From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: <sashiko-reviews@lists.linux.dev>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next v1 1/2] bpf: Allow bpf_res_spin_lock() in all contexts
Date: Sun, 19 Jul 2026 14:02:04 +0200 [thread overview]
Message-ID: <DK2J66UJL9Y2.1CFPFRV92X1S5@gmail.com> (raw)
In-Reply-To: <20260719115625.B498D1F000E9@smtp.kernel.org>
On Sun Jul 19, 2026 at 1:56 PM CEST, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>
> New issues:
> - [Medium] bpf_res_spin_lock() remains disabled for socket filter programs, contradicting the commit title 'Allow bpf_res_spin_lock() in all contexts'.
>
> Pre-existing issues:
> - [High] When parsing BTF fields, the check for a valid `bpf_res_spin_lock` offset incorrectly checks `rec->spin_lock_off` instead of `rec->res_spin_lock_off`.
> --
>
> --- Patch [1]: [PATCH bpf-next v1 1/2] bpf: Allow bpf_res_spin_lock() in all contexts ---
> commit 88a844e18ff8ff22c90389d929ce1c63353b73fe
> Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>
>
> bpf: Allow bpf_res_spin_lock() in all contexts
>
> This commit removes the restriction that prevents tracing programs from
> using bpf_res_spin_lock(). The stated goal is to allow its use in all
> contexts.
>
>> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
>> index 4446f0bde88b5..bb6e16668d0d1 100644
>> --- a/kernel/bpf/verifier.c
>> +++ b/kernel/bpf/verifier.c
>> @@ -17815,7 +17815,9 @@ static int check_map_prog_compatibility(struct bpf_verifier_env *env,
>> verbose(env, "socket filter progs cannot use bpf_spin_lock yet\n");
>> return -EINVAL;
>> }
>> + }
>
> [Severity: Medium]
> The commit message states the goal is to allow bpf_res_spin_lock() in all
> contexts. However, just above this block in check_map_prog_compatibility(),
> there is a check that still blocks it:
>
> if (btf_record_has_field(map->record, BPF_SPIN_LOCK | BPF_RES_SPIN_LOCK)) {
> if (prog_type == BPF_PROG_TYPE_SOCKET_FILTER) {
>
> Does this contradict the commit title by leaving it disabled for socket
> filter programs?
>
We don't want to enable it for socket filter.
>>
>> + if (btf_record_has_field(map->record, BPF_SPIN_LOCK)) {
>> if (is_tracing_prog_type(prog_type)) {
>> verbose(env, "tracing progs cannot use bpf_spin_lock yet\n");
>> return -EINVAL;
>
>
> While reviewing this area, I also noticed a potential issue in another file.
>
> kernel/bpf/btf.c:btf_parse_fields() {
> ...
> case BPF_RES_SPIN_LOCK:
> WARN_ON_ONCE(rec->spin_lock_off >= 0);
> /* Cache offset for faster lookup at runtime */
> rec->res_spin_lock_off = rec->fields[i].offset;
> break;
> ...
> }
>
> [Severity: High]
> This is a pre-existing issue, but does this WARN_ON_ONCE() incorrectly check
> rec->spin_lock_off instead of rec->res_spin_lock_off?
>
> If a user creates a BPF map value containing both a bpf_spin_lock and a
> bpf_res_spin_lock, and BPF_SPIN_LOCK is parsed first, rec->spin_lock_off will
> be non-negative. When BPF_RES_SPIN_LOCK is then processed, it appears this
> would trivially trigger the warning, which could cause a kernel panic if
> panic_on_warn is enabled.
Yeah, it's not that serious, but will fix when I respin (or follow up separately).
That said, for now, I will wait for more reviews.
next prev parent reply other threads:[~2026-07-19 12:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-19 11:35 [PATCH bpf-next v1 0/2] Open up res_spin_lock for tracing programs, fix is_tracing_prog_type() Kumar Kartikeya Dwivedi
2026-07-19 11:35 ` [PATCH bpf-next v1 1/2] bpf: Allow bpf_res_spin_lock() in all contexts Kumar Kartikeya Dwivedi
2026-07-19 11:56 ` sashiko-bot
2026-07-19 12:02 ` Kumar Kartikeya Dwivedi [this message]
2026-07-20 22:00 ` Emil Tsalapatis
2026-07-21 17:53 ` Eduard Zingerman
2026-07-19 11:35 ` [PATCH bpf-next v1 2/2] bpf: Fix is_tracing_prog_type() to cover fentry/fexit/fmod_ret Kumar Kartikeya Dwivedi
2026-07-19 14:09 ` sashiko-bot
2026-07-19 14:12 ` Kumar Kartikeya Dwivedi
2026-07-20 22:40 ` Emil Tsalapatis
2026-07-21 18:26 ` Eduard Zingerman
-- strict thread matches above, loose matches on Subject: below --
2026-07-24 20:16 [PATCH bpf-next v1 0/2] Open up res_spin_lock() in all contexts Kumar Kartikeya Dwivedi
2026-07-24 20:16 ` [PATCH bpf-next v1 1/2] bpf: Allow bpf_res_spin_lock() " Kumar Kartikeya Dwivedi
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=DK2J66UJL9Y2.1CFPFRV92X1S5@gmail.com \
--to=memxor@gmail.com \
--cc=bpf@vger.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