From: Andrea Parri <parri.andrea@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>
Cc: Andrea Parri <parri.andrea@gmail.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next v2] rtnetlink: comment the RCU waits in unregister paths
Date: Thu, 15 Oct 2026 10:17:16 +0200 [thread overview]
Message-ID: <20261015081723.404990-1-parri.andrea@gmail.com> (raw)
rtnl_unregister_all() and rtnl_af_unregister() wait for RCU readers
before tearing down what those readers use, but do not say which
readers they are waiting for.
A missing wait is then easy to overlook: rtnl_link_unregister() lacked
its synchronize_rcu() until commit 3b70edea393d ("rtnetlink: wait for
RCU readers in rtnl_link_unregister()"). Add a comment to both waits,
naming the readers each one waits for.
Suggested-by: Eric Dumazet <edumazet@kernel.org>
Link: https://lore.kernel.org/CAL4WiioFMQN4troVjQjCmE6Z9kwwb95SnoEupjD=PPSK6Q5f6w@mail.gmail.com
Assisted-by: LLM
Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
---
v2:
- Drop the comments on synchronize_srcu(), its argument already names
the readers (Kuniyuki)
- Name rtnetlink_rcv_msg() and try_module_get() in the
rtnl_unregister_all() comment (Kuniyuki)
- Mention the rtnl_af_ops walkers that do not take ops->srcu in the
rtnl_af_unregister() comment
v1: https://lore.kernel.org/20261008124423.11543-1-parri.andrea@gmail.com
net/core/rtnetlink.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 15bffafbf0a9c..d73dbc2c8ba0d 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -526,6 +526,9 @@ void rtnl_unregister_all(int protocol)
}
rtnl_unlock();
+ /* Wait for rtnl_get_link() calls that rtnetlink_rcv_msg() makes
+ * under RCU, before try_module_get().
+ */
synchronize_net();
kfree(tab);
@@ -843,6 +846,9 @@ void rtnl_af_unregister(struct rtnl_af_ops *ops)
list_del_rcu(&ops->list);
spin_unlock(&rtnl_af_ops_lock);
+ /* Wait for rtnl_af_ops walkers that invoke callbacks without
+ * ops->srcu, and for rtnl_af_lookup() readers not yet holding it.
+ */
synchronize_rcu();
synchronize_srcu(&ops->srcu);
cleanup_srcu_struct(&ops->srcu);
--
2.53.0
reply other threads:[~2026-10-15 8:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261015081723.404990-1-parri.andrea@gmail.com \
--to=parri.andrea@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox