Skip to content

Commit ccab434

Browse files
oneukumdavem330
authored andcommitted
usb: aqc111: check packet for fixup for true limit
If a device sends a packet that is inbetween 0 and sizeof(u64) the value passed to skb_trim() as length will wrap around ending up as some very large value. The driver will then proceed to parse the header located at that position, which will either oops or process some random value. The fix is to check against sizeof(u64) rather than 0, which the driver currently does. The issue exists since the introduction of the driver. Signed-off-by: Oliver Neukum <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7475e51 commit ccab434

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/usb/aqc111.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,17 +1079,17 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
10791079
u16 pkt_count = 0;
10801080
u64 desc_hdr = 0;
10811081
u16 vlan_tag = 0;
1082-
u32 skb_len = 0;
1082+
u32 skb_len;
10831083

10841084
if (!skb)
10851085
goto err;
10861086

1087-
if (skb->len == 0)
1087+
skb_len = skb->len;
1088+
if (skb_len < sizeof(desc_hdr))
10881089
goto err;
10891090

1090-
skb_len = skb->len;
10911091
/* RX Descriptor Header */
1092-
skb_trim(skb, skb->len - sizeof(desc_hdr));
1092+
skb_trim(skb, skb_len - sizeof(desc_hdr));
10931093
desc_hdr = le64_to_cpup((u64 *)skb_tail_pointer(skb));
10941094

10951095
/* Check these packets */

0 commit comments

Comments
 (0)