BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Josef Bacik" <josef@toxicpanda.com>
Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH RFC v4 02/13] rcu-tasks: Add a Tasks RCU implementation for reader-marked trampolines
Date: Fri, 18 Sep 2026 15:10:30 +0000	[thread overview]
Message-ID: <20260918151031.2E0941F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260918-b4-rcu-tasks-preempt-qs-v4-2-63f0e9d69661@toxicpanda.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] rcu-tasks: NULL pointer dereference in rcu_tasks_irq_resched_enter() during early boot
--

commit ea4914f1671c6b6ff32f3cbc1cd74fa6dd51744d
Author: Josef Bacik <josef@toxicpanda.com>

rcu-tasks: Add a Tasks RCU implementation for reader-marked trampolines

This commit introduces a Tasks RCU implementation for architectures that
make their trampolines Tasks Trace RCU readers. It hooks into the generic
irq entry code to track preemptions. The tracking utilizes a per-CPU list
for tasks preempted during irq exit.

> diff --git a/kernel/entry/common.c b/kernel/entry/common.c
> index e4acd50bd81a1..94318519998c8 100644
> --- a/kernel/entry/common.c
> +++ b/kernel/entry/common.c

[ ... ]

> @@ -141,8 +142,13 @@ void raw_irqentry_exit_cond_resched(struct pt_regs *regs)
>  		rcu_irq_exit_check_preempt();
>  		if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
>  			WARN_ON_ONCE(!on_thread_stack());
> -		if (need_resched() && arch_irqentry_exit_need_resched())
> +		if (need_resched() && arch_irqentry_exit_need_resched()) {
> +			if (IS_ENABLED(CONFIG_TASKS_RCU_TRAMPOLINE_READERS))
> +				rcu_tasks_irq_resched_enter(instruction_pointer(regs));
>  			preempt_schedule_irq();
> +			if (IS_ENABLED(CONFIG_TASKS_RCU_TRAMPOLINE_READERS))
> +				rcu_tasks_irq_resched_exit();
> +		}
>  	}
>  }

> diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
> index 627295396cd91..f03be742be48c 100644
> --- a/kernel/rcu/tasks.h
> +++ b/kernel/rcu/tasks.h

[ ... ]

> +void rcu_tasks_irq_resched_enter(unsigned long ip)
> +{
> +	struct task_struct *t = current;
> +	struct rcu_tasks_percpu *rtpcp = this_cpu_ptr(rcu_tasks.rtpcpu);
> +
> +	lockdep_assert_irqs_disabled();
> +	WRITE_ONCE(t->rcu_tasks_irq_ip, ip);
> +	t->rcu_tasks_exit_cpu = smp_processor_id();
> +	raw_spin_lock_rcu_node(rtpcp);
> +	list_add(&t->rcu_tasks_exit_list, &rtpcp->rtp_exit_list);

[Severity: Critical]
Could this cause a null pointer dereference regression during early boot?

When the trampoline reader feature is selected,
raw_irqentry_exit_cond_resched() hooks into the generic irq exit path to
call rcu_tasks_irq_resched_enter(). During early boot, interrupts are
enabled via local_irq_enable() in start_kernel(), meaning preemptions can
begin occurring.

However, the per-cpu rtp_exit_list list head cannot be statically
initialized and is dynamically initialized via cblist_init_generic() from
a core_initcall. Since core_initcalls are executed much later by the
kernel_init thread, any preemption before that phase will attempt to
list_add() to a zero-initialized (null) rtp_exit_list.

Would this lead to a kernel panic when the list macros dereference the
uninitialized head pointer?

> +	raw_spin_unlock_rcu_node(rtpcp);
> +
> +	if (unlikely(rcu_tasks_trampoline_text(ip)))
> +		rcu_tasks_tramp_hold(t);
> +	else
> +		rcu_tasks_tramp_release(t);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260918-b4-rcu-tasks-preempt-qs-v4-0-63f0e9d69661@toxicpanda.com?part=2

  reply	other threads:[~2026-09-18 15:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 14:49 [PATCH RFC v4 00/13] rcu-tasks: build Tasks RCU on Tasks Trace readers in trampolines Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 01/13] entry: Pass pt_regs to irqentry_exit_cond_resched() Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 02/13] rcu-tasks: Add a Tasks RCU implementation for reader-marked trampolines Josef Bacik
2026-09-18 15:10   ` sashiko-bot [this message]
2026-09-18 15:48     ` Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 03/13] kprobes: Expose the optprobe jump window to Tasks RCU Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 04/13] ftrace: Mark modules hosting direct-call trampolines for " Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 05/13] x86/ftrace: Take a Tasks Trace reader around ftrace_caller's call-out Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 06/13] x86/kprobes: Take a Tasks Trace reader in the optprobe template Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 07/13] bpf, x86: Take a Tasks Trace reader in the trampoline around its call-outs Josef Bacik
2026-09-18 21:26   ` Alexei Starovoitov
2026-09-18 14:49 ` [PATCH RFC v4 08/13] arm64: ftrace: Take a Tasks Trace reader around ftrace_caller's call-out Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 09/13] bpf, arm64: Take a Tasks Trace reader in the trampoline around its call-outs Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 10/13] samples: ftrace: Make the direct-call trampolines Tasks Trace readers Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 11/13] rcutorture: Make Tasks RCU readers Tasks Trace readers where required Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 12/13] rcu-tasks-trace: Assert no reader is held on return to userspace Josef Bacik
2026-09-18 14:49 ` [PATCH RFC v4 13/13] x86, arm64: Build Tasks RCU on Tasks Trace readers in trampolines Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260918151031.2E0941F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox