Commit f39d3341 authored by Oliver Neukum's avatar Oliver Neukum Committed by Yongqiang Liu
Browse files

usb: aqc111: check packet for fixup for true limit

stable inclusion
from stable-v5.10.205
commit d69581c17608d81824dd497d9a54b6a5b6139975
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9OZ9P


CVE: CVE-2023-52655

--------------------------------

[ Upstream commit ccab434e674ca95d483788b1895a70c21b7f016a ]

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: default avatarOliver Neukum <oneukum@suse.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
parent 18a75d0a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1079,17 +1079,17 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
	u16 pkt_count = 0;
	u64 desc_hdr = 0;
	u16 vlan_tag = 0;
	u32 skb_len = 0;
	u32 skb_len;

	if (!skb)
		goto err;

	if (skb->len == 0)
	skb_len = skb->len;
	if (skb_len < sizeof(desc_hdr))
		goto err;

	skb_len = skb->len;
	/* RX Descriptor Header */
	skb_trim(skb, skb->len - sizeof(desc_hdr));
	skb_trim(skb, skb_len - sizeof(desc_hdr));
	desc_hdr = le64_to_cpup((u64 *)skb_tail_pointer(skb));

	/* Check these packets */