* [PATCH net-next v2] aqc111: Fix rx/tx_fixup issues
@ 2026-11-22 11:09 Birger Koblitz
2026-11-22 11:13 ` netdev-bot+sinfo
2026-11-23 11:10 ` sashiko-bot
0 siblings, 2 replies; 3+ messages in thread
From: Birger Koblitz @ 2026-11-22 11:09 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet
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, respectively
alignment-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]
While sparse complains about lack of the use of __le64, these spots also
incorrectly handle alignment. Fix these problems by introducing __le64
where necessary and additionally make use of get_unaligned_le64/
put_unalignged_le64().
The current code also incorrectly modifies the skb buffer without checking
it was cloned, possibly corrupting a shared buffer. This issue is also
fixed.
Finally, also introduce a minimum lengthe check for packets as the packet
length is received via a USB transfer and may be incorrect.
Fixes: 361459cd9642 ("net: usb: aqc111: Implement RX data path")
Fixes: 4a3576d2bcc7 ("net: usb: aqc111: Implement TX data path")
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. Finally also a length-cleck
on the minimum length of received packets is added.
---
Changes in v2:
- Do not use cast in desc_hdr = get_unaligned_le64((__le64 *)skb_tail_pointer(skb));
- Added packet-length check
- Improved commit subject and description covering alignment and skb-cloned
fixes
- Link to v1: https://lore.kernel.org/r/20261117-aqc111-v1-1-27a54c4b54ca@birger-koblitz.de
---
drivers/net/usb/aqc111.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
index 12a99df77f0d332053852e44991188c690c4c0bc..ee7c8bb858458418048dc05defe4a642b6d05b05 100644
--- a/drivers/net/usb/aqc111.c
+++ b/drivers/net/usb/aqc111.c
@@ -1078,7 +1078,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;
@@ -1095,7 +1095,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(skb_tail_pointer(skb));
/* Check these packets */
desc_offset = (desc_hdr & AQ_RX_DH_DESC_OFFSET_MASK) >>
@@ -1120,10 +1120,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;
@@ -1139,6 +1139,7 @@ static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
if (pkt_desc & AQ_RX_PD_DROP ||
!(pkt_desc & AQ_RX_PD_RX_OK) ||
+ pkt_len < (ETH_HLEN + AQ_RX_HW_PAD) ||
pkt_len > (dev->hard_mtu + AQ_RX_HW_PAD)) {
skb_pull(skb, pkt_len_with_padd);
/* Next RX Packet Descriptor */
@@ -1224,7 +1225,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);
@@ -1236,7 +1238,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: eb6d6c80d35449c27471b1874f13066c09a8964d
change-id: 20261117-aqc111-b0cf408d776b
Best regards,
--
Birger Koblitz <mail@birger-koblitz.de>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v2] aqc111: Fix rx/tx_fixup issues
2026-11-22 11:09 [PATCH net-next v2] aqc111: Fix rx/tx_fixup issues Birger Koblitz
@ 2026-11-22 11:13 ` netdev-bot+sinfo
2026-11-23 11:10 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-11-22 11:13 UTC (permalink / raw)
To: Birger Koblitz
Cc: Andrew Lunn, David S. Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet, 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] 3+ messages in thread
* Re: [PATCH net-next v2] aqc111: Fix rx/tx_fixup issues
2026-11-22 11:09 [PATCH net-next v2] aqc111: Fix rx/tx_fixup issues Birger Koblitz
2026-11-22 11:13 ` netdev-bot+sinfo
@ 2026-11-23 11:10 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-23 11:10 UTC (permalink / raw)
To: Birger Koblitz; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: usb: aqc111: unnecessary skb_copy_expand() in
aqc111_tx_fixup()
--
commit 72c72c17e1d18f31f018cbdd222d6325ba34956e
Author: Birger Koblitz <mail@birger-koblitz.de>
aqc111: Fix rx/tx_fixup issues
This commit uses unaligned little-endian helpers for RX and TX descriptors,
checks for cloned skbs in aqc111_tx_fixup(), and validates minimum packet
length in aqc111_rx_fixup().
> diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
> index 12a99df77f0d3..ee7c8bb858458 100644
> --- a/drivers/net/usb/aqc111.c
> +++ b/drivers/net/usb/aqc111.c
[ ... ]
> @@ -1224,7 +1225,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);
> @@ -1236,7 +1238,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);
[Severity: Medium]
Does checking skb_cloned(skb) unconditionally force skb_copy_expand() on
every TCP packet even when padding_size == 0?
Outgoing TCP skbs arrive cloned from __tcp_transmit_skb(), but
tcp_skb_entail() calls __skb_header_release(), so skb_header_cloned(skb)
is false and the headroom reserved via needed_headroom is unshared. When
padding_size == 0, aqc111_tx_fixup() only pushes tx_desc into headroom and
never touches the tail, yet this check now copies and linearizes all such
TCP packets (including nonlinear SG/TSO packets when dev->can_dma_sg is
set) under GFP_ATOMIC instead of transmitting their fragments via
build_dma_sg().
Should this check skb_header_cloned(skb) || (padding_size &&
skb_cloned(skb)), matching asix_tx_fixup()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122-aqc111-v2-1-52d5ddb17a37@birger-koblitz.de?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 11:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 11:09 [PATCH net-next v2] aqc111: Fix rx/tx_fixup issues Birger Koblitz
2026-11-22 11:13 ` netdev-bot+sinfo
2026-11-23 11:10 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox