From: "Ömer Mete Kaya" <omermetekaya0@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net
Cc: john.fastabend@gmail.com, andrii@kernel.org, eddyz87@gmail.com,
memxor@gmail.com, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com,
ihor.solodrai@linux.dev, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Ömer Mete Kaya" <omermetekaya0@gmail.com>
Subject: [PATCH bpf] bpf: Fix uninitialized known_memory read in check_mem_reg()
Date: Mon, 28 Sep 2026 01:28:05 +0300 [thread overview]
Message-ID: <20260927223327.414912-1-omermetekaya0@gmail.com> (raw)
check_mem_reg() takes an optional bool *known_memory output parameter.
When the register is NULL, the function returns early via
mark_arg_precision() without setting *known_memory, leaving it
uninitialized.
The caller in check_func_arg() declares 'bool known_memory'
without initialization and reads it after check_mem_reg() returns:
bool known_memory;
err = check_mem_reg(..., &known_memory);
if (err < 0) {
if (known_memory)
...
}
If mark_arg_precision() returns a negative value and the register was
NULL, reading known_memory is undefined behavior. In practice only the
diagnostic message selection is affected.
Fix by setting *known_memory = false before returning in the NULL
register path, matching the intent that a NULL register does not
imply the memory region is known.
Fixes: 66e2727395dd ("bpf: Report Call Type Safety argument errors")
Signed-off-by: Ömer Mete Kaya <omermetekaya0@gmail.com>
---
kernel/bpf/verifier.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 535967fc5f12..2cc8a2778c5a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7652,8 +7652,11 @@ static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg
{
int size, err = 0;
- if (bpf_register_is_null(reg))
+ if (bpf_register_is_null(reg)) {
+ if (known_memory)
+ *known_memory = false;
return mark_arg_precision(env, argno);
+ }
if (known_memory)
*known_memory = true;
--
2.55.0
reply other threads:[~2026-09-27 22:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260927223327.414912-1-omermetekaya0@gmail.com \
--to=omermetekaya0@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.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®