Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 3/3] fprobe: Switch fprobe and BPF kprobe-multi to Tasks-Rude RCU
Date: Mon, 28 Sep 2026 14:46:36 +0000	[thread overview]
Message-ID: <20260928144636.9D2531F00893@smtp.kernel.org> (raw)
In-Reply-To: <179060579456.372125.8753302103085829884.stgit@devnote2>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] trace: Use-After-Free in fprobe_module_callback during rhashtable walk
- [Low] trace: sparse context imbalance due to missing RCU_SCHED annotation
--

commit b3e36a52547a2b577250e858535265a49a8ab8b5
Author: Masami Hiramatsu (Google) <mhiramat@kernel.org>

fprobe: Switch fprobe and BPF kprobe-multi to Tasks-Rude RCU

This commit switches fprobe entry/exit callbacks and BPF kprobe-multi 
asynchronous unregistration from standard RCU to Tasks-Rude RCU. This 
prevents potential use-after-free races during RCU grace periods by 
waiting for preempt-disabled execution contexts to complete.

> diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
> index 9f2d98181779a..b7850df17575a 100644
> --- a/kernel/trace/fprobe.c
> +++ b/kernel/trace/fprobe.c

[ ... ]

> @@ -76,8 +76,14 @@ static const struct rhashtable_params fprobe_rht_params = {
>  	.obj_hashfn		= fprobe_node_obj_hashfn,
>  	.obj_cmpfn		= fprobe_node_cmp,
>  	.automatic_shrinking	= true,
> +	.use_tasks_rude		= true,

[Severity: High]
Does setting .use_tasks_rude = true introduce a use-after-free race during
module unload?

Since deferred bucket table reclamation now uses call_rcu_tasks_rude(), the
table walk in fprobe_module_callback() might not have adequate reader
protection:

kernel/trace/fprobe.c:fprobe_module_callback() {
    ...
		rhashtable_walk_start(&iter);

		while ((node = rhashtable_walk_next(&iter)) && !IS_ERR(node))
			if (fprobe_remove_node_in_module(mod, node, &alist) < 0) {
    ...
}

rhashtable_walk_start() solely relies on rcu_read_lock(). Under
CONFIG_PREEMPT_RCU, rcu_read_lock() does not disable preemption, meaning
a preemption during the walk satisfies the Tasks-Rude RCU quiescent state.

If the walker is preempted, could a concurrent background resize complete its
grace period and free the bucket table, causing rhashtable_walk_next() to
dereference freed memory when the walker is scheduled back?

>  };
>  
> +DEFINE_LOCK_GUARD_0(rcu_sched_notrace, rcu_read_lock_sched_notrace(),
> +		    rcu_read_unlock_sched_notrace())
> +DECLARE_LOCK_GUARD_0_ATTRS(rcu_sched_notrace, __acquires_shared(RCU),
> +			   __releases_shared(RCU))

[Severity: Low]
Does the rcu_sched_notrace lock guard declaration omit the RCU_SCHED context?

rcu_read_lock_sched_notrace() acquires both RCU and RCU_SCHED, but this
DECLARE_LOCK_GUARD_0_ATTRS macro only declares __acquires_shared(RCU) and
__releases_shared(RCU).

Could this cause sparse context imbalance warnings due to the missing
__acquires_shared(RCU_SCHED) and __releases_shared(RCU_SCHED) annotations?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179060575297.372125.10581329083761385407.stgit@devnote2?part=3

  reply	other threads:[~2026-09-28 14:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 14:29 [RFC PATCH 0/3] fprobe, rcu/tasks, rhashtable: Switch fprobe and BPF kprobe-multi to Tasks-Rude RCU Masami Hiramatsu (Google)
2026-09-28 14:29 ` [RFC PATCH 1/3] rcu/tasks: Export call_rcu_tasks_rude() Masami Hiramatsu (Google)
2026-09-28 14:39   ` sashiko-bot
2026-09-28 15:17   ` bot+bpf-ci
2026-09-28 14:29 ` [RFC PATCH 2/3] rhashtable: Add use_tasks_rude parameter to defer bucket table free Masami Hiramatsu (Google)
2026-09-28 14:43   ` sashiko-bot
2026-09-28 14:29 ` [RFC PATCH 3/3] fprobe: Switch fprobe and BPF kprobe-multi to Tasks-Rude RCU Masami Hiramatsu (Google)
2026-09-28 14:46   ` sashiko-bot [this message]
2026-09-28 16:25 ` [RFC PATCH 0/3] fprobe, rcu/tasks, rhashtable: " Paul E. McKenney
2026-09-28 23:28   ` Masami Hiramatsu
2026-09-29  0:04     ` Paul E. McKenney
2026-09-29  0:33       ` Andrii Nakryiko
2026-09-29  0:41         ` Paul E. McKenney
2026-09-30  0:35           ` Masami Hiramatsu
2026-09-30  0:47             ` 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=20260928144636.9D2531F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@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