[PATCH 1/9] srcu: Record callback registration stack for KASAN

From: Kunwu Chan

Date: Fri Oct 23 2026 - 06:22:19 EST


Record the callback registration stack in __call_srcu()
for KASAN diagnostics involving SRCU callbacks.

Suggested-by: Zqiang <qiang.zhang@xxxxxxxxx>
Signed-off-by: Kunwu Chan <chentao@xxxxxxxxxx>
---
kernel/rcu/srcutree.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 2b0e2b2d2c18..46fe2f0cef85 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -20,6 +20,7 @@
#include <linux/percpu.h>
#include <linux/preempt.h>
#include <linux/irq_work.h>
+#include <linux/kasan.h>
#include <linux/llist.h>
#include <linux/rcupdate_wait.h>
#include <linux/sched.h>
@@ -1530,6 +1531,10 @@ static void __call_srcu(struct srcu_struct *ssp, struct rcu_head *rhp,
{
if (WARN_ON_ONCE(ssp->srcu_reader_flavor == SRCU_READ_FLAVOR_ATOMIC))
return; // Leak the callback rather than corrupt SRCU state.
+
+ /* Record the caller: the irq_work's stack says nothing about it. */
+ kasan_record_aux_stack(rhp);
+
if (should_rcu_defer()) {
struct srcu_defer *sndp = this_cpu_ptr(&srcu_defer);
struct srcu_data *sdp;
--
2.43.0