]> git.baikalelectronics.ru Git - kernel.git/commit
can: peak_usb: add range checking in decode operations
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 13 Aug 2020 14:06:04 +0000 (17:06 +0300)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 3 Nov 2020 21:30:32 +0000 (22:30 +0100)
commit151673de47ca1530f092bd28af854e6a9f6aafbf
tree26020c437850d8682866b576e4aadb0cbd35d242
parent9a68d3391575766a8dc6967b74e458b95d6b3386
can: peak_usb: add range checking in decode operations

These values come from skb->data so Smatch considers them untrusted.  I
believe Smatch is correct but I don't have a way to test this.

The usb_if->dev[] array has 2 elements but the index is in the 0-15
range without checks.  The cfd->len can be up to 255 but the maximum
valid size is CANFD_MAX_DLEN (64) so that could lead to memory
corruption.

Fixes: 3974c183698c ("can: peak_usb: add support for PEAK new CANFD USB adapters")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200813140604.GA456946@mwanda
Acked-by: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/peak_usb/pcan_usb_fd.c