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=1796372350; b=elrldeAxwyXMC/4IZFYn0jaauvCWJOXkENfq+HJUchVLjm8kADdYLcCcYVs/VO3vP109 GU4cZFluJAy7+oYZopMqA1HELSJthUhzn8+iXSjmG+OuSZkHQ6ItTAUuv82lbmz2lAEaO GG+SZkRE2Kohy8L7PSWGc2Uk1x9X9PKFiBnapkZI6LfVHYwNF7SCrP4mNui72rqvY9lHc 7fBMu2XISK+B48YFMvrsDW2iKssF4bqMltflNRlsagyKj3xOGBK0IXMZT1XOa2qyjaAJK fC4VVO7tgsQXYh6Ur8WcxgNNpuPoy726f7C2mvnR2VE8pU6Qcaxz3TDLE3EEJDU+V6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796372350; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=1I3DwlUhRDF7c50wpE9Ep6/CamPGX+tP3w63g6YiExg=; b=eMo+mnoDaDOM2S/fiQRN29KeyuidztaV5COYreYZrglrkg3h8iyVlrlCjsh52youdnd8 ylBJuT9qcfQ/IAUQPXaOau1RKNzKIQe442O30PyPIOanrmUn07k3qN0CM+eH5Yt5l32qE SuFC+or6aUehSxweNi6Gzo+XJCsugW1rwcff9LWMkMR0NCZVpjB/XW5y5o9WQYaEMLeV+ Q+MkUwgtebvHrsDDLSvhhMpi9jnf8xB7AVoQlrxJDmQnQ7ya85r37Dc1o7uWnGbMP30T2 5he5KCCYDPTe4HzymEjXGFLYUkbXqnjMxDTVGCjHLx2JyKuHBHH+uzg9EB9/thXZupA== 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=FFJzw1bf; 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 210EA606A322; Fri, 4 Dec 2026 08:19:09 +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=FFJzw1bf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CA721F000CE; Fri, 4 Dec 2026 08:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796372349; bh=1I3DwlUhRDF7c50wpE9Ep6/CamPGX+tP3w63g6YiExg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=FFJzw1bfqa5lpsi5fWK0vvkdJKRaroUzwnXVXN96DCofD25lavDX77fQK+dpaYvvp MHKnh5PCS0nG3xXHqGwuZIQZRE+gm2bNiLelThoCwsNLjQZVMJILBrFHcP08tT4lM4 0kdE553j0my5goCOCCOme3+96/mJytJLzK8OMXgpPxiND2QtIxum/eIYRpVuqkWq0O SDweP0fl3myqwRoRaGEme31QtwMmIxFx6mXuvoXcsFUhNbNYVAMuCwMlxB/p44zQkW nfznQ/VvQfjvoj09LCGqNUDqNttqfdanrEXSh1t9CQl988ReVDQvc5D/n1xeVkozWC NrAZ6TJrvEbxA== Subject: Re: [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable From: netdev-bot+sashiko@kernel.org To: mail@birger-koblitz.de Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-usb@vger.kernel.org, benjamin.larsson@genexis.eu Date: Fri, 04 Dec 2026 08:19:08 +0000 Message-ID: <179637234868.3146.1585314112375922296@kernel.org> In-Reply-To: <20261201-fcs-v3-1-6c355917b17e@birger-koblitz.de> References: <20261201-fcs-v3-1-6c355917b17e@birger-koblitz.de> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] ax88179_set_multicast() (drivers/net/usb/ax88179_lib.c:359-365) now picks its starting rxctl… - [Medium] ax88179_set_multicast() now does an unlocked read-modify-write of data->rxctl: READ_ONCE, clear IPE/DROPCRCERR/PRO/AMALL/AM, then… - [Low] For chip_version >= AX_VERSION_AX88179A (AX88179A, AX88772D, AX88279), ax88179_set_multicast()… -- net: usb: ax88179: Make receiving FCS on AX88179A configurable This patch changes ax88179_set_multicast() so that AX_RX_CTL_DROPCRCERR is set on the AX88179A only when NETIF_F_RXFCS or NETIF_F_RXALL is enabled. For chips with chip_version >= AX_VERSION_AX88179A, the rxctl value is now built from the cached data->rxctl, not from a fixed baseline. The behaviour of the older AX88179 is meant to stay the same. > diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c > index 821ee9cd8ded1..353b3a7479308 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); [Severity: Medium] When chip_version >= AX_VERSION_AX88179A, this branch now starts from the cached data->rxctl instead of AX_RX_CTL_START | AX_RX_CTL_AB. It never adds START or AB back. The cache is only initialized by ax88179a_reset(). What happens if this runs on the legacy ax88179_178a.c path? ax88179_bind() zero-allocates the private data: drivers/net/usb/ax88179_178a.c:ax88179_bind() { ... ax179_data = kzalloc_obj(*ax179_data); ... } It then reads chip_version from AX_CHIP_STATUS and does not reject values >= AX_VERSION_AX88179A. The legacy driver_info is picked only by USB VID/PID. That covers the 0b95:1790 vendor-interface catch-all entry and the OEM entries (D-Link, Sitecom, Samsung, Lenovo, Belkin, Toshiba, MCT, Allied Telesis). ax88179_reset() starts RX from a stack buffer and never stores the value in ax179_data->rxctl: *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16); If AX179A-class silicon (chip_version 6 or 7) is bound through this path, would open go like this? __dev_open() dev_set_rx_mode() ax88179_set_multicast() rxctl = 0 & ~(...); /* no START, no AB */ WRITE_ONCE(data->rxctl, rxctl); ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, ...); ax88179_link_reset() would then write the same START-less value back on every link reset: ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &ax179_data->rxctl); Wouldn't that leave the RX engine stopped and broadcast reception off? Before this patch the legacy path always rebuilt the value with START | AB, whatever chip_version said. The second patch in the series does not seem to change this. I could not confirm that any shipping device puts AX179A-class silicon behind one of the legacy table entries. Still, nothing in the code prevents it. [Severity: Low] AX_RX_CTL_AP is not in this mask, so is it intended that AP now stays set on AX179A-family chips? ax88179a_reset() puts it into the cache: rxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; Before this patch, the first ndo_set_rx_mode call rebuilt rxctl from START | AB | DROPCRCERR, which cleared AP. Now AP survives every rx-mode update on the AX88179A, AX88772D and AX88279. The commit message only covers the DROPCRCERR/FCS change. Could it also mention the switch to a read-modify-write of the cached value, and this change to the filter mode? That switch is also what makes this function depend on data->rxctl being initialized, as noted above. > + } 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; [Severity: Medium] This is an unlocked read-modify-write of data->rxctl, and DROPCRCERR is derived from net->features. Can it race with ndo_set_features? Later in this series, the "Support NETIF_F_RXFCS and NETIF_F_RXALL" patch makes ax88179a_set_features() do its own read-modify-write. It calls READ_ONCE() on ax179_data->rxctl, toggles DROPCRCERR, stores the result with WRITE_ONCE() and then does a synchronous AX_RX_CTL write. All of this runs under RTNL only. ndo_set_rx_mode runs under netif_addr_lock and can be reached without RTNL, for example by an unprivileged IPV6_ADD_MEMBERSHIP: ipv6_sock_mc_join() dev_mc_add() __dev_set_rx_mode() ax88179_set_multicast() Also, __netdev_update_features() only updates dev->features after ndo_set_features() returns: err = dev->netdev_ops->ndo_set_features(dev, features); ... dev->features = features; With "ethtool -K ethX rx-all on", the interleaving could be: CPU1 (set_features) CPU2 (ax88179_set_multicast) sets DROPCRCERR in cache and hw sees RXALL still clear clears DROPCRCERR async AX_RX_CTL write lands last dev->features gains RXALL After that, ax88179a_rx_fixup() sets fcs_trailer = ETH_FCS_LEN and subtracts it from pkt_len because RXFCS is off, but the hardware no longer appends the FCS. Wouldn't every received frame then lose 4 bytes of payload until the next rx-mode change? Turning rx-fcs or rx-all off would hit the reverse case and leave a 4-byte trailer on every frame. The two read-modify-write paths can also lose each other's PRO/AM/AMALL updates. ax88179a_mac_link_up() then writes the stale cache back to the hardware. It holds medium_status_mutex, which neither writer takes: ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, READ_ONCE(ax179_data->rxctl)); The second patch in the series fixes the resume case by deriving DROPCRCERR from the features in ax88179a_reset(). It doesn't seem to fix this race, and it adds the second writer. Should these writers share a lock? > if (net->flags & IFF_PROMISC) { > rxctl |= AX_RX_CTL_PRO; > } else if (net->flags & IFF_ALLMULTI || [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-fcs-v3-0-6c355917b17e%40birger-koblitz.de