Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: usb: sr9700: Handle negative len

Packet len computed as difference of length word extracted from
skb data and four may result in a negative value. In such case
processing of the buffer should be interrupted rather than
setting sr_skb->len to an unexpectedly large value (due to cast
from signed to unsigned integer) and passing sr_skb to
usbnet_skb_return.

Fixes: e9da0b56fe27 ("sr9700: sanity check for packet length")
Signed-off-by: Szymon Heidrich <szymon.heidrich@gmail.com>
Link: https://lore.kernel.org/r/20230114182326.30479-1-szymon.heidrich@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Szymon Heidrich and committed by
Paolo Abeni
ecf7cf8e 87b93b67

+1 -1
+1 -1
drivers/net/usb/sr9700.c
··· 413 413 /* ignore the CRC length */ 414 414 len = (skb->data[1] | (skb->data[2] << 8)) - 4; 415 415 416 - if (len > ETH_FRAME_LEN || len > skb->len) 416 + if (len > ETH_FRAME_LEN || len > skb->len || len < 0) 417 417 return 0; 418 418 419 419 /* the last packet of current skb */