All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: sashiko-reviews@lists.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 18:51:32 +0800	[thread overview]
Message-ID: <8b3e7f24-795d-458b-a24e-fe154b0cf03d@linux.dev> (raw)
In-Reply-To: <20260828095416.50FE61F000E9@smtp.kernel.org>


on 8/28/26 5:54 PM, sashiko-bot@kernel.org wrote:
> 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.


Right, good catch. Passing a "const void" type_id to bpf_snprintf_btf() 
resolves to

void in btf_modifier_show() and hits the same NULL deref, which the 
check here does not cover.

Shoud I add the fix in this patchset since they are all about "show" 
semantics‌?



  reply	other threads:[~2026-08-28 10:51 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 ` [PATCH bpf 1/2] bpf: Fix NULL-ptr-deref when dumping a " sashiko-bot
2026-08-28 10:51   ` Jiayuan Chen [this message]
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=8b3e7f24-795d-458b-a24e-fe154b0cf03d@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --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 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.