From: Bradley Morgan <bradley.morgan@linux.dev>
To: Sechang Lim <rhkrqnwk98@gmail.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <jfern@kernel.org>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun@kernel.org>,
Uladzislau Rezki <urezki@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>,
Puranjay Mohan <puranjay@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
rcu@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] rcu: Mark rcu_read_unlock_special() notrace
Date: Sat, 28 Nov 2026 12:48:47 +0000 [thread overview]
Message-ID: <E81D3CA7-DB12-4A2E-BA60-C371FC420F77@linux.dev> (raw)
In-Reply-To: <20261128061955.174288-1-rhkrqnwk98@gmail.com>
On 28 November 2026 06:19:26 GMT, Sechang Lim <rhkrqnwk98@gmail.com> wrote:
>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.
I took a double look, like loads of looks, this seriously LGTM, like, I
like this, thanks for the patch,
Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>
>
>Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
>---
>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
>
--- Thanks!
next prev parent reply other threads:[~2026-11-28 12:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 6:19 [PATCH v4] rcu: Mark rcu_read_unlock_special() notrace Sechang Lim
2026-11-28 12:48 ` Bradley Morgan [this message]
2026-11-28 17:39 ` Alexei Starovoitov
2026-11-30 17:18 ` Paul E. McKenney
2026-11-30 17:21 ` Joel Fernandes
2026-12-01 18:44 ` Paul E. McKenney
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=E81D3CA7-DB12-4A2E-BA60-C371FC420F77@linux.dev \
--to=bradley.morgan@linux.dev \
--cc=ast@kernel.org \
--cc=boqun@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=frederic@kernel.org \
--cc=jfern@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=puranjay@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rhkrqnwk98@gmail.com \
--cc=rostedt@goodmis.org \
--cc=urezki@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.