From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf 1/2] bpf: Fix NULL-ptr-deref when dumping a key-less BTF hash map
Date: Fri, 28 Aug 2026 09:54:15 +0000 [thread overview]
Message-ID: <20260828095416.50FE61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828093142.179856-1-jiayuan.chen@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] btf_modifier_show dereferences NULL when a modifier resolves to a void type.
--
commit 36dc7c26f56375bd142801da1fcbc83e4a765c35
Author: Jiayuan Chen <jiayuan.chen@linux.dev>
bpf: Fix NULL-ptr-deref when dumping a key-less BTF hash map
This patch fixes a NULL pointer dereference in btf_type_show() that occurs
when dumping a key-less BTF hash map. It restores previous behavior by
rejecting key-less BTF in hash map check callbacks, and adds a NULL check
for void types in btf_type_show() to gracefully handle any other paths.
Reported-by: syzbot+37b56485bbbf90ad8489@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/6a8f4e88.27659fcc.2ceef7.0008.GAE@google.com/T/
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index da36d4b9d31ab..c32265dc4ae7e 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -8229,6 +8229,10 @@ static void btf_type_show(const struct btf *btf, u32 type_id, void *obj,
> memset(&show->state, 0, sizeof(show->state));
> memset(&show->obj, 0, sizeof(show->obj));
>
> + /* A void type (e.g. type_id 0) has no show op, don't deref NULL. */
> + if (!t || !btf_type_ops(t))
> + return;
> +
> btf_type_ops(t)->show(btf, t, type_id, obj, 0, show);
> }
[Severity: High]
This is a pre-existing issue, but does this fix need to be extended to
btf_modifier_show() as well?
If a user with BPF tracing privileges invokes the bpf_snprintf_btf() helper
with a btf_id of a modifier that points to void (e.g., const void),
btf_type_show() will see the modifier type and pass this check since
modifier_ops is not NULL.
Execution would then proceed to btf_modifier_show(), which strips the modifier
and resolves the underlying type to btf_void:
kernel/bpf/btf.c:btf_modifier_show() {
if (btf->resolved_ids)
t = btf_type_id_resolve(btf, &type_id);
else
t = btf_type_skip_modifiers(btf, type_id, NULL);
btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show);
}
Since btf_type_ops(t) for btf_void is NULL, wouldn't this unconditional call
result in an immediate NULL pointer dereference, bypassing the check added
here?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260828093142.179856-1-jiayuan.chen@linux.dev?part=1
next prev parent reply other threads:[~2026-08-28 9:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 9:31 [PATCH bpf 1/2] bpf: Fix NULL-ptr-deref when dumping a key-less BTF hash map Jiayuan Chen
2026-08-28 9:31 ` [PATCH bpf 2/2] selftests/bpf: Add test for " Jiayuan Chen
2026-08-28 10:17 ` bot+bpf-ci
2026-08-28 9:54 ` sashiko-bot [this message]
2026-08-28 10:51 ` [PATCH bpf 1/2] bpf: Fix NULL-ptr-deref when dumping a " Jiayuan Chen
2026-08-28 22:28 ` 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=20260828095416.50FE61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jiayuan.chen@linux.dev \
--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.