can: bcm: check timer values before ktime conversion
authorOliver Hartkopp <socketcan@hartkopp.net>
Sun, 13 Jan 2019 18:31:43 +0000 (19:31 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 22 Jan 2019 10:33:46 +0000 (11:33 +0100)
commit93171ba6f1deffd82f381d36cb13177872d023f6
tree5f561038080d2b31941a39fec548e60edfc28e4c
parent7b12c8189a3dc50638e7d53714c88007268d47ef
can: bcm: check timer values before ktime conversion

Kyungtae Kim detected a potential integer overflow in bcm_[rx|tx]_setup()
when the conversion into ktime multiplies the given value with NSEC_PER_USEC
(1000).

Reference: https://marc.info/?l=linux-can&m=154732118819828&w=2

Add a check for the given tv_usec, so that the value stays below one second.
Additionally limit the tv_sec value to a reasonable value for CAN related
use-cases of 400 days and ensure all values to be positive.

Reported-by: Kyungtae Kim <kt0755@gmail.com>
Tested-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: linux-stable <stable@vger.kernel.org> # >= 2.6.26
Tested-by: Kyungtae Kim <kt0755@gmail.com>
Acked-by: Andre Naujoks <nautsch2@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
net/can/bcm.c