From: sashiko-bot@kernel.org
To: "Birger Koblitz" <mail@birger-koblitz.de>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v20 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration
Date: Sat, 07 Nov 2026 07:21:53 +0000 [thread overview]
Message-ID: <sashiko-outbox-202698@kernel.org> (raw)
In-Reply-To: <20261106-ax88179a-v20-8-37b5a1189983@birger-koblitz.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: usb: ax88179: TOCTOU race updating AX_RX_CTL in
ax88179_set_multicast()
--
commit f3a2f1850ef2ba90e3243642ec0642d91a64aa9a
Author: Birger Koblitz <mail@birger-koblitz.de>
ax88179_178a: Add AX179A/AX279 multicast configuration
This commit updates ax88179_set_multicast() to configure AX_RX_CTL_DROPCRCERR
and conditionally set AX_RX_CTL_IPE, and wires it up as .ndo_set_rx_mode in
ax88179a_netdev_ops.
> diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c
> index a314db4c97666..b4b00c8b4b623 100644
> --- a/drivers/net/usb/ax88179_lib.c
> +++ b/drivers/net/usb/ax88179_lib.c
> @@ -321,16 +321,21 @@ int ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, u8
> void ax88179_set_multicast(struct net_device *net)
> {
> struct usbnet *dev = netdev_priv(net);
> - struct ax88179_data *data = dev->driver_priv;
> u8 *m_filter = ((u8 *)dev->data);
> + struct ax88179_data *data;
> + u16 rxctl = 0;
> +
> + data = dev->driver_priv;
>
> - data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE);
> + rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR);
> + if (data->ip_align)
> + rxctl |= AX_RX_CTL_IPE;
>
> if (net->flags & IFF_PROMISC) {
> - data->rxctl |= AX_RX_CTL_PRO;
> + rxctl |= AX_RX_CTL_PRO;
> } else if (net->flags & IFF_ALLMULTI ||
> netdev_mc_count(net) > AX_MAX_MCAST) {
> - data->rxctl |= AX_RX_CTL_AMALL;
> + rxctl |= AX_RX_CTL_AMALL;
> } else if (netdev_mc_empty(net)) {
> /* just broadcast and directed */
> } else {
> @@ -351,9 +356,10 @@ void ax88179_set_multicast(struct net_device *net)
> AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE,
> m_filter);
>
> - data->rxctl |= AX_RX_CTL_AM;
> + rxctl |= AX_RX_CTL_AM;
> }
>
> + WRITE_ONCE(data->rxctl, rxctl);
> ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL,
> 2, 2, &data->rxctl);
> }
> diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
> index 4207d2cc2b865..a6b0a3f47118c 100644
> --- a/drivers/net/usb/ax88179a_devices.c
> +++ b/drivers/net/usb/ax88179a_devices.c
> @@ -678,6 +678,7 @@ static const struct net_device_ops ax88179a_netdev_ops = {
> .ndo_set_mac_address = ax88179_set_mac_addr,
> .ndo_validate_addr = eth_validate_addr,
> .ndo_eth_ioctl = ax88179a_mii_ioctl,
> + .ndo_set_rx_mode = ax88179_set_multicast,
> .ndo_set_features = ax88179a_set_features,
> .ndo_vlan_rx_add_vid = ax88179a_vlan_rx_add_vid,
> .ndo_vlan_rx_kill_vid = ax88179a_vlan_rx_kill_vid,
[Severity: Medium]
Can a concurrent ax88179a_mac_link_up() overwrite AX_RX_CTL with a stale
rxctl value after ax88179_set_multicast() updates it?
ax88179_set_multicast() runs in BH context under netif_addr_lock_bh(net),
while ax88179a_mac_link_up() runs in process context from the phylink resolve
workqueue under medium_status_mutex:
drivers/net/usb/ax88179a_devices.c:ax88179a_mac_link_up() {
...
ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, READ_ONCE(ax179_data->rxctl));
mutex_unlock(&ax179_data->medium_status_mutex);
...
}
If an RX mode update (such as an IPv6 MLD multicast join on link up) runs
while ax88179a_mac_link_up() is entering usbnet_write_cmd(), the control URBs
can be queued in the reverse order of the data->rxctl accesses:
CPU0 (kworker) CPU1 (<softirq>)
ax88179a_mac_link_up()
val = READ_ONCE(ax179_data->rxctl)
ax88179_write_u16(..., val)
...
usb_autopm_get_interface()
ax88179_set_multicast()
WRITE_ONCE(data->rxctl, rxctl)
ax88179_write_cmd_async(...)
usb_submit_urb() [new rxctl]
usb_control_msg() [old val]
<-- overwrites AX_RX_CTL with stale rxctl
This leaves the hardware AX_RX_CTL register out of sync with data->rxctl and
silently drops multicast or promiscuous traffic until the next RX mode or
link state change. Deferring the work via usbnet_defer_kevent(dev,
EVENT_SET_RX_MODE) or re-checking rxctl in ax88179a_mac_link_up() would avoid
the race.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-ax88179a-v20-0-37b5a1189983@birger-koblitz.de?part=8
next prev parent reply other threads:[~2026-11-07 7:21 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 7:21 [PATCH net-next v20 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-11-06 7:21 ` [PATCH net-next v20 01/13] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-11-06 10:11 ` Maxime Chevallier
2026-11-06 15:32 ` Birger Koblitz
2026-11-06 15:55 ` Andrew Lunn
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-10 4:46 ` Birger Koblitz
2026-11-10 16:30 ` Andrew Lunn
2026-11-10 16:58 ` Birger Koblitz
2026-11-06 7:21 ` [PATCH net-next v20 02/13] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-06 7:21 ` [PATCH net-next v20 03/13] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 04/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 05/13] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 06/13] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 07/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-11-07 7:21 ` sashiko-bot [this message]
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 09/13] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 11/13] ax88179_178a: Update driver name and information Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 12/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
2026-11-06 7:21 ` [PATCH net-next v20 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-11-07 7:21 ` sashiko-bot
2026-11-10 1:38 ` netdev-bot+sashiko
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-202698@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.