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 v4 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable
Date: Sat, 05 Dec 2026 21:22:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-251903@kernel.org> (raw)
In-Reply-To: <20261204-fcs-v4-1-32773b612c81@birger-koblitz.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: usb: ax88179: unlocked rxctl RMW in
  ax88179_set_multicast()
--

commit 92e42adb3b2a81ab9beb3f4942dd4fe939e57e19
Author: Birger Koblitz <mail@birger-koblitz.de>

net: usb: ax88179: Make receiving FCS on AX88179A configurable

This commit changes ax88179_set_multicast() on AX88179A and newer chips to
read-modify-write data->rxctl and set AX_RX_CTL_DROPCRCERR based on
NETIF_F_RXFCS and NETIF_F_RXALL.  It also stops setting AX_RX_CTL_DROPCRCERR
by default in ax88179a_reset().

> diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c
> index 821ee9cd8ded1..273c5946e16a1 100644
> --- a/drivers/net/usb/ax88179_lib.c
> +++ b/drivers/net/usb/ax88179_lib.c
> @@ -352,14 +352,22 @@ void ax88179_set_multicast(struct net_device *net)
>  	struct usbnet *dev = netdev_priv(net);
>  	u8 *m_filter = ((u8 *)dev->data);
>  	struct ax88179_data *data;
> -	u16 rxctl = 0;
> +	u16 rxctl;
>  
>  	data = dev->driver_priv;
>  
> -	rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR);
> +	if (data->chip_version >= AX_VERSION_AX88179A) {
> +		rxctl = READ_ONCE(data->rxctl);
> +		rxctl &= ~(AX_RX_CTL_IPE | AX_RX_CTL_DROPCRCERR | AX_RX_CTL_PRO |
> +			AX_RX_CTL_AMALL | AX_RX_CTL_AM);
> +	} else {
> +		rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR);
> +	}
>  	if (data->ip_align)
>  		rxctl |= AX_RX_CTL_IPE;
> -
> +	if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) ||
> +	    data->chip_version != AX_VERSION_AX88179A)
> +		rxctl |= AX_RX_CTL_DROPCRCERR; /* Do not remove FCS from frame */
>  	if (net->flags & IFF_PROMISC) {
>  		rxctl |= AX_RX_CTL_PRO;
>  	} else if (net->flags & IFF_ALLMULTI ||

[Severity: Medium]
Can this unlocked read-modify-write of data->rxctl race with other AX_RX_CTL
writers and leave data->rxctl out of sync with hardware?

__dev_set_rx_mode() calls ax88179_set_multicast() in BH context holding only
netif_addr_lock_bh() without RTNL.  Neither ax88179a_resume() ->
ax88179a_reset() (which runs while netif_device_present() stays true) nor
ax88179a_mac_link_up() takes netif_addr_lock_bh():

CPU0                                CPU1
ax88179a_resume()
  ax88179a_reset()
    ax88179_write_u16(..., 0)
                                    __dev_set_rx_mode()
                                      ax88179_set_multicast()
                                        rxctl = READ_ONCE(data->rxctl)
    WRITE_ONCE(ax179_data->rxctl, ...)
    ax88179_write_u16(..., rxctl)
                                        WRITE_ONCE(data->rxctl, rxctl)
                                        ax88179_write_cmd_async(...)
                                          <-- clobbers rxctl / AX_RX_CTL

This allows lost updates to data->rxctl, out-of-order async and synchronous
AX_RX_CTL writes, or re-enabling AX_RX_CTL_START mid-reset or during link-up.

Reading net->features without RTNL also races with __netdev_update_features(),
which calls ndo_set_features() before updating dev->features.

With commit "net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on
AX88179A", a concurrent ax88179_set_multicast() can overwrite
AX_RX_CTL_DROPCRCERR from stale net->features, leaving ax88179a_rx_fixup()
out of sync with hardware FCS stripping.

That follow-up commit does not resolve this race either, as
ax88179_set_multicast() still reads net->features without RTNL, submits its
async write outside rx_ctl_mutex, and ax88179a_reset() remains unlocked.

Consider serializing rxctl updates with a spinlock_bh or deferring RX mode
writes to workqueue context (such as ndo_set_rx_mode_async or
usbnet_defer_kevent()), and avoid recomputing AX_RX_CTL_DROPCRCERR from
net->features outside RTNL.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-fcs-v4-0-32773b612c81@birger-koblitz.de?part=1

  reply	other threads:[~2026-12-05 21:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 21:21 [PATCH net-next v4 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-12-04 21:21 ` [PATCH net-next v4 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
2026-12-05 21:22   ` sashiko-bot [this message]
2026-12-04 21:21 ` [PATCH net-next v4 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-12-05 21:22   ` sashiko-bot

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-251903@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