From: sashiko-bot@kernel.org
To: "Puranjay Mohan" <puranjay@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v6 3/4] bpf: Add bpf_call_rcu_tasks_trace() kfunc
Date: Tue, 22 Sep 2026 20:37:02 +0000 [thread overview]
Message-ID: <20260922203702.BAE921F0089E@smtp.kernel.org> (raw)
In-Reply-To: <20260922200208.3203834-4-puranjay@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] bpf: bpf_call_rcu_tasks_trace() deadlock from NMI context
--
commit 47fa2f5e11782172e769349f78bd62857f9572eb
Author: Puranjay Mohan <puranjay@kernel.org>
bpf: Add bpf_call_rcu_tasks_trace() kfunc
This commit introduces the bpf_call_rcu_tasks_trace() kfunc to allow
sleepable BPF programs to safely defer reclaim using a tasks trace RCU
grace period. It shares verifier plumbing and struct bpf_rcu_head with
bpf_call_rcu(), differing only in the queueing call.
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -4872,13 +4861,50 @@ __bpf_kfunc int bpf_call_rcu(struct bpf_rcu_head *rh, void *map__const_map,
[ ... ]
> - rhk->callback_fn = (bpf_callback_t)(void *)callback;
> + rhk->callback_fn = (bpf_callback_t)callback;
> rhk->map = map;
> rhk->prog = prog;
> - call_rcu(&rhk->rcu, bpf_rcu_run_callback);
> + if (trace)
> + call_rcu_tasks_trace(&rhk->rcu, bpf_rcu_run_callback);
> + else
> + call_rcu(&rhk->rcu, bpf_rcu_run_callback);
> return 0;
> }
[Severity: High]
Can this sequence lead to a kernel deadlock if called from NMI context?
If a BPF tracing program executing in NMI context (or with IRQs disabled)
calls the bpf_call_rcu_tasks_trace() kfunc, it will unconditionally invoke
call_rcu_tasks_trace(), which is a wrapper for call_srcu().
Since call_srcu() requires acquiring a raw_spinlock_t (sdp->lock), if the
NMI interrupted a task on the same CPU that was already holding this
spinlock, the NMI handler will spin indefinitely attempting to acquire it.
Should this code defer call_rcu_tasks_trace() via irq_work_queue if
irqs_disabled() is true, similar to how it is handled in
bpf_async_refcount_put()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260922200208.3203834-1-puranjay@kernel.org?part=3
next prev parent reply other threads:[~2026-09-22 20:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 20:00 [PATCH bpf-next v6 0/4] bpf: Add bpf_call_rcu() and bpf_call_rcu_tasks_trace() Puranjay Mohan
2026-09-22 20:00 ` [PATCH bpf-next v6 1/4] bpf: Add bpf_call_rcu() kfunc Puranjay Mohan
2026-09-22 20:00 ` [PATCH bpf-next v6 2/4] selftests/bpf: Add tests for bpf_call_rcu() Puranjay Mohan
2026-09-22 20:00 ` [PATCH bpf-next v6 3/4] bpf: Add bpf_call_rcu_tasks_trace() kfunc Puranjay Mohan
2026-09-22 20:37 ` sashiko-bot [this message]
2026-09-22 20:00 ` [PATCH bpf-next v6 4/4] selftests/bpf: Add a test for bpf_call_rcu_tasks_trace() Puranjay Mohan
2026-09-22 23:41 ` [PATCH bpf-next v6 0/4] bpf: Add bpf_call_rcu() and bpf_call_rcu_tasks_trace() Andrii Nakryiko
2026-09-23 10:37 ` Puranjay Mohan
2026-09-23 11:29 ` Kumar Kartikeya Dwivedi
2026-09-23 16:45 ` Andrii Nakryiko
2026-09-23 16:53 ` Kumar Kartikeya Dwivedi
2026-09-23 16:59 ` Andrii Nakryiko
2026-09-23 17:57 ` Kumar Kartikeya Dwivedi
2026-09-23 18:21 ` Andrii Nakryiko
2026-09-23 18:30 ` Puranjay Mohan
2026-09-23 19:25 ` Andrii Nakryiko
2026-09-22 23:50 ` patchwork-bot+netdevbpf
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=20260922203702.BAE921F0089E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@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 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.