[PATCH for-v7.5 03/11] srcutiny: Record callback registration stack for KASAN

From: Joel Fernandes

Date: Thu Nov 12 2026 - 20:11:51 EST


From: Kunwu Chan <kunwu.chan@xxxxxxxxx>

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

Suggested-by: Zqiang <qiang.zhang@xxxxxxxxx>
Signed-off-by: Kunwu Chan <chentao@xxxxxxxxxx>
Reviewed-by: Joel Fernandes <jfern@xxxxxxxxxx>
Signed-off-by: Joel Fernandes <jfern@xxxxxxxxxx>
---
kernel/rcu/srcutiny.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
index 63a3f0a8bc53..3ee28885b96f 100644
--- a/kernel/rcu/srcutiny.c
+++ b/kernel/rcu/srcutiny.c
@@ -10,6 +10,7 @@

#include <linux/export.h>
#include <linux/irq_work.h>
+#include <linux/kasan.h>
#include <linux/llist.h>
#include <linux/mutex.h>
#include <linux/preempt.h>
@@ -290,6 +291,9 @@ EXPORT_SYMBOL_GPL(srcu_defer_drain);
void call_srcu(struct srcu_struct *ssp, struct rcu_head *rhp,
rcu_callback_t func)
{
+ /* Record the caller: the irq_work's stack says nothing about it. */
+ kasan_record_aux_stack(rhp);
+
if (should_rcu_defer()) {
/* A re-entrant call_srcu() during the drain would livelock it. */
if (READ_ONCE(srcu_defer_draining) && !in_nmi()) {
--
2.54.0