OSDN Git Service

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)
commita6921dd524fe31d1f460c161d3526a407533b6db
tree26020c437850d8682866b576e4aadb0cbd35d242
parent79c43333bdd5a7026a5aab606b53053b643585e7
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: 0a25e1f4f185 ("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