From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796505734; b=lXI5X3KP9K7Y6tgFkNZSEUdJp9WaG0hJl6LRcJl20m+Bu2DUei/vmD64m3A4QypiUrJH mGjKtpVELEkY2zAiD0xdcv8iJhTNdF0qcPlsa+L5O1tG49q4i+AvfAXQYtHV1UOfZtgt3 8JQrC9wAUVd4XScPePkhIvwMTBI8+sNicm6G0fcbmoo1A4dbvfZaVhRw8dqUBUYbWMsaX 5XUYDpLzE8jIs4kGJdVYDVJBTEY/Ps5hicwIGr0b2JEwyWnC67Ymfi3p+uEHNPfYopRsQ nmB0VjYMHA4L2KRNzeusl16EKc9nr7narup66AKWJVSebwcgkVfqRDMe2F7ecxxqK0g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796505734; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=lfYW6OZFW17KNO/9hIklVNEUkL6IJlrwbgQnm6A28pA=; b=v4hVar48BOGZtM0cZ4FElzG8dD4JOojmDNcXAs8ipdAySk2p5GS1dfeucRGwzc28EJ+G XxGlSOeNj+qFWfbVWmIj9YNDYDwjyCT+C+kXmGo0tZM+fvQDcH8uojpys/jxUQDRRVSau up1rxwLqZ3+dk0RZugBxEUA1ssn0/yDGP4jkbdXgrxaMhOLpJkCsEBcnLYRsHzmmRyYgI JI7hTNdY9XAqg6945swml/gufSykf4wXjt2Oh/IQsm7qDeLbblVHyiENrgWdldDTU1YWW O5l2y4AUCi9ASsIz01zzacYNWBaLazFS2JkMOabK3FriSHEiHDU6Tic8R9JT1TQhY4w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BC4QMyLo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3971E606A333 for ; Sat, 5 Dec 2026 21:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BC4QMyLo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0133D1F0092B; Sat, 5 Dec 2026 21:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796505734; bh=lfYW6OZFW17KNO/9hIklVNEUkL6IJlrwbgQnm6A28pA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=BC4QMyLoo06KfUCvdhlOTmOU8B5GmeYWKWBjGM0h9dPGS+1o1Xk0XCYdgOD51JVTJ o5hnbFtUMf2Gx3yzWr+32xtysx8e/n1r6Ms7a85frLJFn+5nkhFC2Rv1UUIZTCfvRz jZU08QRVjJc6f/9gZhNw/zRDBky72JibJUjDu28GG1tQj7M0vQV1RKViATveypYTJQ ZRGxZI70lmKJUoussiA2yHXyRJACoKxKdjXZZuK4D1KiQcMvL//e+MV54SjjRbSwwq QizbE8L2EsAJiXwlsYO5UJeNpYFbgt31TuquIjID5GpO1k9w4zjCniHwhq5AFPqCnZ gdrsA505XuDVw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v4 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Reply-To: sashiko-reviews@lists.linux.dev To: "Birger Koblitz" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261204-fcs-v4-2-32773b612c81@birger-koblitz.de> References: <20261204-fcs-v4-0-32773b612c81@birger-koblitz.de> <20261204-fcs-v4-2-32773b612c81@birger-koblitz.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 21:22:13 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 11 potential issues to consider: - [High] net: usb: ax88179: missing mutex_init() for rx_ctl_mutex in bind paths - [High] net: usb: ax88179: sleeping mutex_lock() in atomic ax88179_set_multicast() - [Medium] net: usb: ax88179: out-of-order async AX_RX_CTL writes in set_multicast() - [Medium] net: usb: ax88179: stale net->features read reverts AX_RX_CTL_DROPCRCERR - [Medium] net: usb: ax88179: unlocked AX_RX_CTL updates in reset() and mac_link_up() - [Medium] net: usb: ax88179: cached rxctl updated before USB write check succeeds - [Medium] net: usb: ax88179: live RXFCS/RXALL toggle races with ax88179a_rx_fixup() - [Medium] net: usb: ax88179: incomplete RX error/drop stats in ax88179a_rx_fixup() - [Medium] net: usb: ax88179: ax88179a_rx_checksum() skips RX_OK/DROP check on RXALL - [Low] net: usb: ax88179: ax88179a_set_features() writes AX_RX_CTL_START when down - [Low] net: usb: ax88179: inappropriate Fixes trailer and incomplete changelog -- commit 5e000501a479ed67d43879d36a716e17523931f9 Author: Birger Koblitz > net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A > > Add NETIF_F_RXFCS and NETIF_F_RXALL features for > the AX88179A and take a trailing FCS into account for MTU > verification when checking packet length in rx_fixup(). > > Count dropped packets and those with incorrect FCS. > > Fixes: 7d573278f9a5 ("ax88179_178a: Add HW support for AX179A-based chips= ") > Suggested-by: Benjamin Larsson > Signed-off-by: Birger Koblitz [Severity: Low] Should this commit drop the Fixes: trailer? It adds new user-visible features (NETIF_F_RXFCS and NETIF_F_RXALL) and depends on commit "net: usb: ax88179: Make receiving FCS on AX88179A configurable", so carrying Fixes: queues a non-standalone feature commit for automated -stable backporting. Restoring AX_RX_CTL_DROPCRCERR for AX88279 in ax88179a_reset() fixes a bisection regression from commit "net: usb: ax88179: Make receiving FCS on AX88179A configurable" and belongs in that patch instead. Also, the commit message does not mention adding rx_ctl_mutex or the ax88179a_reset() change. > diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c > index 273c5946e16a1..dc32660a23359 100644 > --- a/drivers/net/usb/ax88179_lib.c > +++ b/drivers/net/usb/ax88179_lib.c > @@ -356,6 +356,7 @@ void ax88179_set_multicast(struct net_device *net) > =20 > data =3D dev->driver_priv; > =20 > + mutex_lock(&data->rx_ctl_mutex); > if (data->chip_version >=3D AX_VERSION_AX88179A) { > rxctl =3D READ_ONCE(data->rxctl); > rxctl &=3D ~(AX_RX_CTL_IPE | AX_RX_CTL_DROPCRCERR | AX_RX_CTL_PRO | [Severity: High] Can ax88179_set_multicast() sleep here? It is registered as ndo_set_rx_mode, which the networking core invokes via dev_set_rx_mode() under netif_addr_lock_bh() with a spinlock held and softirqs disabled. Because ax88179a_set_features() and ax88179a_mac_link_up() hold rx_ctl_mutex across blocking USB control transfers, acquiring it here trips sleeping-in-atomic checks and can panic or self-deadlock on contention. [Severity: Medium] Can clearing AX_RX_CTL_DROPCRCERR and recomputing it from net->features here revert a concurrent feature update? CPU0 CPU1 __netdev_update_features() ax88179a_set_features() rxctl |=3D AX_RX_CTL_DROPCRCERR ax88179_write_u16(..., rxctl) mutex_unlock(&rx_ctl_mutex) __dev_mc_add() (no rtnl_lock) ax88179_set_multicast() reads stale net->features clears AX_RX_CTL_DROPCRCERR writes stale rxctl to hw dev->features =3D features <-- hw and dev->features diverge Once dev->features and hardware AX_RX_CTL_DROPCRCERR disagree, ax88179a_rx_fixup() either truncates 4 payload bytes per frame or leaves 4 FCS bytes attached and drops full-MTU frames. Preserving AX_RX_CTL_DROPCRCERR in data->rxctl instead of recomputing it from net->features avoids this race. [ ... ] > @@ -397,8 +398,9 @@ void ax88179_set_multicast(struct net_device *net) > } > =20 > WRITE_ONCE(data->rxctl, rxctl); > + mutex_unlock(&data->rx_ctl_mutex); > ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, > - 2, 2, &data->rxctl); > + 2, 2, &rxctl); > } [Severity: Medium] Can this asynchronous AX_RX_CTL write land after a newer synchronous write from ax88179a_set_features()? CPU0 CPU1 ax88179_set_multicast() WRITE_ONCE(data->rxctl, old) mutex_unlock(&rx_ctl_mutex) ax88179a_set_features() mutex_lock(&rx_ctl_mutex) WRITE_ONCE(data->rxctl, new) ax88179_write_u16(..., new) mutex_unlock(&rx_ctl_mutex) ax88179_write_cmd_async(..., old) <-- overwrites hw with stale rxctl If the older async URB executes on EP0 after the synchronous write, hardware AX_RX_CTL_DROPCRCERR disagrees with dev->net->features, causing ax88179a_rx_fixup() to miscalculate FCS length on subsequent frames. > diff --git a/drivers/net/usb/ax88179_lib.h b/drivers/net/usb/ax88179_lib.h > index 401c0bed3d28b..a9e688424c129 100644 > --- a/drivers/net/usb/ax88179_lib.h > +++ b/drivers/net/usb/ax88179_lib.h > @@ -292,6 +292,7 @@ enum ax_chip_version { > =20 > struct ax88179_data { > struct mutex medium_status_mutex; /* protect AX_MEDIUM_STATUS_MODE */ > + struct mutex rx_ctl_mutex; /* protect AX_RX_CTL */ > u8 eee_enabled; > u8 eee_active; > u16 rxctl; [Severity: High] Is rx_ctl_mutex ever initialized? Both ax88179a_bind() and ax88179_bind() allocate ax88179_data with kzalloc_obj() and call mutex_init() on medium_status_mutex, but neither calls mutex_init(&ax179_data->rx_ctl_mutex). Locking a zero-filled mutex on interface bring-up violates the mutex API, tripping lockdep and mutex/spinlock debug checks and risking corruption or lockup on CONFIG_PREEMPT_RT. > diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179= a_devices.c > index 78a804203202f..9137f790ddaa6 100644 > --- a/drivers/net/usb/ax88179a_devices.c > +++ b/drivers/net/usb/ax88179a_devices.c [ ... ] > @@ -780,6 +784,24 @@ static int ax88179a_set_features(struct net_device *= net, netdev_features_t featu > if (ret < 0) > return ret; > } > + > + if (changed & (NETIF_F_RXFCS | NETIF_F_RXALL)) { > + u16 rxctl; > + > + mutex_lock(&ax179_data->rx_ctl_mutex); > + rxctl =3D READ_ONCE(ax179_data->rxctl); > + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) > + rxctl |=3D AX_RX_CTL_DROPCRCERR; > + else > + rxctl &=3D ~AX_RX_CTL_DROPCRCERR; > + WRITE_ONCE(ax179_data->rxctl, rxctl); > + ret =3D ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); > + mutex_unlock(&ax179_data->rx_ctl_mutex); > + > + if (ret < 0) > + return ret; > + } > + > return 0; > } [Severity: Medium] Should ax179_data->rxctl only be updated after ax88179_write_u16() succeeds? If the USB write fails, __netdev_update_features() keeps dev->features at the old value while ax179_data->rxctl retains the new AX_RX_CTL_DROPCRCERR bit, which the next ax88179a_mac_link_up() then programs into hardware out of sync with dev->features. [Severity: Low] Does this write AX_RX_CTL_START back to hardware when the interface is down? ax88179a_stop() clears hardware AX_RX_CTL to 0 without clearing AX_RX_CTL_START in ax179_data->rxctl, and ax88179a_set_features() does not check netif_running(net) before writing AX_RX_CTL. [ ... ] > @@ -1050,10 +1080,19 @@ static int ax88179a_rx_fixup(struct usbnet *dev, = struct sk_buff *skb) > if (pkt_end > hdr_off || (pkt_cnt =3D=3D 0 && pkt_end !=3D hdr_off)) > goto err; > =20 > - if (pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK) || > - pkt_len > (dev->hard_mtu + AX179A_RX_HW_PAD) || pkt_len < 2 + ETH_= HLEN) { > + if (((pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK)= ) && > + !(features & NETIF_F_RXALL)) || > + pkt_len > dev->hard_mtu + AX179A_RX_HW_PAD + fcs_trailer || > + pkt_len < 2 + ETH_HLEN + fcs_trailer) { > skb_pull(skb, pkt_len_plus_padd); > =20 > + if (pkt_desc & AX179A_RX_PD_DROP) > + dev->net->stats.rx_dropped++; > + > + if (!(pkt_desc & AX179A_RX_PD_RX_OK)) { > + dev->net->stats.rx_crc_errors++; > + dev->net->stats.rx_errors++; > + } > /* Next RX Packet Descriptor */ > pkt_desc_ptr++; > continue; [Severity: Medium] Does placing the error counters inside the discard block break RX accounting when NETIF_F_RXALL is enabled? Valid-length frames with !(pkt_desc & AX179A_RX_PD_RX_OK) bypass this block completely and stop incrementing rx_crc_errors and rx_errors. In addition, frames with AX179A_RX_PD_RX_OK set and AX179A_RX_PD_DROP clear that fail the oversize or runt length checks are dropped without incrementing rx_length_errors, rx_errors, or rx_dropped, and usbnet's rx_process() does not count them because ax88179a_rx_fixup() returns 1. It is also unclear whether !AX179A_RX_PD_RX_OK exclusively indicates CRC errors rather than other receive errors. [Severity: Medium] Can L2-errored frames admitted under NETIF_F_RXALL be falsely marked CHECKSUM_UNNECESSARY? When NETIF_F_RXALL and NETIF_F_RXCSUM are both enabled, frames with AX179A_RX_PD_DROP set or AX179A_RX_PD_RX_OK clear now reach ax88179a_rx_checksum(), which only checks negative error bits (AX179A_RX_PD_L3_ERR and AX179A_RX_PD_L4_ERR) without a positive checksum-verified flag. If the hardware skips L3/L4 checksum validation on failed L2 frames, the stack will skip software verification on corrupted TCP/UDP payloads. Gating ax88179a_rx_checksum() on (pkt_desc & AX179A_RX_PD_RX_OK) && !(pkt_desc & AX179A_RX_PD_DROP) avoids this. > @@ -1063,6 +1102,9 @@ static int ax88179a_rx_fixup(struct usbnet *dev, st= ruct sk_buff *skb) > if (!ax_skb) > goto err; > =20 > + if (!(features & NETIF_F_RXFCS)) > + pkt_len -=3D fcs_trailer; > + > skb_put(ax_skb, pkt_len); > memcpy(ax_skb->data, skb->data + (ax179_data->ip_align ? AX179A_RX_HW_= PAD : 0), > pkt_len); [Severity: Medium] Can toggling NETIF_F_RXFCS or NETIF_F_RXALL on a live interface corrupt in-flight frames in ax88179a_rx_fixup()? CPU0 CPU1 __netdev_update_features() ax88179a_set_features() clears AX_RX_CTL_DROPCRCERR (hw stops appending FCS) usbnet_bh() -> ax88179a_rx_fixup() reads old dev->net->features fcs_trailer =3D ETH_FCS_LEN pkt_len -=3D fcs_trailer <-- truncat= es dev->features =3D features payload Because ax88179a_set_features() changes AX_RX_CTL live without draining in-flight RX URBs and __netdev_update_features() updates dev->features only after ndo_set_features() returns, frames captured across the transition either lose 4 bytes of payload or keep 4 trailing FCS bytes (and full-MTU frames get dropped as oversized). [ ... ] > @@ -1221,6 +1263,9 @@ static int ax88179a_reset(struct usbnet *dev) > rxctl |=3D AX_RX_CTL_IPE; > if (dev->net->flags & IFF_PROMISC) > rxctl |=3D AX_RX_CTL_PRO; > + if (dev->net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) || > + ax179_data->chip_version =3D=3D AX_VERSION_AX88279) > + rxctl |=3D AX_RX_CTL_DROPCRCERR; > WRITE_ONCE(ax179_data->rxctl, rxctl); > ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); [Severity: Medium] Should ax88179a_reset() hold rx_ctl_mutex around updating ax179_data->rxctl and writing AX_RX_CTL? ax88179a_resume() calls ax88179a_reset() before taking rtnl_lock(), so a concurrent ax88179a_set_features() or ax88179_set_multicast() can race and lose AX_RX_CTL updates. Similarly, ax88179a_mac_link_up() writes AX_RX_CTL_STOP without holding rx_ctl_mutex across link reconfiguration, allowing a concurrent ax88179a_set_features() to write AX_RX_CTL_START back to hardware while MAC and bulk-in registers are still being reprogrammed. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-fcs-v4-0-3= 2773b612c81@birger-koblitz.de?part=3D2