From: sashiko-bot@kernel.org
To: "Puranjay Mohan" <puranjay@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 3/4] bpf: Add bpf_call_rcu_tasks_trace() kfunc
Date: Mon, 21 Sep 2026 19:52:37 +0000 [thread overview]
Message-ID: <20260921195238.67BF41F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921191407.1742386-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 and corruption from NMI context
--
commit 7357eb51c5d591938af8ac0c27619c6dee0b07c7
Author: Puranjay Mohan <puranjay@kernel.org>
bpf: Add bpf_call_rcu_tasks_trace() kfunc
This commit adds a new bpf kfunc, bpf_call_rcu_tasks_trace(), to defer
reclaim until after an RCU tasks trace grace period. It is intended for
sleepable BPF programs and shares the backend __bpf_call_rcu() with
bpf_call_rcu().
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index 8a01dd4058a03..301b35bd85c8a 100644
> --- 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,
> return -EBADF;
> }
>
> - 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);
[Severity: High]
Can this branch cause a deadlock if called from NMI context?
A BPF program of type BPF_PROG_TYPE_PERF_EVENT executing in NMI context
could call bpf_call_rcu_tasks_trace(), which delegates to
call_rcu_tasks_trace() and ultimately call_srcu().
Since call_srcu() relies on acquiring a raw spinlock, could an NMI
interrupting a CPU already holding that lock lead to a guaranteed deadlock?
> + else
> + call_rcu(&rhk->rcu, bpf_rcu_run_callback);
[Severity: High]
Can this branch corrupt RCU callback lists if called from NMI context?
Similarly, bpf_call_rcu() delegates to call_rcu(), which modifies CPU-local
lists under local_irq_save(). Since local_irq_save() does not block NMIs,
could an NMI interrupting an existing call_rcu() on the same CPU result
in list corruption?
> return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921191407.1742386-1-puranjay@kernel.org?part=3
next prev parent reply other threads:[~2026-09-21 19:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 19:14 [PATCH bpf-next v5 0/4] bpf: Add bpf_call_rcu() and bpf_call_rcu_tasks_trace() Puranjay Mohan
2026-09-21 19:14 ` [PATCH bpf-next v5 1/4] bpf: Add bpf_call_rcu() kfunc Puranjay Mohan
2026-09-21 19:39 ` sashiko-bot
2026-09-21 20:33 ` bot+bpf-ci
2026-09-22 1:53 ` Alexei Starovoitov
2026-09-22 14:17 ` Puranjay Mohan
2026-09-22 18:35 ` Alexei Starovoitov
2026-09-22 19:09 ` Puranjay Mohan
2026-09-22 23:55 ` Paul E. McKenney
2026-09-21 19:14 ` [PATCH bpf-next v5 2/4] selftests/bpf: Add tests for bpf_call_rcu() Puranjay Mohan
2026-09-21 19:25 ` sashiko-bot
2026-09-21 19:14 ` [PATCH bpf-next v5 3/4] bpf: Add bpf_call_rcu_tasks_trace() kfunc Puranjay Mohan
2026-09-21 19:52 ` sashiko-bot [this message]
2026-09-21 20:18 ` bot+bpf-ci
2026-09-21 20:21 ` Puranjay Mohan
2026-09-21 19:14 ` [PATCH bpf-next v5 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=20260921195238.67BF41F000FF@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.