* [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup
@ 2026-11-17 18:28 Birger Koblitz
2026-11-17 18:33 ` netdev-bot+sinfo
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Birger Koblitz @ 2026-11-17 18:28 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: linux-usb, netdev, linux-kernel, Birger Koblitz
The MAC supported by the aqc111 driver is very similar
to the AX88179A. During the development of the driver for
the AX88179A, the following issues in endianness-handling
were found, which are also present in the aqc111 driver:
CHECK drivers/net/usb/aqc111.c
drivers/net/usb/aqc111.c:1094:34: warning: incorrect type in argument 1 (different base types)
drivers/net/usb/aqc111.c:1094:34: expected restricted __le64 const [usertype] *p
drivers/net/usb/aqc111.c:1094:34: got unsigned long long [usertype] *
drivers/net/usb/aqc111.c:1122:45: warning: incorrect type in argument 1 (different base types)
drivers/net/usb/aqc111.c:1122:45: expected restricted __le64 const [usertype] *p
drivers/net/usb/aqc111.c:1122:45: got unsigned long long [usertype] *[assigned] pkt_desc_ptr
drivers/net/usb/aqc111.c:1235:22: warning: incorrect type in assignment (different base types)
drivers/net/usb/aqc111.c:1235:22: expected unsigned long long [usertype]
drivers/net/usb/aqc111.c:1235:22: got restricted __le64 [usertype]
Fix these problems and additionally also make sure that cloned
skbs are always copied for expansion.
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
The MAC supported by the aqc111 driver is very similar
to the AX88179A. During the development of the driver for
the AX88179A, the following issues in endianness-handling
were found, which are also present in the aqc111 driver:
CHECK drivers/net/usb/aqc111.c
drivers/net/usb/aqc111.c:1094:34: warning: incorrect type in argument 1 (different base types)
drivers/net/usb/aqc111.c:1094:34: expected restricted __le64 const [usertype] *p
drivers/net/usb/aqc111.c:1094:34: got unsigned long long [usertype] *
drivers/net/usb/aqc111.c:1122:45: warning: incorrect type in argument 1 (different base types)
drivers/net/usb/aqc111.c:1122:45: expected restricted __le64 const [usertype] *p
drivers/net/usb/aqc111.c:1122:45: got unsigned long long [usertype] *[assigned] pkt_desc_ptr
drivers/net/usb/aqc111.c:1235:22: warning: incorrect type in assignment (different base types)
drivers/net/usb/aqc111.c:1235:22: expected unsigned long long [usertype]
ddrivers/net/usb/aqc111.c:1235:22: got restricted __le64 [usertype]
Fix these problems and additionally also make sure that cloned
skbs are always copied for expansion.
---
drivers/net/usb/aqc111.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
index dd53f413c38f6035c18f9922fd4e90d66a73ae53..39d8755ca8e7bff484100f82863cc2ac8582fcc9 100644
--- a/drivers/net/usb/aqc111.c
+++ b/drivers/net/usb/aqc111.c
@@ -1074,7 +1074,7 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
struct aqc111_data *aqc111_data = dev->driver_priv;
struct sk_buff *new_skb = NULL;
u32 pkt_total_offset = 0;
- u64 *pkt_desc_ptr = NULL;
+ __le64 *pkt_desc_ptr = NULL;
u32 start_of_descs = 0;
u32 desc_offset = 0; /*RX Header Offset*/
u16 pkt_count = 0;
@@ -1091,7 +1091,7 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
/* RX Descriptor Header */
skb_trim(skb, skb_len - sizeof(desc_hdr));
- desc_hdr = le64_to_cpup((u64 *)skb_tail_pointer(skb));
+ desc_hdr = get_unaligned_le64((__le64 *)skb_tail_pointer(skb));
/* Check these packets */
desc_offset = (desc_hdr & AQ_RX_DH_DESC_OFFSET_MASK) >>
@@ -1116,10 +1116,10 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
goto err;
/* Get the first RX packet descriptor */
- pkt_desc_ptr = (u64 *)(skb->data + desc_offset);
+ pkt_desc_ptr = (__le64 *)(skb->data + desc_offset);
while (pkt_count--) {
- u64 pkt_desc = le64_to_cpup(pkt_desc_ptr);
+ u64 pkt_desc = get_unaligned_le64(pkt_desc_ptr);
u32 pkt_len_with_padd = 0;
u32 pkt_len = 0;
@@ -1220,7 +1220,8 @@ static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
headroom = skb_headroom(skb);
tailroom = skb_tailroom(skb);
- if (!(headroom >= sizeof(tx_desc) && tailroom >= padding_size)) {
+ if (skb_cloned(skb) ||
+ !(headroom >= sizeof(tx_desc) && tailroom >= padding_size)) {
new_skb = skb_copy_expand(skb, sizeof(tx_desc),
padding_size, flags);
dev_kfree_skb_any(skb);
@@ -1232,7 +1233,7 @@ static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
skb_put_zero(skb, padding_size);
/* Copy TX header */
tx_desc_ptr = skb_push(skb, sizeof(tx_desc));
- *tx_desc_ptr = cpu_to_le64(tx_desc);
+ put_unaligned_le64(tx_desc, tx_desc_ptr);
usbnet_set_skb_tx_stats(skb, 1, 0);
---
base-commit: 805185b7c7a1069e407b6f7b3bc98e44d415f484
change-id: 20261117-aqc111-b0cf408d776b
Best regards,
--
Birger Koblitz <mail@birger-koblitz.de>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup 2026-11-17 18:28 [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup Birger Koblitz @ 2026-11-17 18:33 ` netdev-bot+sinfo 2026-11-19 19:41 ` Andrew Lunn 2026-11-20 6:29 ` netdev-bot+sashiko 2 siblings, 0 replies; 7+ messages in thread From: netdev-bot+sinfo @ 2026-11-17 18:33 UTC (permalink / raw) To: Birger Koblitz Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-usb, netdev, linux-kernel Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. *IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages. -- The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup 2026-11-17 18:28 [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup Birger Koblitz 2026-11-17 18:33 ` netdev-bot+sinfo @ 2026-11-19 19:41 ` Andrew Lunn 2026-11-22 7:38 ` Birger Koblitz 2026-11-20 6:29 ` netdev-bot+sashiko 2 siblings, 1 reply; 7+ messages in thread From: Andrew Lunn @ 2026-11-19 19:41 UTC (permalink / raw) To: Birger Koblitz Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-usb, netdev, linux-kernel > - desc_hdr = le64_to_cpup((u64 *)skb_tail_pointer(skb)); > + desc_hdr = get_unaligned_le64((__le64 *)skb_tail_pointer(skb)); static inline u64 get_unaligned_le64(const void *p) { return le64_to_cpu(__get_unaligned_t(__le64, p)); } You should cast to a void *, not __le64 *. I'm not even sure a cast is needed: static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb) { return skb->head + skb->tail; } The compiler should do an implicit cast. Andrew ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup 2026-11-19 19:41 ` Andrew Lunn @ 2026-11-22 7:38 ` Birger Koblitz 2026-11-22 12:47 ` Daniel Golle 0 siblings, 1 reply; 7+ messages in thread From: Birger Koblitz @ 2026-11-22 7:38 UTC (permalink / raw) To: Andrew Lunn Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-usb, netdev, linux-kernel Hi Andrew, thanks for looking at this! On 19/11/2026 8:41 pm, Andrew Lunn wrote: >> - desc_hdr = le64_to_cpup((u64 *)skb_tail_pointer(skb)); >> + desc_hdr = get_unaligned_le64((__le64 *)skb_tail_pointer(skb)); > > static inline u64 get_unaligned_le64(const void *p) > { > return le64_to_cpu(__get_unaligned_t(__le64, p)); > } > > You should cast to a void *, not __le64 *. I'm not even sure a cast is > needed: > > static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb) > { > return skb->head + skb->tail; > } > > The compiler should do an implicit cast. > > Andrew Indeed, no cast is needed: desc_hdr = get_unaligned_le64(skb_tail_pointer(skb)); compiles and makes sparse happy: $ make C=1 drivers/net/ DESCEND objtool CC [M] drivers/net/usb/aqc111.o CHECK drivers/net/usb/aqc111.c I will re-send, also taking the comments from the LLM into account. Birger ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup 2026-11-22 7:38 ` Birger Koblitz @ 2026-11-22 12:47 ` Daniel Golle 0 siblings, 0 replies; 7+ messages in thread From: Daniel Golle @ 2026-11-22 12:47 UTC (permalink / raw) To: Birger Koblitz Cc: Andrew Lunn, Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-usb, netdev, linux-kernel On Sun, Nov 22, 2026 at 08:38:40AM +0100, Birger Koblitz wrote: > I will re-send, also taking the comments from the LLM into account. Please lso fix the Subject-line to include "net: usb:" as prefix. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup 2026-11-17 18:28 [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup Birger Koblitz 2026-11-17 18:33 ` netdev-bot+sinfo 2026-11-19 19:41 ` Andrew Lunn @ 2026-11-20 6:29 ` netdev-bot+sashiko 2026-11-22 10:55 ` Birger Koblitz 2 siblings, 1 reply; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-20 6:29 UTC (permalink / raw) To: mail Cc: andrew+netdev, davem, edumazet, kuba, pabeni, linux-usb, netdev, linux-kernel Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 (1) · Medium: 1 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The new `skb_cloned(skb) ||` term in aqc111_tx_fixup() (drivers/net/usb/aqc111.c:1223) sends every cloned TX skb to… - [Low] The commit message misdescribes the change. - [Low] The patch fixes real runtime bugs but has no Fixes: tag and no stable Cc, and its message reads like a sparse cleanup. Pre-existing issues: - [High] This problem wasn't introduced by this patch, but aqc111_rx_fixup() takes pkt_len from the device-controlled per-packet… -- aqc111: Correct endianness handling in rx/tx_fixup This commit moves the RX and TX descriptor accesses in aqc111_rx_fixup() and aqc111_tx_fixup() to __le64 pointers with get_unaligned_le64() and put_unaligned_le64(), to address sparse warnings. It also makes aqc111_tx_fixup() always copy cloned skbs via skb_copy_expand(). > aqc111: Correct endianness handling in rx/tx_fixup [Severity: Low] Does "endianness handling" accurately describe what changes here? The old code already got the byte order right. le64_to_cpup() is le64_to_cpu(*p), and the TX path stored cpu_to_le64(tx_desc). Sparse was only complaining about the missing __le64 annotations. The runtime changes in the patch are different, and the message doesn't describe them: - Plain 64-bit loads and stores become get_unaligned_le64() and put_unaligned_le64(), which is an alignment fix. aqc111 never sets EVENT_NO_IP_ALIGN, so RX skbs carry the NET_IP_ALIGN offset, and desc_offset is a multiple of 8. On NET_IP_ALIGN=2 architectures, the trailing descriptor header and the descriptor array both sit at 2 mod 8. On TX, skb->data - 8 is normally 2 mod 4. - aqc111_tx_fixup() now always copies cloned skbs, and the message covers that with only this sentence: > Fix these problems and additionally also make sure that cloned > skbs are always copied for expansion. Could the subject and body describe the alignment change and the cloned-skb change, so the patch isn't mistaken for a cosmetic sparse cleanup? [Severity: Low] Should this carry Fixes: tags, and maybe be split into an alignment fix and a cloned-skb fix? Two problems are fixed here. The 64-bit descriptor accesses in aqc111_rx_fixup() and aqc111_tx_fixup() are misaligned. aqc111_tx_fixup() also writes the TX descriptor and padding in place into the headroom and tailroom of cloned skbs. Both go back to the original aqc111 RX/TX data path commits. Without Fixes: tags or a stable Cc, these fixes may not reach stable kernels, and the patch may go to net-next instead of net. > diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c > index dd53f413c38f6..39d8755ca8e7b 100644 > --- a/drivers/net/usb/aqc111.c > +++ b/drivers/net/usb/aqc111.c [ ... ] > @@ -1116,10 +1116,10 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) > goto err; > > /* Get the first RX packet descriptor */ > - pkt_desc_ptr = (u64 *)(skb->data + desc_offset); > + pkt_desc_ptr = (__le64 *)(skb->data + desc_offset); > > while (pkt_count--) { > - u64 pkt_desc = le64_to_cpup(pkt_desc_ptr); > + u64 pkt_desc = get_unaligned_le64(pkt_desc_ptr); > u32 pkt_len_with_padd = 0; > u32 pkt_len = 0; [Severity: High] This is a pre-existing issue, not one introduced by this patch, but is aqc111_rx_fixup() missing a lower bound on pkt_len? pkt_len comes from the device-supplied descriptor, and only an upper bound is checked: drivers/net/usb/aqc111.c:aqc111_rx_fixup() { ... if (pkt_desc & AQ_RX_PD_DROP || !(pkt_desc & AQ_RX_PD_RX_OK) || pkt_len > (dev->hard_mtu + AQ_RX_HW_PAD)) { ... skb_put(new_skb, pkt_len); memcpy(new_skb->data, skb->data, pkt_len); skb_pull(new_skb, AQ_RX_HW_PAD); ... usbnet_skb_return(dev, new_skb); ... } A malicious or broken USB device can report a pkt_len below ETH_HLEN + AQ_RX_HW_PAD and still keep pkt_total_offset equal to desc_offset. When pkt_len < 2, the skb_pull() above silently fails. The runt skb then goes through usbnet_skb_return()->eth_type_trans(), which doesn't check the length. The 14 byte ethhdr is read from bytes that were never written, so skb->protocol and pkt_type come from uninitialized memory. The skb is then passed to netif_rx() without ETH_HLEN having been pulled. If the device is bridged, br_dev_queue_push_xmit() calls skb_push(skb, ETH_HLEN) into headroom that was never written. That could transmit about 12 bytes of stale kernel memory on another port. An AF_PACKET reader could also get uninitialized bytes in sll_addr. Would rejecting pkt_len < ETH_HLEN + AQ_RX_HW_PAD in the drop condition above prevent this? [ ... ] > @@ -1220,7 +1220,8 @@ static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb, > headroom = skb_headroom(skb); > tailroom = skb_tailroom(skb); > > - if (!(headroom >= sizeof(tx_desc) && tailroom >= padding_size)) { > + if (skb_cloned(skb) || > + !(headroom >= sizeof(tx_desc) && tailroom >= padding_size)) { > new_skb = skb_copy_expand(skb, sizeof(tx_desc), > padding_size, flags); > dev_kfree_skb_any(skb); [Severity: Medium] Does this new skb_cloned() check force a full payload copy for every TCP data skb? TCP transmits clones from __tcp_transmit_skb(), so skb_cloned() is true for these skbs by the time they reach ndo_start_xmit. TCP also marks them nohdr, so skb_header_cloned() is false. Writing the 8 byte descriptor into their headroom was therefore already allowed. skb_copy_expand() allocates a new linear buffer of 8 + skb->len + padding_size using the caller's GFP flags. It then copies the whole payload, including the frags. This bites hardest when usb_device_no_sg_constraint() sets can_dma_sg in aqc111_bind() and AQ_SUPPORT_FEATURE enables NETIF_F_SG and NETIF_F_TSO. In that case the skb_linearize() call earlier in aqc111_tx_fixup() is skipped. Before this patch, a nonlinear TSO skb with padding_size == 0 went straight to skb_push(). Now it gets a linearizing copy of up to about 64KB. That needs a high-order atomic allocation, and the packet is dropped if the allocation fails. Linear cloned skbs are copied too, for example every packet while an AF_PACKET tap is active. Nonlinear skbs that need padding were already copied before this patch, because skb_tailroom() returns 0 for them. The sibling ax88179_tx_fixup() only unshares the head: drivers/net/usb/ax88179_178a.c:ax88179_tx_fixup() { ... if ((skb_header_cloned(skb) || headroom < 0) && pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) { ... } Would skb_header_cloned() plus pskb_expand_head(), sized for the descriptor and the padding, be enough here? The commit message also doesn't say which problem the cloned check fixes. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117-aqc111-v1-1-27a54c4b54ca%40birger-koblitz.de ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup 2026-11-20 6:29 ` netdev-bot+sashiko @ 2026-11-22 10:55 ` Birger Koblitz 0 siblings, 0 replies; 7+ messages in thread From: Birger Koblitz @ 2026-11-22 10:55 UTC (permalink / raw) To: netdev-bot+sashiko Cc: andrew+netdev, davem, edumazet, kuba, pabeni, linux-usb, netdev, linux-kernel On 20/11/2026 7:29 am, netdev-bot+sashiko@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 3 potential > issue(s) to consider. > > Critical: 0 · High: 0 (1) · Medium: 1 · Low: 2 > > If you believe none of the issues are legitimate, please reply to each > issue of Medium severity or higher and explain why the AI is wrong. > If any of them are legitimate and you plan to respin, please let patchwork > know by including "pw-bot: cr" as a separate line at the end of your reply > (one such reply per series is enough). > > - [Medium] The new `skb_cloned(skb) ||` term in aqc111_tx_fixup() > (drivers/net/usb/aqc111.c:1223) sends every cloned TX skb to… > - [Low] The commit message misdescribes the change. > - [Low] The patch fixes real runtime bugs but has no Fixes: tag and no > stable Cc, and its message reads like a sparse cleanup. > > Pre-existing issues: > - [High] This problem wasn't introduced by this patch, but > aqc111_rx_fixup() takes pkt_len from the device-controlled per-packet… > > -- > > aqc111: Correct endianness handling in rx/tx_fixup > > This commit moves the RX and TX descriptor accesses in aqc111_rx_fixup() > and aqc111_tx_fixup() to __le64 pointers with get_unaligned_le64() and > put_unaligned_le64(), to address sparse warnings. It also makes > aqc111_tx_fixup() always copy cloned skbs via skb_copy_expand(). > >> aqc111: Correct endianness handling in rx/tx_fixup > > [Severity: Low] > Does "endianness handling" accurately describe what changes here? > > The old code already got the byte order right. le64_to_cpup() is > le64_to_cpu(*p), and the TX path stored cpu_to_le64(tx_desc). Sparse was > only complaining about the missing __le64 annotations. > > The runtime changes in the patch are different, and the message doesn't > describe them: > > - Plain 64-bit loads and stores become get_unaligned_le64() and > put_unaligned_le64(), which is an alignment fix. aqc111 never sets > EVENT_NO_IP_ALIGN, so RX skbs carry the NET_IP_ALIGN offset, and > desc_offset is a multiple of 8. On NET_IP_ALIGN=2 architectures, the > trailing descriptor header and the descriptor array both sit at 2 mod 8. > On TX, skb->data - 8 is normally 2 mod 4. > > - aqc111_tx_fixup() now always copies cloned skbs, and the message covers > that with only this sentence: > >> Fix these problems and additionally also make sure that cloned >> skbs are always copied for expansion. > > Could the subject and body describe the alignment change and the > cloned-skb change, so the patch isn't mistaken for a cosmetic sparse > cleanup? I will adapt the commit message and subject and make sure this is not misunderstood as cosmetics. > > [Severity: Low] > Should this carry Fixes: tags, and maybe be split into an alignment fix and > a cloned-skb fix? > > Two problems are fixed here. The 64-bit descriptor accesses in > aqc111_rx_fixup() and aqc111_tx_fixup() are misaligned. aqc111_tx_fixup() > also writes the TX descriptor and padding in place into the headroom and > tailroom of cloned skbs. Both go back to the original aqc111 RX/TX data > path commits. > > Without Fixes: tags or a stable Cc, these fixes may not reach stable > kernels, and the patch may go to net-next instead of net. > >> diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c >> index dd53f413c38f6..39d8755ca8e7b 100644 >> --- a/drivers/net/usb/aqc111.c >> +++ b/drivers/net/usb/aqc111.c > > [ ... ] > >> @@ -1116,10 +1116,10 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb) >> goto err; >> >> /* Get the first RX packet descriptor */ >> - pkt_desc_ptr = (u64 *)(skb->data + desc_offset); >> + pkt_desc_ptr = (__le64 *)(skb->data + desc_offset); >> >> while (pkt_count--) { >> - u64 pkt_desc = le64_to_cpup(pkt_desc_ptr); >> + u64 pkt_desc = get_unaligned_le64(pkt_desc_ptr); >> u32 pkt_len_with_padd = 0; >> u32 pkt_len = 0; > I will keep this together but describe the fix better. The fix comprises very few spot changes and should also be understandable as is. > [Severity: High] > This is a pre-existing issue, not one introduced by this patch, but is > aqc111_rx_fixup() missing a lower bound on pkt_len? > > pkt_len comes from the device-supplied descriptor, and only an upper bound > is checked: > > drivers/net/usb/aqc111.c:aqc111_rx_fixup() { > ... > if (pkt_desc & AQ_RX_PD_DROP || > !(pkt_desc & AQ_RX_PD_RX_OK) || > pkt_len > (dev->hard_mtu + AQ_RX_HW_PAD)) { > ... > skb_put(new_skb, pkt_len); > memcpy(new_skb->data, skb->data, pkt_len); > skb_pull(new_skb, AQ_RX_HW_PAD); > ... > usbnet_skb_return(dev, new_skb); > ... > } > > A malicious or broken USB device can report a pkt_len below > ETH_HLEN + AQ_RX_HW_PAD and still keep pkt_total_offset equal to > desc_offset. When pkt_len < 2, the skb_pull() above silently fails. > > The runt skb then goes through usbnet_skb_return()->eth_type_trans(), which > doesn't check the length. The 14 byte ethhdr is read from bytes that were > never written, so skb->protocol and pkt_type come from uninitialized > memory. The skb is then passed to netif_rx() without ETH_HLEN having been > pulled. > > If the device is bridged, br_dev_queue_push_xmit() calls > skb_push(skb, ETH_HLEN) into headroom that was never written. That could > transmit about 12 bytes of stale kernel memory on another port. An > AF_PACKET reader could also get uninitialized bytes in sll_addr. > > Would rejecting pkt_len < ETH_HLEN + AQ_RX_HW_PAD in the drop condition > above prevent this? > I will add this fix. > [ ... ] > >> @@ -1220,7 +1220,8 @@ static struct sk_buff *aqc111_tx_fixup(struct usbnet *dev, struct sk_buff *skb, >> headroom = skb_headroom(skb); >> tailroom = skb_tailroom(skb); >> >> - if (!(headroom >= sizeof(tx_desc) && tailroom >= padding_size)) { >> + if (skb_cloned(skb) || >> + !(headroom >= sizeof(tx_desc) && tailroom >= padding_size)) { >> new_skb = skb_copy_expand(skb, sizeof(tx_desc), >> padding_size, flags); >> dev_kfree_skb_any(skb); > > [Severity: Medium] > Does this new skb_cloned() check force a full payload copy for every TCP > data skb? > > TCP transmits clones from __tcp_transmit_skb(), so skb_cloned() is true > for these skbs by the time they reach ndo_start_xmit. TCP also marks them > nohdr, so skb_header_cloned() is false. Writing the 8 byte descriptor into > their headroom was therefore already allowed. > > skb_copy_expand() allocates a new linear buffer of > 8 + skb->len + padding_size using the caller's GFP flags. It then copies > the whole payload, including the frags. > > This bites hardest when usb_device_no_sg_constraint() sets can_dma_sg in > aqc111_bind() and AQ_SUPPORT_FEATURE enables NETIF_F_SG and NETIF_F_TSO. > In that case the skb_linearize() call earlier in aqc111_tx_fixup() is > skipped. > > Before this patch, a nonlinear TSO skb with padding_size == 0 went straight > to skb_push(). Now it gets a linearizing copy of up to about 64KB. That > needs a high-order atomic allocation, and the packet is dropped if the > allocation fails. > > Linear cloned skbs are copied too, for example every packet while an > AF_PACKET tap is active. Nonlinear skbs that need padding were already > copied before this patch, because skb_tailroom() returns 0 for them. > > The sibling ax88179_tx_fixup() only unshares the head: > > drivers/net/usb/ax88179_178a.c:ax88179_tx_fixup() { > ... > if ((skb_header_cloned(skb) || headroom < 0) && > pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) { > ... > } > > Would skb_header_cloned() plus pskb_expand_head(), sized for the > descriptor and the padding, be enough here? The change fixes a definite error in case the skb was cloned. The fix may be relatively resource-intensive in case it is triggered, however it is preferable for the code to be correct. I cannot further optimize this code as I do not have actual hardware to test. > > The commit message also doesn't say which problem the cloned check fixes. I will add this. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-22 12:48 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-17 18:28 [PATCH net-next] aqc111: Correct endianness handling in rx/tx_fixup Birger Koblitz 2026-11-17 18:33 ` netdev-bot+sinfo 2026-11-19 19:41 ` Andrew Lunn 2026-11-22 7:38 ` Birger Koblitz 2026-11-22 12:47 ` Daniel Golle 2026-11-20 6:29 ` netdev-bot+sashiko 2026-11-22 10:55 ` Birger Koblitz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®