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=1796024480; b=ZybGFeIUbjDmFLlRNJkfTKTh+IgdGvWlCd1GtmGh0Mpg73RlMl/wuneH5Owj0G0aWgmh Za5+/84yD/WjK+oL9FEHTKeK8nCV805L0G8FhR0LoDiHCslKysEIOr1696pfyKj5QRPMx eCobELpgDFXsOzAVfxEM9EVYn8at0tT/OIxFlmjbkalK70+7mcmue4pk0NWye0uDrJxys LL78R1kVE9cRZy9tjy5wR/2+O8L6okkagoahLsZCU8G69ECSWU868n2MEmeOl02B19FTe K953+5s/ZI1/Z4ha0X+EJLNOdbN3TFcm/2HkUyYsGASSYSHBA6H+EKAycwORwjaXLQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796024480; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=mQkdxEaTsr266/U9CTP8tZt/ZcYNKM5Ai+6Cix7oFJA=; b=0mHh0zFDihEYbA9/mi2k/lwi2s1CW/K96MOnWLBmz2XINwQwUnTMqv9upYg2z0U233Md sN9OofLVtEU8JO5HRsuqgMrKdWDMvyPoHv8fMU7LB2e4pngqBOd6JM5/JYbMmxlt3iXnj w2xV7Stj+uwjZNigFyS0mGrcEDQBqdy488Dxr9FUsyHF3mh88KZ6aUVEQRn497Kvsogdz /SeuImgW9Kujmki3C69Pi1nuwo1qbM7JRPdb+XBJe3LWgE5yIwu8JqINnZiwHvQ7+n0eV 42NO1OV8u6crBX5x1rfTzAgsyxA8l6Q34LFC8ViLMPZdc9QjN7yfKVRlo8qEqwSF/lA== 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=GRdZbCn1; 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 15666606A320 for ; Mon, 30 Nov 2026 07:41:19 +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=GRdZbCn1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFEEF1F00899; Mon, 30 Nov 2026 07:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796024479; bh=mQkdxEaTsr266/U9CTP8tZt/ZcYNKM5Ai+6Cix7oFJA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=GRdZbCn1MNwCR5tSy/5Jjs6WmQ8ACf0zyK7UaSnU/zN//0LCS+8mKDFSTN4CXzvc3 nSSRoB8OP8/occGXmKz9ZTHWQV6W+EnWZw/AlpI/wYvpYcOmFIqJbMXEwKdOsyVBWE DvNYRmN9aTZdHZbROu/GSUuk/XMnF7ESOKk4oEy5Crrliol4d3+PNiso6XuSo7wqkS +NoiQ89lU+Zlx9zkEh05IV+c/aSaxqeS71KnvW/GbchSjLAus4HGQYHPIO86sJ8AOV 82/Ky6sNNYZ0HaFZA5o3CVxeQk6nFG1f8mE5s45TsI6ok2lulnHRql6B8mgTtZKwxC 22j6J1Cs8DMcg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v2 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: <20261129-fcs-v2-2-f60d6b105a15@birger-koblitz.de> References: <20261129-fcs-v2-0-f60d6b105a15@birger-koblitz.de> <20261129-fcs-v2-2-f60d6b105a15@birger-koblitz.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 07:41:18 +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 5 potential issues to consider: - [Medium] net: usb: ax88179: missing fcs_trailer in ax88179a_rx_fixup() min length check - [Medium] net: usb: ax88179: bad-FCS frames skip stats and get CHECKSUM_UNNECESSARY - [Medium] net: usb: ax88179: unsynchronized rxctl updates in ax88179a_set_features() - [Low] net: usb: ax88179: unchecked ax88179_write_u16() in ax88179a_set_features() - [Low] net: usb: ax88179: ax88179a_set_features() starts RX while interface is down -- commit 21d8e6eaf31af5eed7506d49312844c800b253bc 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 devic= es, adjusts packet length handling in ax88179a_rx_fixup() for trailing FCS byte= s, 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..21cf90d69f502 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,18 @@ 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); > + ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); > + } > + > return 0; > } [Severity: Medium] Can this ax179_data->rxctl update race with ax88179_set_multicast() or ax88179a_mac_link_up()? __netdev_update_features() calls ndo_set_features before updating net->features. While ax88179_write_u16() sleeps on the USB control transfer, ax88179_set_multicast() can run under netif_addr_lock_bh() without rtnl_lock and recompute AX_RX_CTL_DROPCRCERR from the old net->features value: 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, ...) ax88179_set_multicast() rxctl &=3D ~AX_RX_CTL_DROPCRCERR if (net->features & ...) /* still false */ WRITE_ONCE(data->rxctl, rxctl) ax88179_write_cmd_async(...) net->features =3D features; <-- AX_RX_CTL_DROPCRCERR lost That leaves hardware FCS appending disabled while net->features has NETIF_F_RXFCS or NETIF_F_RXALL set. ax88179a_mac_link_up() also runs in the phylink workqueue without rtnl_lock, writes AX_RX_CTL_STOP while configuring the link, and restores AX_RX_CTL from ax179_data->rxctl under medium_status_mutex, so an unserialized write here can re-enable AX_RX_CTL_START in the middle of link setup. [Severity: Low] Should this check and return the error from ax88179_write_u16()? If the control transfer fails, returning 0 lets the netdev core commit the new feature flags to net->features while AX_RX_CTL in hardware keeps the old AX_RX_CTL_DROPCRCERR state, so ax88179a_rx_fixup() misinterprets whether received packets carry a 4-byte FCS trailer. [Severity: Low] Can this re-enable hardware reception while the interface is down? ax88179a_stop() writes 0 to AX_RX_CTL in hardware without clearing AX_RX_CTL_START in ax179_data->rxctl, so toggling rx-fcs or rx-all while the interface is stopped writes AX_RX_CTL_START back to AX_RX_CTL. [ ... ] > @@ -1039,9 +1058,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 +1074,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) { > 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; > @@ -1063,6 +1096,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] Should the minimum length check also account for fcs_trailer? When NETIF_F_RXALL is enabled and NETIF_F_RXFCS is disabled, a 16- or 17-byte runt frame (including the 4-byte FCS trailer) passes pkt_len < 2 + ETH_HLEN and then has fcs_trailer subtracted, leaving pkt_len at 12 or 13 bytes (< ETH_HLEN). usbnet_skb_return() then calls eth_type_trans(), where eth_skb_pull_mac() fails to pull ETH_HLEN bytes and eth_type_trans() reads eth->h_proto past skb_tail_pointer(ax_skb) from uninitialized skb memory. [Severity: Medium] When NETIF_F_RXALL is enabled, does a frame with !(pkt_desc & AX179A_RX_PD_RX_OK) skip rx_crc_errors accounting and still get passed to ax88179a_rx_checksum()? Because the error counters are inside the discard branch, bad-FCS frames received under NETIF_F_RXALL are not counted in rx_crc_errors or rx_errors. They then reach ax88179a_rx_checksum(), which only checks AX179A_RX_PD_L4_ERR and AX179A_RX_PD_L3_ERR and can mark a frame that failed L2 CRC verification as CHECKSUM_UNNECESSARY. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129-fcs-v2-0-f= 60d6b105a15@birger-koblitz.de?part=3D2