From: sashiko-bot@kernel.org
To: "Puranjay Mohan" <puranjay@kernel.org>
Cc: linux-perf-users@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 2/2] uprobes: Switch uretprobes_srcu to SRCU-fast-updown
Date: Mon, 06 Jul 2026 17:42:41 +0000 [thread overview]
Message-ID: <20260706174242.25B791F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706172744.3920417-3-puranjay@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrent hprobe_expire() and hprobe_consume() can cause a use-after-free on uprobe due to misunderstood SRCU semantics.
--
commit 86c857f0a70ec453b9e38c36e230b36b91bef460
Author: Puranjay Mohan <puranjay@kernel.org>
uprobes: Switch uretprobes_srcu to SRCU-fast-updown
uretprobes_srcu currently uses normal SRCU, which issues
two smp_mb() per read lock/unlock pair. This overhead is
paid on every uretprobe hit.
Switch to SRCU-fast-updown, which eliminates the per-reader
memory barriers by moving the ordering cost to the
grace-period side.
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 4084e926e2844..afa491b0bd3f9 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
[ ... ]
> @@ -2045,7 +2046,7 @@ static void ri_timer(struct timer_list *timer)
> struct return_instance *ri;
>
> /* SRCU protects uprobe from reuse for the cmpxchg() inside hprobe_expire(). */
> - guard(srcu)(&uretprobes_srcu);
> + guard(srcu_fast_updown)(&uretprobes_srcu);
[Severity: High]
This isn't a bug introduced by this patch, but does the new SRCU read lock
acquired here actually protect the uprobe from being freed?
If a uprobe is being unregistered, uprobe_free_deferred() calls
call_srcu(&uretprobes_srcu, ...) to free the uprobe. This starts an SRCU
grace period that waits only for pre-existing SRCU readers to finish.
Concurrently, if ri_timer() or dup_utask() takes this new SRCU read lock,
the grace period will not wait for it because the new lock started after the
grace period began.
If the traced task concurrently executes uprobe_handle_trampoline(), calls
hprobe_consume() and hprobe_finalize(), and releases the original SRCU read
lock, the grace period can complete and free the uprobe (via
call_rcu_tasks_trace()).
When ri_timer() then proceeds to call hprobe_expire(), which does:
kernel/events/uprobes.c:hprobe_expire() {
...
case HPROBE_LEASED: {
struct uprobe *uprobe = try_get_uprobe(hprobe->uprobe);
...
}
Could this lead to a use-after-free on the uprobe? The comment in
hprobe_expire() seems to assume the new lock prevents the free:
/*
* Even if hprobe_consume() or another hprobe_expire() wins
* the state update race and unlocks SRCU from under us, we
* still have a guarantee that underyling uprobe won't be
* freed due to ongoing caller's SRCU lock region, so we can
* return it regardless.
*/
Is this analysis accurate?
> /* RCU protects return_instance from freeing. */
> guard(rcu)();
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706172744.3920417-1-puranjay@kernel.org?part=2
prev parent reply other threads:[~2026-07-06 17:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 17:27 [PATCH bpf-next 0/2] uprobes: Switch uretprobes_srcu to SRCU-fast-updown Puranjay Mohan
2026-07-06 17:27 ` [PATCH bpf-next 1/2] srcu: Add lock guard for srcu_fast_updown flavor Puranjay Mohan
2026-07-06 17:36 ` Paul E. McKenney
2026-07-06 17:27 ` [PATCH bpf-next 2/2] uprobes: Switch uretprobes_srcu to SRCU-fast-updown Puranjay Mohan
2026-07-06 17:42 ` sashiko-bot [this message]
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=20260706174242.25B791F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=puranjay@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