From: sashiko-bot@kernel.org
To: "Puranjay Mohan" <puranjay@kernel.org>
Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH v4 2/6] rcu: Make Tiny call_rcu() safe to call from any context
Date: Mon, 10 Aug 2026 12:42:59 +0000 [thread overview]
Message-ID: <20260810124300.6F6F61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810122758.183765-3-puranjay@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Moving `debug_rcu_head_queue()` into `rcu_do_enqueue()` bypasses debugobjects tracking for deferred RCU callbacks, masking use-after-free bugs and causing list corruption on double frees.
--
--- Patch [2]: [PATCH v4 2/6] rcu: Make Tiny call_rcu() safe to call from any context ---
commit b9d1d9e1aa870c19c3d9b30019cdb1bc509b6703
Author: Puranjay Mohan <puranjay@kernel.org>
rcu: Make Tiny call_rcu() safe to call from any context
This commit updates Tiny call_rcu() to handle interrupts-disabled contexts
when the scheduler is active. It defers the callback on a lockless list
which is re-issued later via an irq_work, similar to Tree RCU.
> diff --git a/kernel/rcu/tiny.c b/kernel/rcu/tiny.c
> index dccccd6be9411..656b6a682e31a 100644
> --- a/kernel/rcu/tiny.c
> +++ b/kernel/rcu/tiny.c
[ ... ]
> @@ -157,29 +251,19 @@ EXPORT_SYMBOL_GPL(synchronize_rcu);
> */
> void call_rcu(struct rcu_head *head, rcu_callback_t func)
> {
> - static atomic_t doublefrees;
> - unsigned long flags;
> -
> - if (debug_rcu_head_queue(head)) {
> - if (atomic_inc_return(&doublefrees) < 4) {
> - pr_err("%s(): Double-freed CB %p->%pS()!!! ", __func__, head, head->func);
> - mem_dump_obj(head);
> - }
> + if (should_rcu_defer()) {
> + call_rcu_defer(head, func);
> return;
> }
[Severity: High]
Does moving debug_rcu_head_queue() into rcu_do_enqueue() bypass debugobjects
tracking for deferred RCU callbacks?
Execution is routed to call_rcu_defer() before debug_rcu_head_queue() can
activate the object in the debugobjects tracker. Adding to the lockless list
in call_rcu_defer() overwrites head->next without verifying if the RCU head
is already enqueued.
If a caller erroneously frees the object or double-queues it during the
deferral window before the timer tick issues the irq_work drain, could this
mask use-after-free bugs or create cyclic structures on double frees?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260810122758.183765-1-puranjay@kernel.org?part=2
next prev parent reply other threads:[~2026-08-10 12:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 12:27 [PATCH v4 0/6] rcu,srcu: Make call_rcu()/call_srcu() safe from any context Puranjay Mohan
2026-08-10 12:27 ` [PATCH v4 1/6] rcu: Make call_rcu() safe to call " Puranjay Mohan
2026-08-10 12:43 ` sashiko-bot
2026-08-10 12:48 ` Puranjay Mohan
2026-08-10 12:27 ` [PATCH v4 2/6] rcu: Make Tiny " Puranjay Mohan
2026-08-10 12:42 ` sashiko-bot [this message]
2026-08-10 12:45 ` Puranjay Mohan
2026-08-10 12:27 ` [PATCH v4 3/6] srcu: Make call_srcu() " Puranjay Mohan
2026-08-10 12:27 ` [PATCH v4 4/6] srcu: Make Tiny " Puranjay Mohan
2026-08-10 12:27 ` [PATCH v4 5/6] rcutorture: Exercise ->call() from NMI context Puranjay Mohan
2026-08-10 12:27 ` [PATCH v4 6/6] selftests/bpf: Add a call_srcu() re-entry reproducer Puranjay Mohan
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=20260810124300.6F6F61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--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;
as well as URLs for NNTP newsgroup(s).