From: Michal Kubiak <michal.kubiak@intel.com>
To: Breno Leitao <leitao@debian.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
Stephen Hemminger <stephen@networkplumber.org>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<paulmck@kernel.org>
Subject: Re: [PATCH net 1/2] netpoll: Use rcu_access_pointer() in __netpoll_setup
Date: Mon, 18 Nov 2024 13:18:18 +0100 [thread overview]
Message-ID: <Zzswim8DI85fYlRR@localhost.localdomain> (raw)
In-Reply-To: <20241118-netpoll_rcu-v1-1-a1888dcb4a02@debian.org>
On Mon, Nov 18, 2024 at 03:15:17AM -0800, Breno Leitao wrote:
> The ndev->npinfo pointer in __netpoll_setup() is RCU-protected but is being
> accessed directly for a NULL check. While no RCU read lock is held in this
> context, we should still use proper RCU primitives for consistency and
> correctness.
>
> Replace the direct NULL check with rcu_access_pointer(), which is the
> appropriate primitive when only checking for NULL without dereferencing
> the pointer. This function provides the necessary ordering guarantees
> without requiring RCU read-side protection.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Fixes: 8fdd95ec162a ("netpoll: Allow netpoll_setup/cleanup recursion")
nitpick: Shouldn't the "Signed-off-by" tag go as the last one?
Thanks,
Reviewed-by: Michal Kubiak <michal.kubiak@intel.com>
> ---
> net/core/netpoll.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/netpoll.c b/net/core/netpoll.c
> index aa49b92e9194babab17b2e039daf092a524c5b88..45fb60bc4803958eb07d4038028269fc0c19622e 100644
> --- a/net/core/netpoll.c
> +++ b/net/core/netpoll.c
> @@ -626,7 +626,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
> goto out;
> }
>
> - if (!ndev->npinfo) {
> + if (!rcu_access_pointer(ndev->npinfo)) {
> npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
> if (!npinfo) {
> err = -ENOMEM;
>
> --
> 2.43.5
>
>
next prev parent reply other threads:[~2024-11-18 12:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 11:15 [PATCH net 0/2] netpoll: Use RCU primitives for npinfo pointer access Breno Leitao
2024-11-18 11:15 ` [PATCH net 1/2] netpoll: Use rcu_access_pointer() in __netpoll_setup Breno Leitao
2024-11-18 12:18 ` Michal Kubiak [this message]
2024-11-19 3:28 ` Herbert Xu
2024-11-19 10:22 ` Breno Leitao
2024-11-20 3:01 ` Herbert Xu
2024-11-20 3:48 ` Herbert Xu
2024-11-20 17:58 ` Breno Leitao
2024-11-18 11:15 ` [PATCH net 2/2] netpoll: Use rcu_access_pointer() in netpoll_poll_lock Breno Leitao
2024-11-18 12:20 ` Michal Kubiak
2024-11-18 15:37 ` Breno Leitao
2024-11-19 3:02 ` Jakub Kicinski
2024-11-19 3:48 ` Herbert Xu
2024-11-19 3:40 ` [PATCH net 0/2] netpoll: Use RCU primitives for npinfo pointer access patchwork-bot+netdevbpf
2024-11-19 3:53 ` Herbert Xu
2024-11-19 14:34 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zzswim8DI85fYlRR@localhost.localdomain \
--to=michal.kubiak@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paulmck@kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.