mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dlm: wait for outstanding SRCU callbacks to complete in exit paths
@ 2026-09-01  9:18 Zqiang
  2026-09-01 17:12 ` Alexander Aring
  2026-09-02 13:21 ` Alexander Aring
  0 siblings, 2 replies; 13+ messages in thread
From: Zqiang @ 2026-09-01  9:18 UTC (permalink / raw)
  To: aahringo, teigland; +Cc: gfs2, linux-kernel, qiang.zhang

The dlm_lowcomms_exit() and dlm_midcomms_exit() iterate over the
srcu protected connection and node hash tables and hand each
element to call_srcu() for deferred freeing (connection_release()
and midcomms_node_release()). call_srcu() is asynchronous: the
callbacks are invoked only after an SRCU grace period, which may
happen after the exit function has already returned.

These exit functions are reached from exit_dlm() on module unload.
Once they return, module teardown continues and the module text
may be unloaded while call_srcu() callbacks are still pending. When
such a callback finally runs, it executes freed module code and
touches the static SRCU domains that are being torn down, resulting
in a use-after-free.

Add an srcu_barrier() after the call_srcu() loop in each exit function
to wait for all outstanding callbacks of the respective SRCU domain to
complete before returning. In dlm_midcomms_exit() the barrier is issued
before dlm_lowcomms_exit() so that node callbacks are drained prior to
tearing down the lower layer.

Signed-off-by: Zqiang <qiang.zhang@linux.dev>
---
 fs/dlm/lowcomms.c | 1 +
 fs/dlm/midcomms.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index 2aff1c7c17de..ea8353c4638d 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -1984,4 +1984,5 @@ void dlm_lowcomms_exit(void)
 		}
 	}
 	srcu_read_unlock(&connections_srcu, idx);
+	srcu_barrier(&connections_srcu);
 }
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c
index 8964164600d2..045431524494 100644
--- a/fs/dlm/midcomms.c
+++ b/fs/dlm/midcomms.c
@@ -1178,6 +1178,7 @@ void dlm_midcomms_exit(void)
 		}
 	}
 	srcu_read_unlock(&nodes_srcu, idx);
+	srcu_barrier(&nodes_srcu);
 
 	dlm_lowcomms_exit();
 }
-- 
2.17.1


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

end of thread, other threads:[~2026-09-02 20:05 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-01  9:18 [PATCH] dlm: wait for outstanding SRCU callbacks to complete in exit paths Zqiang
2026-09-01 17:12 ` Alexander Aring
2026-09-02 13:21 ` Alexander Aring
2026-09-02 14:15   ` Zqiang
2026-09-02 14:29     ` Zqiang
2026-09-02 14:36       ` Alexander Aring
2026-09-02 14:49         ` Zqiang
2026-09-02 15:02           ` Alexander Aring
2026-09-02 14:30     ` Alexander Aring
2026-09-02 14:48       ` Alexander Aring
2026-09-02 16:44       ` Paul E. McKenney
2026-09-02 17:13         ` Alexander Aring
2026-09-02 20:05           ` Paul E. McKenney

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

all inboxes | Powered by JetHome®