Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Birger Koblitz" <mail@birger-koblitz.de>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v17 04/13] ax88179_178a: Add HW support for AX179A-based chips
Date: Wed, 07 Oct 2026 03:05:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-162610@kernel.org> (raw)
In-Reply-To: <20261006-ax88179a-v17-4-252814fe35ea@birger-koblitz.de>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] net: usb: ax88179_178a: AB-BA deadlock between rtnl_lock and phylink_resolve
- [High] net: usb: ax88179_178a: direct modification of cloned SKB in tx_fixup corrupts data
- [High] net: usb: ax88179_178a: unaligned memory access in rx_fixup when parsing descriptors
- [Medium] net: usb: ax88179_178a: missing MAC_10 capability for AX88279 prevents 10Mbps links
--

commit 30ef18704c5826b2296627db92bef2b5bafb38bf
Author: Birger Koblitz <mail@birger-koblitz.de>
Subject: ax88179_178a: Add HW support for AX179A-based chips

This patch adds bindings and hardware support for AX179A-based USB-Ethernet
controllers, including the AX88279, AX88179A/B, and AX772D/E. It introduces
a vendor interface that can be activated to take precedence over CDC-NCM.

> diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/net/usb/ax88179a_devices.c
[ ... ]
> +static void ax88179a_mac_link_up(struct phylink_config *config,
> +				 struct phy_device *phy,
> +				 unsigned int phy_mode, phy_interface_t interface,
> +				 int speed, int duplex,
> +				 bool tx_pause, bool rx_pause)
> +{
[ ... ]
> +	if (duplex)
> +		mode |= AX_MEDIUM_FULL_DUPLEX;
> +
> +	rtnl_lock();
> +	if (dev->net->mtu > 1500)
> +		mode |= AX_MEDIUM_JUMBO_EN;
> +	ax88179_write_u16(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, mode);
> +
> +	ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, READ_ONCE(ax179_data->rxctl));
> +	rtnl_unlock();

[Severity: High]
Does this introduce an AB-BA deadlock with dev_close()? The phylink_resolve
workqueue runs asynchronously and calls mac_link_up, which acquires
rtnl_lock() here.

Concurrently, if the interface is brought down, dev_close() holds
rtnl_lock() and eventually calls ndo_stop (usbnet_stop) which delegates
to ax88179a_stop() and then phylink_stop(). Since phylink_stop() calls
flush_work(&pl->resolve), both threads could wait forever if the workqueue
is actively executing mac_link_up and blocked waiting for rtnl_lock().

[ ... ]
> +static int ax88179a_phylink_setup(struct usbnet *dev)
> +{
[ ... ]
> +	data->phylink_config.mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_100;
> +	if (data->is_ax88772d)
> +		data->phylink_config.mac_capabilities |= MAC_10;
> +	else if (data->chip_version < AX_VERSION_AX88279)
> +		data->phylink_config.mac_capabilities |= MAC_10 | MAC_1000;
> +	else
> +		data->phylink_config.mac_capabilities |= MAC_1000 | MAC_2500FD;

[Severity: Medium]
Will omitting MAC_10 here prevent the PHY from negotiating 10Mbps link
speeds for the AX88279?

The driver explicitly provides a bulk configuration for BULK_IN_SPEED_FS
(10Mbps full-speed) for this chip in the AX88279_BULKIN_SIZE array, but
without MAC_10, phylink might reject 10Mbps link modes entirely and
prevent fallback to legacy switches.

[ ... ]
> +static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> +{
[ ... ]
> +	if (!skb || skb->len < sizeof(rx_hdr))
> +		goto err;
> +
> +	/* RX Descriptor Header */
> +	skb_trim(skb, skb->len - sizeof(rx_hdr));
> +	rx_hdr = le64_to_cpup((__le64 *)skb_tail_pointer(skb));

[Severity: High]
Could this cause unaligned memory access panics on architectures with strict
alignment requirements (like SPARC or older ARM)?

The usbnet framework uses a 2-byte IP alignment offset by default (and
ip_align = 1 for some chips here), meaning skb_tail_pointer(skb) is likely
not 8-byte aligned. Calling le64_to_cpup() on unaligned pointers can
trigger traps. Should this use get_unaligned_le64() instead?

[ ... ]
> +	/* Get the first RX packet descriptor */
> +	pkt_desc_ptr = (__le64 *)(skb->data + hdr_off);
> +
> +	pkt_end = 0;
> +	while (pkt_cnt--) {
> +		u64 pkt_desc = le64_to_cpup(pkt_desc_ptr);

[Severity: High]
Similarly, is pkt_desc_ptr guaranteed to be 8-byte aligned here? With the
2-byte IP alignment offset, this might also require get_unaligned_le64().

[ ... ]
> +static struct sk_buff *ax88179a_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
> +{
[ ... ]
> +	headroom = skb_headroom(skb);
> +	tailroom = skb_tailroom(skb);
> +
> +	if (!(headroom >= sizeof(tx_desc) && tailroom >= padding_size)) {
> +		ax_skb = skb_copy_expand(skb, sizeof(tx_desc), padding_size, flags);
> +		dev_kfree_skb_any(skb);
> +		skb = ax_skb;
> +		if (!skb)
> +			return NULL;
> +	}
> +	if (padding_size != 0)
> +		skb_put_zero(skb, padding_size);
> +	/* Copy TX header */
> +	tx_desc_ptr = skb_push(skb, sizeof(tx_desc));
> +	put_unaligned_le64(tx_desc, tx_desc_ptr);

[Severity: High]
Could this corrupt data if the SKB is shared or cloned?

The validation checks for headroom and tailroom, but it appears to miss a
call to skb_cloned() or skb_cow_head() before modifying the packet
boundaries with skb_put_zero() and skb_push().

If the packet is being transmitted by subsystems that clone SKBs (like TCP
retransmits or packet sniffers), modifying this linear buffer will alter
the payload for all concurrent users, which can lead to silent data
corruption or use-after-free panics.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006-ax88179a-v17-0-252814fe35ea@birger-koblitz.de?part=4

  reply	other threads:[~2026-10-07  3:05 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06  3:05 [PATCH net-next v17 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 01/13] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-07  3:55     ` Fwd: " Birger Koblitz
2026-10-07 12:18       ` Andrew Lunn
2026-10-07 14:16         ` Birger Koblitz
2026-10-08  3:34     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 02/13] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:36     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 03/13] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:38     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 04/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-10-07  3:05   ` sashiko-bot [this message]
2026-10-08  3:41     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 05/13] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 06/13] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 07/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:44     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 09/13] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:47     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 11/13] ax88179_178a: Update driver name and information Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:48     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 12/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:50     ` Birger Koblitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-162610@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mail@birger-koblitz.de \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox