Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: hsr: wait for pending node-free RCU callbacks on module exit
@ 2026-07-31 19:25 Ali Ahmet Memis
  2026-08-02 15:34 ` Ali Ahmet Memis
  0 siblings, 1 reply; 2+ messages in thread
From: Ali Ahmet Memis @ 2026-07-31 19:25 UTC (permalink / raw)
  To: netdev
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, linux-kernel, stable

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-02 15:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 19:25 [PATCH net] net: hsr: wait for pending node-free RCU callbacks on module exit Ali Ahmet Memis
2026-08-02 15:34 ` Ali Ahmet Memis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox