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 v19 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration
Date: Sun, 11 Oct 2026 04:54:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-167017@kernel.org> (raw)
In-Reply-To: <20261010-ax88179a-v19-8-7475173cfb56@birger-koblitz.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: ax88179: TOCTOU race in AX_RX_CTL hardware update
--

commit 81a7ae4b83e41763b94eb2bd27f7e79602b4f8d5
Author: Birger Koblitz <mail@birger-koblitz.de>

ax88179_178a: Add AX179A/AX279 multicast configuration

Add support for conditionally setting the ip_alignement flag
AX_RX_CTL_IPE in AX_RX_CTL and make sure that AX_RX_CTL_DROPCRCERR
is also set to be consistent with the initial configuration in
ax88179_reset()

> 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
[ ... ]
> @@ -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);
>  }

[Severity: High]
Is it possible for this asynchronous USB write to race with the synchronous
hardware update in ax88179a_mac_link_up()?

Since ndo_set_rx_mode (which calls ax88179_set_multicast) holds
netif_addr_lock_bh() while the phylink state machine runs in a workqueue
without this lock, these two functions can execute concurrently.

This asynchronous write is queued without holding medium_status_mutex.

Meanwhile, ax88179a_mac_link_up() reads data->rxctl, acquires
medium_status_mutex, and executes a synchronous USB write:

    ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2,
                      READ_ONCE(ax179_data->rxctl));
    mutex_unlock(&ax179_data->medium_status_mutex);

If ax88179a_mac_link_up() reads data->rxctl before it is updated here, but
its synchronous USB URB is submitted after this asynchronous URB, will the
USB controller write the new value then immediately overwrite it with the
old value?

Could this leave the hardware state out of sync with the software shadow
state, causing the device to silently drop multicast or promiscuous
configuration?

> 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,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261010-ax88179a-v19-0-7475173cfb56@birger-koblitz.de?part=8

  reply	other threads:[~2026-10-11  4:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10  4:54 [PATCH net-next v19 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-10-10  4:54 ` [PATCH net-next v19 01/13] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-11  5:32     ` Birger Koblitz
2026-10-10  4:54 ` [PATCH net-next v19 02/13] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 03/13] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 04/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 05/13] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 06/13] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 07/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-10-11  4:54   ` sashiko-bot [this message]
2026-10-10  4:54 ` [PATCH net-next v19 09/13] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 11/13] ax88179_178a: Update driver name and information Birger Koblitz
2026-10-11  4:54   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 12/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-10-11  4:55   ` sashiko-bot
2026-10-10  4:54 ` [PATCH net-next v19 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-10-11  4:55   ` sashiko-bot
2026-10-10  6:20 ` [PATCH v19 0/13] ax88179_178a: Add support for AX88179A-based chips Jianhui Xu
2026-10-10  7:42   ` 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-167017@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