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

From: Paul E. McKenney

Date: Fri Oct 23 2026 - 15:41:21 EST


On Fri, Oct 23, 2026 at 06:18:33PM +0800, Kunwu Chan wrote:
> 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>

For 1/9-3/9, looks good if there is a kasan_print_aux_stacks() called
somewhere from 7/9-9/9. I am not seeing it, but then again, I do not
claim to be a KASAN expert.

Thanx, Paul

> ---
> 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
>