lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3f60cb6e-a36c-44b3-b80a-3a99d013e0a3@linux.dev>
Date: Tue, 2 Dec 2025 11:08:25 -0800
From: Ihor Solodrai <ihor.solodrai@...ux.dev>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
 Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
 Martin KaFai Lau <martin.lau@...ux.dev>, Eduard Zingerman
 <eddyz87@...il.com>, Song Liu <song@...nel.org>,
 Yonghong Song <yonghong.song@...ux.dev>,
 John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
 Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
 Jiri Olsa <jolsa@...nel.org>, Nathan Chancellor <nathan@...nel.org>,
 Nicolas Schier <nicolas.schier@...ux.dev>,
 Nick Desaulniers <nick.desaulniers+lkml@...il.com>,
 Bill Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>,
 Alan Maguire <alan.maguire@...cle.com>, Donglin Peng
 <dolinux.peng@...il.com>, bpf@...r.kernel.org, dwarves@...r.kernel.org,
 linux-kernel@...r.kernel.org, linux-kbuild@...r.kernel.org
Subject: Re: [PATCH bpf-next v2 3/4] resolve_btfids: introduce enum
 btf_id_kind

On 12/1/25 9:27 AM, Andrii Nakryiko wrote:
> On Thu, Nov 27, 2025 at 10:53 AM Ihor Solodrai <ihor.solodrai@...ux.dev> wrote:
>>
>> Instead of using multiple flags, make struct btf_id tagged with an
>> enum value indicating its kind in the context of resolve_btfids.
>>
>> Signed-off-by: Ihor Solodrai <ihor.solodrai@...ux.dev>
>> ---
>>  tools/bpf/resolve_btfids/main.c | 62 ++++++++++++++++++++++-----------
>>  1 file changed, 42 insertions(+), 20 deletions(-)
> 
> [...]
> 
>>
>> -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,11 @@ 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);
>> +       if (btf_id)
>> +               btf_id->kind = BTF_ID_KIND_SYM;
> 
> seeing this pattern repeated, wouldn't it make sense to just pass this
> kind to btf_id__add() and set it there?

I like the idea, because we could get rid the "unique" flag then.

But the btf_id__add() does not necessarily create a new struct, and so
if we pass the kind in, what do we do with existing objects?
Overwrite the kind? If not, do we check for a mismatch?

> 
>> +
>> +       return btf_id;
>>  }
>>
> 
> [...]
> 
>> @@ -643,7 +656,7 @@ static int id_patch(struct object *obj, struct btf_id *id)
>>         int i;
>>
>>         /* For set, set8, id->id may be 0 */
>> -       if (!id->id && !id->is_set && !id->is_set8) {
>> +       if (!id->id && id->kind == BTF_ID_KIND_SYM) {
> 
> nit: comment says the exception is specifically for SET and SET8, so I
> think checking for those two instead of for SYM (implying that only
> other possible options are set and set8) would be a bit more
> future-proof?

ok

> 
>>                 pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name);
>>                 warnings++;
>>         }
> 
> [...]


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ