From: Ali Ahmet Memis <ali@iusegentoo.com>
To: netdev@vger.kernel.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>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH net] net: hsr: wait for pending node-free RCU callbacks on module exit
Date: Fri, 31 Jul 2026 22:25:43 +0300 [thread overview]
Message-ID: <20260731192545.176969-1-ali@iusegentoo.com> (raw)
HSR/PRP node teardown and the prune paths queue node frees with
call_rcu(&node->rcu_head, hsr_free_node_rcu). hsr_free_node_rcu() lives
in the hsr module text.
hsr_exit() tears down netlink, debugfs and the netdev notifier, but it
never calls rcu_barrier(). If a node-free callback is still pending when
the module is unloaded, RCU can invoke hsr_free_node_rcu() after the
module text has been freed, branching into freed memory.
Per Documentation/RCU/checklist.rst, a module that registers callbacks
with call_rcu() must call rcu_barrier() in its exit path before it is
unloaded; synchronize_rcu() is not sufficient because it only waits for
a grace period, not for the queued callbacks to actually run.
Add rcu_barrier() at the end of hsr_exit(), after netlink/link teardown
has stopped any new callbacks from being queued.
Fixes: 415e6367512b ("hsr: Implement more robust duplicate discard for PRP")
Cc: stable@vger.kernel.org
Signed-off-by: Ali Ahmet Memis <ali@iusegentoo.com>
---
net/hsr/hsr_main.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c
index 33951d9bd..05d2e5750 100644
--- a/net/hsr/hsr_main.c
+++ b/net/hsr/hsr_main.c
@@ -179,6 +179,13 @@ static void __exit hsr_exit(void)
hsr_netlink_exit();
hsr_debugfs_remove_root();
unregister_netdevice_notifier(&hsr_nb);
+
+ /* Node teardown queues frees via call_rcu(hsr_free_node_rcu), whose
+ * callback lives in this module. Wait for any still-pending callback
+ * before the module text is freed. synchronize_rcu() is not enough:
+ * it waits for a grace period, not for the callbacks to run.
+ */
+ rcu_barrier();
}
module_init(hsr_init);
--
2.54.0
next reply other threads:[~2026-07-31 19:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 19:25 Ali Ahmet Memis [this message]
2026-08-02 15:34 ` [PATCH net] net: hsr: wait for pending node-free RCU callbacks on module exit Ali Ahmet Memis
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=20260731192545.176969-1-ali@iusegentoo.com \
--to=ali@iusegentoo.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox