rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] rcu: Return early if callback is not specified
@ 2025-06-10 17:34 Uladzislau Rezki (Sony)
  2025-06-10 17:34 ` [PATCH 2/3] rcu: Enable rcu_normal_wake_from_gp on small systems Uladzislau Rezki (Sony)
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Uladzislau Rezki (Sony) @ 2025-06-10 17:34 UTC (permalink / raw)
  To: Paul E . McKenney, Joel Fernandes, Neeraj upadhyay
  Cc: RCU, LKML, Frederic Weisbecker, Uladzislau Rezki,
	Oleksiy Avramchenko

Currently the call_rcu() API does not check whether a callback
pointer is NULL. If NULL is passed, rcu_core() will try to invoke
it, resulting in NULL pointer dereference and a kernel crash.

To prevent this and improve debuggability, this patch adds a check
for NULL and emits a kernel stack trace to help identify a faulty
caller.

Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
---
 kernel/rcu/tree.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index e8a4b720d7d2..14d4499c6fc3 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3072,6 +3072,10 @@ __call_rcu_common(struct rcu_head *head, rcu_callback_t func, bool lazy_in)
 	/* Misaligned rcu_head! */
 	WARN_ON_ONCE((unsigned long)head & (sizeof(void *) - 1));
 
+	/* Avoid NULL dereference if callback is NULL. */
+	if (WARN_ON_ONCE(!func))
+		return;
+
 	if (debug_rcu_head_queue(head)) {
 		/*
 		 * Probable double call_rcu(), so leak the callback.
-- 
2.39.5


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

end of thread, other threads:[~2025-06-17  2:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10 17:34 [PATCH 1/3] rcu: Return early if callback is not specified Uladzislau Rezki (Sony)
2025-06-10 17:34 ` [PATCH 2/3] rcu: Enable rcu_normal_wake_from_gp on small systems Uladzislau Rezki (Sony)
2025-06-10 18:34   ` Joel Fernandes
2025-06-11  9:25     ` Uladzislau Rezki
2025-06-10 17:34 ` [PATCH 3/3] Documentation/kernel-parameters: Update rcu_normal_wake_from_gp doc Uladzislau Rezki (Sony)
2025-06-10 19:33 ` [PATCH 1/3] rcu: Return early if callback is not specified Joel Fernandes
2025-06-11  9:24   ` Uladzislau Rezki
2025-06-12 17:30   ` Boqun Feng
2025-06-12 17:33     ` Boqun Feng
2025-06-12 17:46     ` Uladzislau Rezki
2025-06-12 21:03       ` Boqun Feng
2025-06-17  2:25         ` Joel Fernandes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).