Article View: linux.kernel.netdev
Article #20366Re: [PATCH net v8 1/2] net: wangxun: protect ring accesses with RCU
From: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 08:33
Date: Sun, 22 Nov 2026 08:33
125 lines
12984 bytes
12984 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
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).
- [High] The commit message describes VF suspend/resume changes that are
not in the patch, and relies on them to argue that the new __rcu /…
--
net: wangxun: protect ring accesses with RCU
This commit marks wx->tx_ring[] and wx->rx_ring[] as __rcu. Readers are
converted to rcu_dereference() or rtnl_dereference(). The reg_idx
computation moves into per-ring allocation via wx_get_reg_idx(), and
wx_xmit_frame() gains checks for a NULL ring or zero queue count during
teardown.
> The ring arrays are managed by wx_alloc_q_vector() and
> wx_free_q_vector(), reached through wx_init_interrupt_scheme() and
> wx_clear_interrupt_scheme(). The probe paths call
> wx_init_interrupt_scheme() before the netdev is registered; the
> allocation path only publishes rings with rcu_assign_pointer(), so no
> RTNL is needed there. wxvf_resume() defers rebuilding the interrupt
> scheme to wxvf_reopen_subtask(), which runs under RTNL. wxvf_suspend()
> holds RTNL across wxvf_close() and wx_clear_interrupt_scheme(),
> protecting control-path readers and serializing teardown against the
> reset subtask. The service timer and work are drained before the PCI
> device is disabled.
[Severity: High]
Is a VF hunk missing from this patch, or does this paragraph describe a
different revision?
The only change to wx_vf_common.c here is the rtnl_dereference()
conversion in wx_configure_rx_vf(). wxvf_reopen_subtask() does not exist
anywhere under drivers/net/ethernet/wangxun/. After this patch,
wxvf_suspend() (which wxvf_shutdown() also calls) and wxvf_resume() still
read:
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c:wxvf_suspend() {
netif_device_detach(wx->netdev);
wx_clear_interrupt_scheme(wx);
pci_disable_device(pdev);
}
drivers/net/ethernet/wangxun/libwx/wx_vf_common.c:wxvf_resume() {
pci_set_master(pdev);
wx_init_interrupt_scheme(wx);
netif_device_attach(wx->netdev);
}
So wxvf_suspend() takes no RTNL and does not call wxvf_close() on a
running interface. It also does not set WX_STATE_DOWN and does not cancel
service_timer or service_task.
The new comment in struct wx says:
Control-path readers use rtnl_dereference() while holding RTNL.
That only works if the writers in wx_free_q_vector() also hold RTNL. On
this path, wx_free_q_vectors() zeroes the queue counts, NULLs each slot,
and calls kfree_rcu() on the q_vector that embeds the rings, all without
RTNL.
Can the service task race with this? Suspend leaves the timer armed and
WX_STATE_DOWN clear, so the check in wxvf_reset_subtask() still passes:
wxvf_service_task()
wxvf_reset_subtask()
rtnl_lock()
wxvf_reinit_locked()
wxvf_down()
wx_clean_all_tx_rings()
wx_clean_all_rx_rings()
wx_configure_vf()
wx_configure_tx_vf()
wx_configure_rx_vf()
wx_set_ringparam_vf() is another example:
rtnl_dereference(wx->tx_ring[i])->count = new_tx_count;
None of these readers check for NULL or run inside an RCU read-side
section, and some of them sleep, e.g. read_poll_timeout(). Could they
dereference a NULL ring, or use a ring after its kfree_rcu() grace period
has ended?
On resume, wx_init_interrupt_scheme() publishes new zeroed rings with
tx_buffer_info == NULL and desc == NULL, and sets WX_STATE_DOWN. Nothing
reopens the device after that. netif_device_attach() then wakes the TX
queues of a netdev that is still running, and its carrier was never
turned off.
The new checks in wx_xmit_frame() pass, because num_tx_queues is non-zero
and the ring is non-NULL. Does wx_xmit_frame_ring() then dereference a
NULL tx_buffer_info here?
first = &tx_ring->tx_buffer_info[tx_ring->next_to_use];
first->skb = skb;
Because suspend skips wxvf_close(), the queue and misc IRQs are not freed
before pci_free_irq_vectors(). NAPI instances that are still enabled are
passed to netif_napi_del(). The descriptor DMA memory, the buffer_info
arrays and the page_pool are reachable only through the rings freed by
kfree_rcu(). Do these leak on every suspend or shutdown with the
interface up?
Much of this VF lifecycle behaviour predates the patch. However, the
commit message depends on the RTNL, close, drain and reopen changes to
justify the rtnl_dereference() locking model, and those changes are not
in the patch. Could the missing VF changes be included, or could the
commit message and the struct wx comment be corrected to match the
locking the code actually has?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118081329.39551-1-mengyuanlou%40net-swift.com
Technical Details
Message-ID:
<179533642599.3135.8576432289828139956@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368610-linux-kernel-netdev=dewy.ruReferences:
<20261118081329.39551-2-mengyuanlou@net-swift.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368610-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v8 1/2] net: wangxun: protect ring accesses with RCU Date: Sun, 22 Nov 2026 08:33:45 +0000 Organization: Usenet Network Message-ID: <179533642599.3135.8576432289828139956@kernel.org> References: <20261118081329.39551-2-mengyuanlou@net-swift.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3599264"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:EUNJXUEAh1/x/K5FNkPOdahhhvw= sha256:mJjPH5Krvup/b94I+7LzL9rMs+/Nh6vN1Axfirn81YM= sha1:yA4zPLTCfGugTk/vYHiAgps9L8k= sha256:c9EgTtmIlveleptRgfimN73UhrXRrfUabWIwsPrwgL0= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 46406125D6E; Sun, 22 Nov 2026 11:34:04 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fb3CobwP4FxG; Sun, 22 Nov 2026 11:34:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368610-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 45444125D6F; Sun, 22 Nov 2026 11:33:50 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 56B1D2BA53; Sun, 22 Nov 2026 08:33:48 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795336428; b=W6iEBkhCHRQ96R0Xxvk3uNytvnc+GJp8Jjjc70fEvIkoZSs1QGpvyuWzOQtPkx/KbCmz nVXcF/KeJv93j63Ws3HWwqEuUElKmQfJx2povjUlq9+2vXsTQqoNy8/sj++R7G328gPBA jhCvboDEjjFPQJp/PbngNcjSAUTmwFsWvgPknkZa6qWonUTRAlMu3kzTpSe5iOXdLgGN0 aeYMyREf52dLGdAoC9CKfhPDB4ky4iqQFA7D9yUSCXwn7gbzEEJik1eC+sEjXpwxFjAIU y5ne8zHVcDde8he7t0yZcpK4qLAhfrV3OIaa/wCT04MaWQx4Sdudt0NYcFcrMq1on9Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795336428; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=4B5xglvQmDMhBxbJuTEK9yBt10idEDUaQreE0rT6bZ8=; b=xbhPCiKJRS9NiYHcMcrjzHkVDIBVWFT/mcHUMjegYvH2OT1WjMHmW6IpdWfzt0MqljfP Aoil68qeRod9W2X5eNYrxUWgwiSi7G0IgqUuU3xXcNxq8J7WBrjAmsJZImatG4ZNWX8Gx oZ75hCkLmZOM7IewY7Ubre2+TjSFBKJZzQhJoOXszBRhW5H/Dy/pY0EZT3WgL7U+PEu2F J4N73k/e6thzf0/Ns333aw7gQYg7UltKOU0cEJDqFNLfVpmKm6qm4MA8uWkUPK9kAecKV 0QXXkveEtK0L74R+5gcrB29ompOck0cEux1hcVTa3dOdNYTA/ejoQYCw6Z7N1wk2qCQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BXNQXGse; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 191FA606A333; Sun, 22 Nov 2026 08:33:48 +0000 (UTC) X-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=BXNQXGse X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795336427; b=AaE+e+s5pnHc07fpa1egP7whBds8gWBJ2r3sxzt3JPagJCDzCj2q3sj0qZIElusyCu9X +VIkQHGMiuals5gW2Lm32EvB+GyjpWEC2vfUyNWtDCsH70LJ6cS+ZxK5KUBtqDdL6faQd 91OaX1/O0HkSOTYyKZssyZEsg3GshTTztyS1SRaqVLtypdIBib64QmdCL2NXFW42KDnWi WUXwHg4fkEn2a0HTK5f4gFzbOO0KodPOQG12T1vzSx4uASf7BL5/+kLMnYoMvx6oBQskO PQ3ovuvVNnYXUPYDhLFHBPDd1KCpL11HfDmjTF9vekYbqnhLvWlLAvfhtStLiopm3uw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795336427; 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=4B5xglvQmDMhBxbJuTEK9yBt10idEDUaQreE0rT6bZ8=; b=sd6j1ZHrnrofo45/AXNCdKPXi5TyOKufWBqErgHXHLxTmVt+Sku7Ak9ZnEdWKH5OT3wY 8tvjheq+YM2eXbtBqr/7JsXzab4RdkG04flaFGqCsxmGz6wbqckjrSENPtPdVi5N1HYjr 4DmtUHQKDlmIE3CjxHYOe3t/kpyb95loWDXk8M6jBQ/G7G+eZ0MJyKmnkLn/aD8tKQBk+ /16z42WorpG2E0IRvR1B0J7yczxPVOVSo8DUYJP/p9CcFzxbwb2+T54AQOHwZFb2AbEW2 XEIQ+6Ej1DwKYlvhPe1gm5B2SyOBKNsNDMeBlNd0lp4Ovbe8rCQkRGUXTf+p5Ohvr3Q== X-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=BXNQXGse; arc=none smtp.remote-ip=100.103.45.18 X-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 3687C606A320 for <netdev@vger.kernel.org>; Sun, 22 Nov 2026 08:33:47 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C1341F000C0; Sun, 22 Nov 2026 08:33:46 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795336427; bh=4B5xglvQmDMhBxbJuTEK9yBt10idEDUaQreE0rT6bZ8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=BXNQXGse0YqWdAeFQXiyYZ0W25gWqlyvrm4/12bemPjSAQ8SyBRjK1n1ti8007x3D b3WyV0M28eCucifIkbgO/H3R9cTzhx/biDeiqt56aXZLfEnpd7BoYVT/E0Nkp3ZJgL 53MH1QUxphfcDOh+my4e1mjs9XV92C4JDOMzTYFBQW2YbdcLmQLqHYKORGvebi9/2X UOocyZaGhvV/1WPBbY6KNOJFZTebm0mlKYvPSA6MDMOOgWrEYzt8jgOwn4k+dRdXJL 9N6LG28Rxh92YevQTtsfvizz8c6KPgQ/OHdJ0eDI8d2Yrvvb1tfU6VXPvqgdzkyuxc Kx5KJCnuEsk7w== X-Cc: netdev@vger.kernel.org, jiawenwu@trustnetic.com, duanqiangwen@net-swift.com, linglingzhang@net-swift.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, hramamurthy@google.com, jacob.e.keller@intel.com, przemyslaw.kitszel@intel.com X-In-Reply-To: <20261118081329.39551-2-mengyuanlou@net-swift.com> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list