From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: bot+bpf-ci@kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
song@kernel.org, yonghong.song@linux.dev,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, nathan@kernel.org,
nicolas.schier@linux.dev, nick.desaulniers+lkml@gmail.com,
morbo@google.com, justinstitt@google.com
Cc: bpf@vger.kernel.org, dwarves@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
alan.maguire@oracle.com, dolinux.peng@gmail.com,
martin.lau@kernel.org, clm@meta.com
Subject: Re: [PATCH bpf-next v1 3/4] resolve_btfids: introduce enum btf_id_kind
Date: Wed, 26 Nov 2025 11:08:04 -0800 [thread overview]
Message-ID: <d91c8ccc-cf5f-4d50-9a8e-944f90e0401a@linux.dev> (raw)
In-Reply-To: <3d0b94b9fdd5150c136784b5e6904264e5fb09a00d8512e459ec6c3046ed9abb@mail.kernel.org>
On 11/25/25 6:09 PM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c
>> index b7b44e72e..7f5a9f7dd 100644
>> --- a/tools/bpf/resolve_btfids/main.c
>> +++ b/tools/bpf/resolve_btfids/main.c
>
> [ ... ]
>
>> @@ -260,26 +266,33 @@ static char *get_id(const char *prefix_end)
>> return id;
>> }
>>
>> -static struct btf_id *add_set(struct object *obj, char *name, bool is_set8)
>> +static struct btf_id *add_set(struct object *obj, char *name, enum btf_id_kind kind)
>> {
>> /*
>> * __BTF_ID__set__name
>> * name = ^
>> * id = ^
>> */
>> - char *id = name + (is_set8 ? sizeof(BTF_SET8 "__") : sizeof(BTF_SET "__")) - 1;
>> + int prefixlen = kind == BTF_ID_KIND_SET8 ? sizeof(BTF_SET8 "__") : sizeof(BTF_SET "__");
>> + char *id = name + prefixlen - 1;
>> int len = strlen(name);
>> + struct btf_id *btf_id;
>>
>> if (id >= name + len) {
>> pr_err("FAILED to parse set name: %s\n", name);
>> return NULL;
>> }
>>
>> - return btf_id__add(&obj->sets, id, true);
>> + btf_id = btf_id__add(&obj->sets, id, true);
>> + if (btf_id)
>> + btf_id->kind = kind;
>> +
>> + return btf_id;
>> }
>>
>> static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size)
>> {
>> + struct btf_id *btf_id;
>> char *id;
>>
>> id = get_id(name + size);
>> @@ -288,7 +301,10 @@ static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size)
>> return NULL;
>> }
>>
>> - return btf_id__add(root, id, false);
>> + btf_id = btf_id__add(root, id, false);
>> + btf_id->kind = BTF_ID_KIND_SYM;
> ^^^^
>
> Can add_symbol() dereference a NULL pointer here? The function
> btf_id__add() can return NULL on allocation failure (when zalloc fails),
> but the new code sets btf_id->kind before checking if btf_id is NULL.
>
> In contrast, add_set() checks for NULL before setting the kind field.
> Should add_symbol() do the same?
We pass unique=false to btf_id__add() and that means that it can only
return NULL if zalloc() fails, which is unlikely.
Checking for NULL here is little too defensive, but won't hurt.
>
>> +
>> + return btf_id;
>> }
>
> [ ... ]
>
>
> ---
> 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/19689674924
next prev parent reply other threads:[~2025-11-26 19:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 1:26 [PATCH bpf-next v1 0/4] resolve_btfids: Support for BTF modifications Ihor Solodrai
2025-11-26 1:26 ` [PATCH bpf-next v1 1/4] resolve_btfids: rename object btf field to btf_path Ihor Solodrai
2025-11-26 1:26 ` [PATCH bpf-next v1 2/4] resolve_btfids: factor out load_btf() Ihor Solodrai
2025-11-26 1:26 ` [PATCH bpf-next v1 3/4] resolve_btfids: introduce enum btf_id_kind Ihor Solodrai
2025-11-26 2:09 ` bot+bpf-ci
2025-11-26 19:08 ` Ihor Solodrai [this message]
2025-11-26 1:26 ` [PATCH bpf-next v1 4/4] resolve_btfids: change in-place update with raw binary output Ihor Solodrai
2025-11-26 4:46 ` Donglin Peng
2025-11-26 18:22 ` Ihor Solodrai
2025-11-26 18:32 ` Ihor Solodrai
2025-11-26 13:03 ` Donglin Peng
2025-11-26 19:13 ` Ihor Solodrai
2025-11-26 23:58 ` Ihor Solodrai
2025-11-26 12:36 ` [PATCH bpf-next v1 0/4] resolve_btfids: Support for BTF modifications Alan Maguire
2025-11-26 19:01 ` Ihor Solodrai
2025-12-02 12:56 ` Alan Maguire
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=d91c8ccc-cf5f-4d50-9a8e-944f90e0401a@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=dolinux.peng@gmail.com \
--cc=dwarves@vger.kernel.org \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=kpsingh@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=nicolas.schier@linux.dev \
--cc=sdf@fomichev.me \
--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