From: sashiko-bot@kernel.org
To: "Puranjay Mohan" <puranjay@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/4] bpf: Add bpf_call_rcu() kfunc
Date: Mon, 07 Sep 2026 14:06:42 +0000 [thread overview]
Message-ID: <20260907140642.B02581F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907134552.1772405-2-puranjay@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling `bpf_call_rcu` from NMI context causes a raw spinlock deadlock because `call_rcu()` is not NMI-safe.
--
commit 3385037afe11a72dffbb6db99b4174626596c231
Author: Puranjay Mohan <puranjay@kernel.org>
bpf: Add bpf_call_rcu() kfunc
This commit adds a new bpf_call_rcu kfunc that allows BPF programs to defer
operations using RCU grace periods.
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
[ ... ]
> +__bpf_kfunc int bpf_call_rcu(struct bpf_rcu_head *rh, void *map__const_map,
> + bpf_rcu_callback_t callback, struct bpf_prog_aux *aux)
> +{
[ ... ]
> + rhk->callback_fn = (bpf_callback_t)(void *)callback;
> + rhk->map = map;
> + rhk->prog = prog;
> + call_rcu(&rhk->rcu, bpf_rcu_run_callback);
[Severity: High]
Does this code risk a raw spinlock deadlock if called from an NMI context?
Because bpf_call_rcu is exposed to tracing programs, it can be invoked from
NMI contexts, such as when a tracing program is attached to a perf event.
However, call_rcu acquires rcu_node raw spinlocks and is not NMI-safe. If
the NMI interrupts a path that already holds the same rcu_node lock, the
system will attempt to re-acquire the lock, resulting in a deadlock.
Should the verifier restrict this kfunc from being called in NMI contexts,
similar to how it uses btf_record_has_nmi_unsafe_fields for bpf_obj_drop?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260907134552.1772405-1-puranjay@kernel.org?part=1
next prev parent reply other threads:[~2026-09-07 14:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 13:45 [PATCH bpf-next 0/4] bpf: Add bpf_call_rcu() and bpf_call_rcu_tasks_trace() Puranjay Mohan
2026-09-07 13:45 ` [PATCH bpf-next 1/4] bpf: Add bpf_call_rcu() kfunc Puranjay Mohan
2026-09-07 14:06 ` sashiko-bot [this message]
2026-09-07 14:29 ` Puranjay Mohan
2026-09-08 0:19 ` Alexei Starovoitov
2026-09-08 12:22 ` Puranjay Mohan
2026-09-07 13:45 ` [PATCH bpf-next 2/4] selftests/bpf: Add tests for bpf_call_rcu() Puranjay Mohan
2026-09-07 13:58 ` sashiko-bot
2026-09-07 13:45 ` [PATCH bpf-next 3/4] bpf: Add bpf_call_rcu_tasks_trace() kfunc Puranjay Mohan
2026-09-07 13:45 ` [PATCH bpf-next 4/4] selftests/bpf: Add a test for bpf_call_rcu_tasks_trace() 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=20260907140642.B02581F00A3A@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.