🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20746

Re: [PATCH net v8 1/2] net: wangxun: protect ring accesses with RCU

#20746
From: mengyuanlou
Date: Mon, 23 Nov 2026 06:21
163 lines
14961 bytes

> 2026年11月22日 16:33,netdev-bot+sashiko@kernel.org 写道:
> 
> 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 /…

The commit about vf resume/suspend related commit, just merged into net-next,
but not yet merged into net.
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?h=main&id=a6c3e4c1f7032e44cf5dc897a3d328b138e770d1

> 
> --
> 
> 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: <AD0ED59F-3879-46FE-AA7C-E97C81CA57EC@net-swift.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369064-linux-kernel-netdev=dewy.ru
References: <20261118081329.39551-2-mengyuanlou@net-swift.com> <179533642599.3135.8576432289828139956@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369064-linux-kernel-netdev=dewy.ru
From: mengyuanlou@net-swift.com ("mengyuanlou@net-swift.com")
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v8 1/2] net: wangxun: protect ring accesses with RCU
Date: Mon, 23 Nov 2026 14:21:07 +0800
Organization: Usenet Network
Message-ID: <AD0ED59F-3879-46FE-AA7C-E97C81CA57EC@net-swift.com>
References: <20261118081329.39551-2-mengyuanlou@net-swift.com> <179533642599.3135.8576432289828139956@kernel.org>
MIME-Version: 1.0 (Mac OS X Mail 16.0 \(3901.200.71.1.16\))
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network; logging-data="3806945"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:25UW+ZR25KtuLcSyWXCaB3COYe0= sha256:PcE78bZHyBf5eGn5NNnaY1ZWqO1Rtxg6kQ14uB0c22M= sha1:n4Ou4PKUd3JbwVw0GoUq2iyFz3E= sha256:ZvexveD5E+aiGadAPRHfpG+z+YMvZCMvCEXtn+EwJfs=
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 174F4125D8E; Mon, 23 Nov 2026 09:23:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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-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 cY57SY3zOta2; Mon, 23 Nov 2026 09:23:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-369064-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=net-swift.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 5AC69125D89; Mon, 23 Nov 2026 09:23:04 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 780D460287C; Mon, 23 Nov 2026 06:23:03 +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=1795414980; b=abt30OhrVtcETgu6R8GfRatB3fgTNDqV9G7doMN3SLXjhXDsrlrBVPsPVBdhRdZr8WXg SDcxEWkDAv57ZZTmKJuiVgDozfhFoVM8AocThtTHggAHxgt07nGssQyXvvKk0CD3vazl7 zoCQAfbs5RWmnZavSGC/v+8v0sy1M+1TXl7PUafmv0bgaAxkumLRAFFr5MDsCivfEqXi5 oK/6SxOzxVle8E5ZW6MYy4ZUBBrFD5oPgWpzYaSNlgpAqjjdiNE5LifgQzdDk8FOQInaJ IQjzWJelsF1WHKT+Mez0ZHdbZapWBVdSP/C2nI1Hel08zDeaMOa/rmcSKoFWsYjsluA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795414980; h=X-Original-To:Received:DMARC-Filter:X-QQ-mid:X-QQ-Originating-IP: Received:X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt: Content-Type:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:Mime-Version: Subject:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id: References:To:X-Mailer:X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO: X-QQ-XMRINFO:X-QQ-RECHKSPAM; bh=E0SzxQNyO/uz2Vmt2xfShNpjdQxODRf21ORNBL7OCDI=; b=2PwXpjoOJF9LFxqR/CdDMhe/hgu7HPALBOiw1xVbKez1S1OIc141YIuuH36yLT8RXjfj 3F66HfMBDxrIs9pJZL87nzUjKCiWQkQLIU3Pmz7+ceJQ5Oi6ERGxeWZInNYE+VdIn22If 05Yned1Rire8N2XPyKFL3IDrpwKYcFXVsqiAS2dMvYGnfew4aoXMm7nI3XUEcEQnWFBPP kG8wsa0tViohYkmYXRjPFzZBKMn2jyUT0eniAn7a9A1JS4pb+rA2xVpP+lfClzO00BXXg ax3fGp+GAS3UiNuUjpzcXQfwsu9KyrRS0iZpAGZm8EyIMn81R3qUrp/dlFKdG5CXndw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=net-swift.com; spf=pass smtp.mailfrom=net-swift.com; 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 C1D10606A32C; Mon, 23 Nov 2026 06:23:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.254.200.128
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795414980; b=pmmMk3VS1Z36UsSkU1TDLct7c1+BZBg/+UIyEFCxKUjzPtQTAxcpOeSEPjU7FBsqShu7 YRdw68r6yTvDxBHavKC3fbyQe4MPgrsRrAVhdsqrd/avLJYC2DvdHHbRdm9oyZoH7UF6p xIpMIs0lfEt7tKNInTdbJyhOfx1cdP6QWpelGyTWlE8N+XZTOK2MQXve/99LHn8JjRXfo 11q9Qg/TdcR//VD9H5D7gdV5nhZheXPT1V6CtaLHOJ31zU4EGZchZJYvaR2T0XPUBdSfR yDGZqF2Jrw4kA20SLil9NDv1Rza51w2bVRZKGjR1Jz6R4havEhkq6Nz+yRVkYddyhlg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795414980; h=DMARC-Filter:X-QQ-mid:X-QQ-Originating-IP:Received:X-QQ-SSF: X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt:Content-Type:Mime-Version: Subject:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id: References:To:X-Mailer:X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO: X-QQ-XMRINFO:X-QQ-RECHKSPAM; bh=E0SzxQNyO/uz2Vmt2xfShNpjdQxODRf21ORNBL7OCDI=; b=bLD9cunZBuhXBzZxEjzNWHHmYdkyInVdkJEXU504i5N191POM6+1HjojZBVicWcTgC90 85EbpX3IuiWGu9zDKlMga7WFV8KkqzSa1yW7YrEgG/GNCN2nATvWQV1/vqtYO/pq4uWOG 5BczAfQqSaEUeUrdpPUfVjAIQG6zjt0tsEyusra7V9hNJ94gAh11N/+iZw5Wys0aAzMxq YhSlQQnYwB9OP3G1o9cX1mVbvOjGxNXZeAplAEKjD1F04LxuotXgDmyBS6r0t7rF8pCCp LnmLLVpC8nuHM8eGQUsxKwT0Vxz12fO8g7NhBuzE01jWu3egdh2Rk/K+I2rjjwnQr4A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=net-swift.com; spf=pass smtp.mailfrom=net-swift.com; arc=none smtp.remote-ip=54.254.200.128
X-Received: from smtpbgsg2.qq.com (smtpbgsg2.qq.com [54.254.200.128]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C51F2606A31A for <netdev@vger.kernel.org>; Mon, 23 Nov 2026 06:22:55 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C51F2606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=net-swift.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=net-swift.com
X-QQ-mid: zesmtpgz7t1795414880t94da28dd
X-QQ-Originating-IP: HeS6DOpmqT5ZUuVCSAEEzeF9BBtJUj8cUbGrAqp0wFE=
X-Received: from smtpclient.apple ( [36.24.187.23]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 23 Nov 2026 14:21:18 +0800 (CST)
X-QQ-SSF: 0000000000000000000000000000000
X-QQ-GoodBg: 0
X-BIZMAIL-ID: 4641797366784374674
X-EX-QQ-RecipientCnt: 13
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
X-In-Reply-To: <179533642599.3135.8576432289828139956@kernel.org>
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-Mailer: Apple Mail (2.3901.200.71.1.16)
X-QQ-SENDSIZE: 520
X-Feedback-ID: zesmtpgz:net-swift.com:qybglogicsvrgz:qybglogicsvrgz5b-1
X-QQ-XMAILINFO: OCRLgRRf+JROd/VXA4fWPwR1kTP/5jzrJYYGzoq97XF3oAGZqaStSyuJ 0jHFJYQXsyVNO/Weh54k+/DnZL9IKa/LboeRbXBM0wyHbaxw5k7Uh4GHPtJZmbx94FuekF4 sTfAAnSRp36cGIn+wxDHZcgDttI9iiHX161cofh9w5ZgwelZ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