[PATCH 5/9] rcu: Validate callback arguments in Tiny RCU

From: Kunwu Chan

Date: Fri Oct 23 2026 - 06:20:52 EST


Check callback-head alignment and reject NULL callback
functions in Tiny RCU's call_rcu() path.

Signed-off-by: Kunwu Chan <chentao@xxxxxxxxxx>
---
kernel/rcu/tiny.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
index bd22fa43108d..ef0b0474f207 100644
--- a/kernel/rcu/tiny.c
+++ b/kernel/rcu/tiny.c
@@ -252,6 +252,13 @@ EXPORT_SYMBOL_GPL(synchronize_rcu);
*/
void call_rcu(struct rcu_head *head, rcu_callback_t func)
{
+ /* 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;
+
/* Record the caller: the irq_work's stack says nothing about it. */
kasan_record_aux_stack(head);

--
2.43.0