Linux USB
 help / color / mirror / Atom feed
* [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
  0 siblings, 1 reply; 2+ 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 related	[flat|nested] 2+ 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
  0 siblings, 0 replies; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2026-11-17 18:33 UTC | newest]

Thread overview: 2+ 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

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