Skip to content

Commit ecf7cf8

Browse files
szymonhPaolo Abeni
authored andcommitted
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: e9da0b5 ("sr9700: sanity check for packet length") Signed-off-by: Szymon Heidrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 87b93b6 commit ecf7cf8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/usb/sr9700.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
413413
/* ignore the CRC length */
414414
len = (skb->data[1] | (skb->data[2] << 8)) - 4;
415415

416-
if (len > ETH_FRAME_LEN || len > skb->len)
416+
if (len > ETH_FRAME_LEN || len > skb->len || len < 0)
417417
return 0;
418418

419419
/* the last packet of current skb */

0 commit comments

Comments
 (0)