public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.4 01/11] usb: aqc111: check packet for fixup for true limit
@ 2023-11-28 21:09 Sasha Levin
  2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 02/11] blk-throttle: fix lockdep warning of "cgroup_mutex or RCU read lock required!" Sasha Levin
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Sasha Levin @ 2023-11-28 21:09 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Oliver Neukum, David S . Miller, Sasha Levin, edumazet, kuba,
	pabeni, linux-usb, netdev

From: Oliver Neukum <oneukum@suse.com>

[ 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: Oliver Neukum <oneukum@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/usb/aqc111.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
index 68912e266826b..892d58b38cf5b 100644
--- a/drivers/net/usb/aqc111.c
+++ b/drivers/net/usb/aqc111.c
@@ -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 */
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-11-28 21:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-28 21:09 [PATCH AUTOSEL 5.4 01/11] usb: aqc111: check packet for fixup for true limit Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 02/11] blk-throttle: fix lockdep warning of "cgroup_mutex or RCU read lock required!" Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 03/11] bcache: avoid oversize memory allocation by small stripe_size Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 04/11] bcache: add code comments for bch_btree_node_get() and __bch_btree_node_alloc() Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 05/11] bcache: avoid NULL checking to c->root in run_cache_set() Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 06/11] platform/x86: intel_telemetry: Fix kernel doc descriptions Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 07/11] HID: add ALWAYS_POLL quirk for Apple kb Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 08/11] HID: hid-asus: reset the backlight brightness level on resume Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 09/11] HID: multitouch: Add quirk for HONOR GLO-GXXX touchpad Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 10/11] asm-generic: qspinlock: fix queued_spin_value_unlocked() implementation Sasha Levin
2023-11-28 21:09 ` [PATCH AUTOSEL 5.4 11/11] net: usb: qmi_wwan: claim interface 4 for ZTE MF290 Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox