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=1796231862; b=lVC3/btes1+Xnc6ymkhYteVQp9F/vGkbHbuD9VFtVI1gpaHQVNHQJja7mj4maE1fRAg1 cc34cZveY/kBwlGAaiH6dvvm0weII9ALlzZ+Jw+eju/bCEfhD9VN0xvf5KcM9QfdCFkIW R0E5y7PFt5LxPkxf8EC8/VcGnQxwm0bBzscIszERnGYG83ZVyi7px2dxipB3M/HSH8Tlg k1LOw5dLHBaYNunVxEnuyd+kJd/AQuEEbf+d6+A58rtRWD6xI37eESK2XLLjtikKJjUIj 9YWpySsBCPGiC3LtBlW2oBUgbwZzjZdGw1flYyqLrCPpI89D/MitNkWl15ttfvMiN4Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796231862; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=uJld7NEgtQN3MROYBRmlMNzpHKzUc16ecnYNAcfTtB0=; b=uuqiulcH6nyxYWnthmJzWEGz6GOaT1KzqyV5EvgSNRtWhOcDybwoJPYO2+y3e8jgO5uW /nFhV5T0nZXQZ1umv1LEehGiEPrPq4HdhNny9YMNHmMkUpYMVpaa1PolrejUcpisDq1zq Nvtv8NBvhSOtJQbRW3LqM1HKMaCRu7VjazT3Jiq1H0CCzE0gLFcD76HCKAoREXhimxXOo lcvxCka5s8i+EhUHACMKiYIb01CNkhNvY/3TO2tzQEMaB9ramkQzqHyLzgP0sqMUegBPT +R75IXdetUEyh4bB0f/+EzcF1aDYVHo8dbqkbMnzYkgM2Tw5OErGR6UDnhcHH270LYg== 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=GHHa3GNH; 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 CFCAE606A325 for ; Wed, 2 Dec 2026 17:17:42 +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=GHHa3GNH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 886131F00893; Wed, 2 Dec 2026 17:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796231862; bh=uJld7NEgtQN3MROYBRmlMNzpHKzUc16ecnYNAcfTtB0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=GHHa3GNHUfND1MY/3UCyS1/WhMG9ZwX0+V9DbNnXiHQukg6aMc+hnOfV3WPcq56BK DSNjwaBtDtcjDFghN/cYmSzeYPXeKsnPmIqXJ+8HdW7lFUugpoVG79A8v7o2EVToRb sylevzmqKqRQr/ABtJdlGQPEiZT65Gqdq+aX0OdUNETZXak12d9IUCrGnMEcnMmMkV wJMpsh2u4xz3ma2DajTTL1y7dlmlJZvOGcIKnIG4oDWy0bGQOID2g8sv5EDHu+k/Kr luDzeWcSl39MfbXKwLUFjVxayCL97hvYf/7nJAOMQ5bwr/d7IVTzV1/ivbxk7XL/UP SmkcMy2kluprg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v3 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: <20261201-fcs-v3-2-6c355917b17e@birger-koblitz.de> References: <20261201-fcs-v3-0-6c355917b17e@birger-koblitz.de> <20261201-fcs-v3-2-6c355917b17e@birger-koblitz.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 17:17:42 +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 4 potential issues to consider: - [Medium] net: usb: ax88179: unsynchronized rxctl update in ax88179a_set_features() - [Medium] net: usb: ax88179: FCS stripping race on features in ax88179a_rx_fixup() - [Medium] net: usb: ax88179: bad-FCS frames skip stats and checksum check on RXALL - [Low] net: usb: ax88179: ax88179a_set_features() enables RX while stopped -- commit 38bd5184999fcc79ca797c6f439fd670ad6ab639 Author: Birger Koblitz net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A This commit adds NETIF_F_RXFCS and NETIF_F_RXALL support for AX88179A chips, adjusts RX length validation and FCS stripping in ax88179a_rx_fixup(), and updates RX drop and CRC error counters. > diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179= a_devices.c > index 69095110e7043..04d8f37bc7ebe 100644 > --- a/drivers/net/usb/ax88179a_devices.c > +++ b/drivers/net/usb/ax88179a_devices.c > @@ -717,10 +717,12 @@ static int ax88179a_mii_ioctl(struct net_device *ne= t, struct ifreq *rq, int cmd) > static int ax88179a_set_features(struct net_device *net, netdev_features= _t features) > { > struct usbnet *dev =3D netdev_priv(net); > + struct ax88179_data *ax179_data; > netdev_features_t changed; > int ret; > u8 tmp; > =20 > + ax179_data =3D dev->driver_priv; > changed =3D net->features ^ features; > =20 > ret =3D ax88179_set_features(net, features); > @@ -780,6 +782,20 @@ 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 =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); > + if (ret < 0) > + return ret; > + } > + > return 0; > } [Severity: Medium] Can this unlocked update to ax179_data->rxctl and AX_RX_CTL race with ax88179_set_multicast()? __netdev_update_features() invokes ndo_set_features before updating net->features, while ax88179_set_multicast() runs in BH context under netif_addr_lock_bh(net) without rtnl_lock and recomputes AX_RX_CTL_DROPCRCERR from net->features: drivers/net/usb/ax88179_lib.c:ax88179_set_multicast() { ... 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 | AX_RX_CTL_AMALL | AX_RX_CTL_AM); } else { rxctl =3D (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR); } if (data->ip_align) rxctl |=3D AX_RX_CTL_IPE; if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) || data->chip_version !=3D AX_VERSION_AX88179A) rxctl |=3D AX_RX_CTL_DROPCRCERR; ... WRITE_ONCE(data->rxctl, rxctl); ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &data->rxctl); } When ax88179_set_multicast() runs while ax88179a_set_features() is blocked in ax88179_write_u16(), it reads the old net->features value and overwrites both data->rxctl and AX_RX_CTL: CPU0 CPU1 () __netdev_update_features() ax88179a_set_features() rxctl |=3D AX_RX_CTL_DROPCRCERR WRITE_ONCE(ax179_data->rxctl, ...) ax88179_write_u16(..., AX_RX_CTL, ...) dev_mc_add() __dev_set_rx_mode() ax88179_set_multicast() /* net->features still old */ rxctl &=3D ~AX_RX_CTL_DROPCRCERR WRITE_ONCE(data->rxctl, rxctl) ax88179_write_cmd_async(...) <-- reverts DROPCRCERR net->features =3D features Once AX_RX_CTL_DROPCRCERR in hardware disagrees with dev->net->features, ax88179a_rx_fixup() either strips 4 bytes of valid packet payload (when NETIF_F_RXALL is enabled without NETIF_F_RXFCS) or leaves 4 bytes of FCS attached and drops full-MTU packets. Conversely, if ax88179_set_multicast() updates AX_RX_CTL_PRO, AX_RX_CTL_AMALL, or AX_RX_CTL_AM between READ_ONCE() and WRITE_ONCE() in ax88179a_set_features(), those filter changes are lost. Also, WRITE_ONCE(ax179_data->rxctl, rxctl) happens before checking whether ax88179_write_u16() succeeded; if the USB control transfer fails, __netdev_update_features() keeps the old net->features while ax179_data->rxctl retains the new bit and is later written to hardware by ax88179a_mac_link_up(). [Severity: Low] Does toggling NETIF_F_RXFCS or NETIF_F_RXALL while the interface is down or mid-link-up re-enable RX in hardware? ax88179a_reset() sets AX_RX_CTL_START in ax179_data->rxctl, and ax88179a_stop() writes 0 to AX_RX_CTL without clearing AX_RX_CTL_START in ax179_data->rxctl. Similarly, ax88179a_mac_link_up() writes AX_RX_CTL_STOP to AX_RX_CTL while reconfiguring link registers before restoring ax179_data->rxctl under medium_status_mutex. Because ax88179a_set_features() unconditionally writes ax179_data->rxctl to AX_RX_CTL without checking netif_running(net) or synchronizing with ax88179a_mac_link_up(), changing rx-fcs or rx-all re-asserts AX_RX_CTL_START while the interface is stopped or while link registers are being reconfigured. [ ... ] > @@ -1039,9 +1060,14 @@ static int ax88179a_rx_fixup(struct usbnet *dev, s= truct sk_buff *skb) > pkt_end =3D 0; > while (pkt_cnt--) { > u64 pkt_desc =3D get_unaligned_le64(pkt_desc_ptr); > + netdev_features_t features =3D dev->net->features; > u32 pkt_len_plus_padd; > + u32 fcs_trailer =3D 0; > u32 pkt_len; > =20 > + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) > + fcs_trailer =3D ETH_FCS_LEN; > + > pkt_len =3D FIELD_GET(AX179A_RX_PD_LEN, pkt_desc); > pkt_len -=3D (ax179_data->ip_align ? 2 : 0); > pkt_len_plus_padd =3D ((pkt_len + 7 + (ax179_data->ip_align ? 2 : 0)) = & 0x7FFF8); > @@ -1050,10 +1076,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] When NETIF_F_RXALL is enabled, frames with !(pkt_desc & AX179A_RX_PD_RX_OK) or (pkt_desc & AX179A_RX_PD_DROP) bypass this discard block and reach ax88179a_rx_checksum(). Can those corrupted frames be marked CHECKSUM_UNNECESSARY and skip error accounting? drivers/net/usb/ax88179a_devices.c:ax88179a_rx_checksum() { ... skb->ip_summed =3D CHECKSUM_NONE; /* checksum error bit is set */ if (pkt_desc & AX179A_RX_PD_L4_ERR || pkt_desc & AX179A_RX_PD_L3_ERR) return; pkt_type =3D pkt_desc & AX179A_RX_PD_L4_TYPE_MASK; /* It must be a TCP or UDP packet with a valid checksum */ if (pkt_type =3D=3D AX179A_RX_PD_L4_TCP || pkt_type =3D=3D AX179A_RX_PD_L4= _UDP) skb->ip_summed =3D CHECKSUM_UNNECESSARY; } Because ax88179a_rx_checksum() only checks AX179A_RX_PD_L4_ERR and AX179A_RX_PD_L3_ERR, a TCP or UDP packet with an L2 CRC error accepted via NETIF_F_RXALL can have skb->ip_summed set to CHECKSUM_UNNECESSARY. Bypassi= ng the discard block also means rx_crc_errors and rx_errors are never incremented for bad-FCS packets when NETIF_F_RXALL is active. In addition, if a frame has AX179A_RX_PD_RX_OK set and AX179A_RX_PD_DROP clear but fails the pkt_len bounds checks, it enters the discard block and is dropped without incrementing any error or drop counter. > =20 > ax_skb =3D netdev_alloc_skb_ip_align(dev->net, pkt_len); > 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 reading dev->net->features in ax88179a_rx_fixup() truncate 4 bytes of payload from in-flight RX URBs when NETIF_F_RXALL is toggled on a live interface? Whether a frame in an RX URB carries a 4-byte FCS depends on whether AX_RX_CTL_DROPCRCERR was set in hardware when the frame was received, not on dev->net->features when the URB is later processed in BH context: CPU0 CPU1 () /* URB queued in dev->done without FCS */ __netdev_update_features() ax88179a_set_features() /* enables AX_RX_CTL_DROPCRCERR */ net->features |=3D NETIF_F_RXALL usbnet_bh() ax88179a_rx_fixup() fcs_trailer =3D ETH_FCS_LEN pkt_len -=3D fcs_trailer <-- strips 4B of payload Conversely, during the window after ax88179a_set_features() writes AX_RX_CTL and before __netdev_update_features() updates dev->net->features (or for in-flight URBs when disabling NETIF_F_RXALL or NETIF_F_RXFCS), frames captured with an appended FCS are processed with fcs_trailer =3D=3D = 0, leaving the 4-byte FCS attached and dropping full-MTU frames as oversized. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-fcs-v3-0-6= c355917b17e@birger-koblitz.de?part=3D2