From: bot+bpf-ci@kernel.org
To: ethantidmore06@gmail.com,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,ameryhung@gmail.com,bpf@vger.kernel.org,linux-kernel@vger.kernel.org
Cc: john.fastabend@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,ethantidmore06@gmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH] bpf: Fix signedness bug
Date: Sat, 6 Jun 2026 03:25:39 +0000 (UTC) [thread overview]
Message-ID: <86b976f32a179141dbeb3eed5fa106f18f2e46b5c6849ca2c800484847d1deb7@mail.kernel.org> (raw)
In-Reply-To: <20260606024540.47362-1-ethantidmore06@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2840 bytes --]
> commit cc27f12c12ff54b8eace339c3e130317bf205277
> Author: Ethan Tidmore <ethantidmore06@gmail.com>
>
> bpf: Fix signedness bug
>
> The function acquire_reference() returns negative error codes and 'id'
> is an unsigned integer, so the check (id < 0) is always impossible.
Is this commit message accurate? Looking at check_kfunc_call() in
kernel/bpf/verifier.c, the variable 'id' is declared as a signed int:
const struct btf_param *args;
u32 i, nargs, ptr_type_id;
struct btf *desc_btf;
int id;
Since acquire_reference() can return negative error codes like -ENOMEM,
wouldn't the original check (id < 0) work correctly?
The three other call sites of acquire_reference() in the verifier all use
the same signed-int pattern without issue:
verifier.c:mark_stack_slots_dynptr():
id = acquire_reference(env, insn_idx, dynptr_id);
if (id < 0)
return id;
verifier.c:mark_stack_slots_iter():
id = acquire_reference(env, insn_idx, ITER_TYPE_TO_ID(iter_type));
if (id < 0)
return id;
verifier.c:check_helper_call():
id = acquire_reference(env, insn_idx, fn->arg_type[arg_num]);
if (id < 0)
return id;
It looks like the Smatch warning might be a false positive, and the original
code was already handling the error properly.
>
> Detected by Smatch:
> kernel/bpf/verifier.c:13115 check_kfunc_call()
> warn: unsigned 'id' is never less than zero.
>
> Fixes: 308c7a0ae8859 ("bpf: Refactor object relationship tracking and fix dynptr UAF bug")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 935595138aa0..be528a0be13c 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -13167,9 +13167,11 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
> }
> mark_btf_func_reg_size(env, BPF_REG_0, sizeof(void *));
> if (is_kfunc_acquire(&meta)) {
> - id = acquire_reference(env, insn_idx, 0);
> - if (id < 0)
> - return id;
> + err = acquire_reference(env, insn_idx, 0);
> + if (err < 0)
> + return err;
> + id = err;
> +
> regs[BPF_REG_0].id = id;
> } else if (is_rbtree_node_type(ptr_type) || is_list_node_type(ptr_type)) {
> ref_set_non_owning(env, ®s[BPF_REG_0]);
The code change itself is behavior-equivalent since 'err' is also a signed
int, so the patch doesn't introduce a runtime regression. But if the premise
that 'id' is unsigned is wrong, should the commit message be corrected?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/27050796130
next prev parent reply other threads:[~2026-06-06 3:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-06 2:45 Ethan Tidmore
2026-06-06 3:25 ` bot+bpf-ci [this message]
2026-06-06 3:30 ` Amery Hung
2026-06-06 3:31 ` Ethan Tidmore
2026-06-06 3:50 ` Amery Hung
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=86b976f32a179141dbeb3eed5fa106f18f2e46b5c6849ca2c800484847d1deb7@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ethantidmore06@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=yonghong.song@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
all inboxes | Powered by JetHome®