From: sashiko-bot@kernel.org
To: "Ethan Tidmore" <ethantidmore06@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH] bpf: Fix signedness bug
Date: Sat, 06 Jun 2026 03:02:06 +0000 [thread overview]
Message-ID: <20260606030207.1ED451F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260606024540.47362-1-ethantidmore06@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit message falsely claims that the variable 'id' is an unsigned integer, making the error check `(id < 0)` impossible. This claim is demonstrably incorrect; 'id' is declared as a signed integer, meaning the patch fixes a non-existent bug.
--
commit c4f0a14bac5d07880856111e136127510f48012c
Author: Ethan Tidmore <ethantidmore06@gmail.com>
bpf: Fix signedness bug
This commit refactors the error handling for acquire_reference() by using a
separate err variable, claiming that the id variable is unsigned and cannot
be checked for negative error codes.
> The function acquire_reference() returns negative error codes and 'id'
> is an unsigned integer, so the check (id < 0) is always impossible.
>
> Detected by Smatch:
> kernel/bpf/verifier.c:13115 check_kfunc_call()
> warn: unsigned 'id' is never less than zero.
[Severity: Medium]
Is this description accurate? Looking at check_kfunc_call(), id appears to
be explicitly declared as a signed int, not an unsigned integer.
Since acquire_reference() can return negative error codes like -ENOMEM,
wouldn't the original check (id < 0) work correctly?
It looks like the Smatch warning might be a false positive, and the original
code was already handling the error properly.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 935595138aa01..be528a0be13cd 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;
[Severity: Medium]
Is this change necessary? If id is actually a signed int, the original code
would have properly caught the negative error returns from
acquire_reference() without needing to introduce the err variable.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260606024540.47362-1-ethantidmore06@gmail.com?part=1
next prev parent reply other threads:[~2026-06-06 3:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-06 2:45 [PATCH] bpf: Fix signedness bug Ethan Tidmore
2026-06-06 3:02 ` sashiko-bot [this message]
2026-06-06 3:25 ` bot+bpf-ci
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=20260606030207.1ED451F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=ethantidmore06@gmail.com \
--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