The BPF trampoline takes and drops the RCU read lock itself. When the outermost rcu_read_unlock() finds ->rcu_read_unlock_special.s set, it calls rcu_read_unlock_special(). If an fentry program is attached to rcu_read_unlock_special(), the unlock on the trampoline exit path still sees .s set and calls rcu_read_unlock_special() again, which 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 ... With fexit it recurses even earlier, from percpu_ref_get() in __bpf_tramp_enter(), which takes and drops the RCU read lock before the program runs. Mark rcu_read_unlock_special() notrace. rcu_unlock_needs_exp_handling() also runs with .s set, so mark it notrace too. Signed-off-by: Sechang Lim --- v4: - Go back to notrace as in v1 - Also mark rcu_unlock_needs_exp_handling() notrace (Alexei) v3: https://lore.kernel.org/bpf/20261125055359.2715140-1-rhkrqnwk98@gmail.com/ v2: https://lore.kernel.org/bpf/20261125040106.2200628-1-rhkrqnwk98@gmail.com/ v1: https://lore.kernel.org/rcu/20261124185659.1370644-1-rhkrqnwk98@gmail.com/ kernel/rcu/tree_plugin.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 3500e4874833..9c1b227f5fa0 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -689,10 +689,10 @@ static void rcu_preempt_deferred_qs_handler(struct irq_work *iwp) * * Returns true if expedited processing of the rcu_read_unlock() is needed. */ -static bool rcu_unlock_needs_exp_handling(struct task_struct *t, - struct rcu_data *rdp, - struct rcu_node *rnp, - bool irqs_were_disabled) +static notrace bool rcu_unlock_needs_exp_handling(struct task_struct *t, + struct rcu_data *rdp, + struct rcu_node *rnp, + bool irqs_were_disabled) { /* * Check if this task is blocking an expedited grace period. If the @@ -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; base-commit: 2348d158c7fcc2c9557b2fb550ee841c62942fbd -- 2.56.1