]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commita986f4b5e34e1f088bf3c07001ae63be72aea684
tree5f561038080d2b31941a39fec548e60edfc28e4c
parent5ad65f0798a8adcbf0574a1c6f70eda4002c7867
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