* [PATCH] rcu: Mark rcu_read_unlock_special() notrace
@ 2026-11-24 18:56 Sechang Lim
2026-11-24 18:59 ` Bradley Morgan
2026-11-24 19:11 ` sashiko-bot
0 siblings, 2 replies; 3+ messages in thread
From: Sechang Lim @ 2026-11-24 18:56 UTC (permalink / raw)
To: Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki
Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang, rcu,
bpf
The BPF trampoline calls rcu_read_unlock() on its exit path. If the
task was preempted in the RCU read-side critical section, this ends up
in rcu_read_unlock_special(). When a BPF fentry or fexit program is
attached to rcu_read_unlock_special() itself, the trampoline runs again
before ->rcu_read_unlock_special is cleared, calls rcu_read_unlock()
again, and recurses until the stack overflows:
BUG: TASK stack guard page was hit at ffffc90001657ff8
...
bpf_trampoline_6442575622+0x5e/0xac
rcu_read_unlock_special+0x5/0x490
__rcu_read_unlock+0x9c/0x120
rcu_read_unlock_migrate+0x93/0x220
bpf_trampoline_6442575622+0x5e/0xac
rcu_read_unlock_special+0x5/0x490
...
Mark rcu_read_unlock_special() notrace.
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
---
kernel/rcu/tree_plugin.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index ae5d21bae7bc..a887ab69f486 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -746,7 +746,7 @@ static bool rcu_unlock_needs_exp_handling(struct task_struct *t,
* notify RCU core processing or task having blocked during the RCU
* read-side critical section.
*/
-static void rcu_read_unlock_special(struct task_struct *t)
+static notrace void rcu_read_unlock_special(struct task_struct *t)
{
unsigned long flags;
bool irqs_were_disabled;
--
2.56.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rcu: Mark rcu_read_unlock_special() notrace
2026-11-24 18:56 [PATCH] rcu: Mark rcu_read_unlock_special() notrace Sechang Lim
@ 2026-11-24 18:59 ` Bradley Morgan
2026-11-24 19:11 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: Bradley Morgan @ 2026-11-24 18:59 UTC (permalink / raw)
To: rhkrqnwk98
Cc: boqun, bpf, frederic, jiangshanlai, joelagnelf, josh,
mathieu.desnoyers, neeraj.upadhyay, paulmck, qiang.zhang, rcu,
rostedt, urezki
On 24 November 2026 18:56:51 GMT, Sechang Lim <rhkrqnwk98@gmail.com> wrote:
>The BPF trampoline calls rcu_read_unlock() on its exit path. If the
>task was preempted in the RCU read-side critical section, this ends up
>in rcu_read_unlock_special(). When a BPF fentry or fexit program is
>attached to rcu_read_unlock_special() itself, the trampoline runs again
>before ->rcu_read_unlock_special is cleared, calls rcu_read_unlock()
>again, and recurses until the stack overflows:
>
> BUG: TASK stack guard page was hit at ffffc90001657ff8
> ...
> bpf_trampoline_6442575622+0x5e/0xac
> rcu_read_unlock_special+0x5/0x490
> __rcu_read_unlock+0x9c/0x120
> rcu_read_unlock_migrate+0x93/0x220
> bpf_trampoline_6442575622+0x5e/0xac
> rcu_read_unlock_special+0x5/0x490
> ...
>
>Mark rcu_read_unlock_special() notrace.
Hmm.. this seems to be edge case, but no big deal.
Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>
>
>Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
>---
> kernel/rcu/tree_plugin.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
>index ae5d21bae7bc..a887ab69f486 100644
>--- a/kernel/rcu/tree_plugin.h
>+++ b/kernel/rcu/tree_plugin.h
>@@ -746,7 +746,7 @@ static bool rcu_unlock_needs_exp_handling(struct task_struct *t,
> * notify RCU core processing or task having blocked during the RCU
> * read-side critical section.
> */
>-static void rcu_read_unlock_special(struct task_struct *t)
>+static notrace void rcu_read_unlock_special(struct task_struct *t)
> {
> unsigned long flags;
> bool irqs_were_disabled;
>
--- Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rcu: Mark rcu_read_unlock_special() notrace
2026-11-24 18:56 [PATCH] rcu: Mark rcu_read_unlock_special() notrace Sechang Lim
2026-11-24 18:59 ` Bradley Morgan
@ 2026-11-24 19:11 ` sashiko-bot
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-24 19:11 UTC (permalink / raw)
To: Sechang Lim; +Cc: bpf
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] rcu: missing notrace on rcu_unlock_needs_exp_handling() allows
recursion
--
commit 0062b967b0900da7cf7c59da2e3a111544dc9aec
Author: Sechang Lim <rhkrqnwk98@gmail.com>
rcu: Mark rcu_read_unlock_special() notrace
This commit marks rcu_read_unlock_special() notrace to prevent infinite
recursion when a BPF trampoline attached to it calls rcu_read_unlock().
> diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
> index ae5d21bae7bc0..a887ab69f4860 100644
> --- a/kernel/rcu/tree_plugin.h
> +++ b/kernel/rcu/tree_plugin.h
> @@ -746,7 +746,7 @@ static bool rcu_unlock_needs_exp_handling(struct task_struct *t,
> * notify RCU core processing or task having blocked during the RCU
> * read-side critical section.
> */
> -static void rcu_read_unlock_special(struct task_struct *t)
> +static notrace void rcu_read_unlock_special(struct task_struct *t)
> {
> unsigned long flags;
> bool irqs_were_disabled;
[Severity: High]
Should rcu_unlock_needs_exp_handling() also be marked notrace (or static
inline)?
In the preempt_bh_were_disabled || irqs_were_disabled path,
rcu_read_unlock_special() disables IRQs and calls
rcu_unlock_needs_exp_handling() while t->rcu_read_unlock_special.s is
still non-zero. Because rcu_unlock_needs_exp_handling() is neither
notrace nor inline, marking rcu_read_unlock_special() notrace prevents the
compiler from inlining it when notrace expands to
__no_instrument_function__. Attaching a BPF fentry or fexit program to
rcu_unlock_needs_exp_handling() then triggers the same
rcu_read_unlock() -> rcu_read_unlock_special() recursion and stack
overflow.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124185659.1370644-1-rhkrqnwk98@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-24 19:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 18:56 [PATCH] rcu: Mark rcu_read_unlock_special() notrace Sechang Lim
2026-11-24 18:59 ` Bradley Morgan
2026-11-24 19:11 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox