BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anton Protopopov" <a.s.protopopov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH v1 bpf-next 02/18] bpf: Add a btf_id_set8_entry helper
Date: Fri, 06 Nov 2026 20:58:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-202267@kernel.org> (raw)
In-Reply-To: <20261106210314.1767267-2-a.s.protopopov@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] bpf: kfunc sets destruction on failure in
  btf_populate_kfunc_set() [1]
--

commit 0f99bfedbc98b8fbe7b7a25dd4038c3e714adb73
Author: Anton Protopopov <a.s.protopopov@gmail.com>

bpf: Add a btf_id_set8_entry helper

This commit names the element type of struct btf_id_set8 as struct
btf_id_set8_pair, introduces btf_id_set8_entry() to look up a pair, and
changes btf_id_set8_contains() to return a boolean.

> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 228b93d4f8c94..61d2df6776a99 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -9973,8 +9973,8 @@ static u32 *btf_kfunc_id_set_contains(const struct btf *btf,
>  				      enum btf_kfunc_hook hook,
>  				      u32 kfunc_btf_id)
>  {
> +	struct btf_id_set8_pair *pair;
>  	struct btf_id_set8 *set;
> -	u32 *id;
>  
>  	if (hook >= BTF_KFUNC_HOOK_MAX)
>  		return NULL;
> @@ -9983,11 +9983,10 @@ static u32 *btf_kfunc_id_set_contains(const struct btf *btf,
>  	set = btf->kfunc_set_tab->sets[hook];
>  	if (!set)
>  		return NULL;
> -	id = btf_id_set8_contains(set, kfunc_btf_id);
> -	if (!id)
> +	pair = btf_id_set8_entry(set, kfunc_btf_id);
> +	if (!pair)
>  		return NULL;
> -	/* The flags for BTF ID are located next to it */
> -	return id + 1;
> +	return &pair->flags;
>  }

[Severity: High]
This problem wasn't introduced by this patch, but in the paired
btf_populate_kfunc_set() function that populates btf->kfunc_set_tab, does an
error on a later registration destroy all previously registered kfunc sets
[1]?

kernel/bpf/btf.c:btf_populate_kfunc_set() {
    ...
	/* Grow set */
	set = krealloc(tab->sets[hook],
		       struct_size(set, pairs, set_cnt + add_set->cnt),
		       GFP_KERNEL | __GFP_NOWARN);
	if (!set) {
		ret = -ENOMEM;
		goto end;
	}
    ...
end:
	btf_free_kfunc_set_tab(btf);
	return ret;
}

Multiple subsystems register kfunc sets into the shared vmlinux BTF.  If a
later registration fails in krealloc() or exceeds BTF_KFUNC_SET_MAX_CNT,
jumping to end calls btf_free_kfunc_set_tab(), which frees every hook's set
and clears btf->kfunc_set_tab, breaking all previously registered kfuncs.

[1] https://sashiko.dev/#/bug/linux-1a311d3c-46c9-4fa6-a26e-40badcd832d8

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106205523.1765622-1-a.s.protopopov@gmail.com?part=2

  reply	other threads:[~2026-11-06 20:58 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 21:02 [PATCH v1 bpf-next 01/18] bpf: Add BTF ID sets for fmod_ret targets Anton Protopopov
2026-11-06 21:02 ` [PATCH v1 bpf-next 02/18] bpf: Add a btf_id_set8_entry helper Anton Protopopov
2026-11-06 20:58   ` sashiko-bot [this message]
2026-11-09 13:02     ` Anton Protopopov
2026-11-06 21:02 ` [PATCH v1 bpf-next 03/18] bpf: Build fmod_ret target sets from BTF decl tags Anton Protopopov
2026-11-06 21:02 ` [PATCH v1 bpf-next 04/18] selftests/bpf: Declare bpf_fentry_test1 in tracing tests Anton Protopopov
2026-11-06 21:02 ` [PATCH v1 bpf-next 05/18] bpf: Declare fmod_ret targets with BTF_FMODRET sets Anton Protopopov
2026-11-06 21:02 ` [PATCH v1 bpf-next 06/18] selftests/bpf: Test fmod_ret BTF decl tags and attach permission Anton Protopopov
2026-11-06 21:02 ` [PATCH v1 bpf-next 07/18] scripts: Add LLVM plugin infrastructure Anton Protopopov
2026-11-06 21:02 ` [PATCH v1 bpf-next 08/18] bpf: Add the bpf_scan_ir LLVM plugin Anton Protopopov
2026-11-06 21:02 ` [PATCH v1 bpf-next 09/18] bpf: Find fmod_ret candidates in bpf_scan_ir Anton Protopopov
2026-11-06 21:02 ` [PATCH v1 bpf-next 10/18] bpf: Allow writes to private stack objects " Anton Protopopov
2026-11-06 21:03 ` [PATCH v1 bpf-next 11/18] bpf: Follow PHIs " Anton Protopopov
2026-11-06 21:03 ` [PATCH v1 bpf-next 12/18] bpf: Follow integer casts " Anton Protopopov
2026-11-06 21:03 ` [PATCH v1 bpf-next 13/18] bpf: Check the return values of fmod_ret programs on found targets Anton Protopopov
2026-11-06 21:17   ` sashiko-bot
2026-11-09 13:14     ` Anton Protopopov
2026-11-09 13:16       ` Anton Protopopov
2026-11-06 21:03 ` [PATCH v1 bpf-next 14/18] bpf: Require the JIT for fmod_ret programs on found 64-bit targets Anton Protopopov
2026-11-06 21:03 ` [PATCH v1 bpf-next 15/18] resolve_btfids: Tag fmod_ret candidates as targets Anton Protopopov
2026-11-06 21:14   ` sashiko-bot
2026-11-09 13:26     ` Anton Protopopov
2026-11-06 21:50   ` bot+bpf-ci
2026-11-09 13:33     ` Anton Protopopov
2026-11-06 21:03 ` [PATCH v1 bpf-next 16/18] selftests/bpf: Test fmod_ret candidates found by bpf_scan_ir Anton Protopopov
2026-11-06 21:09   ` sashiko-bot
2026-11-09 14:09     ` Anton Protopopov
2026-11-06 21:50   ` bot+bpf-ci
2026-11-09 13:59     ` Anton Protopopov
2026-11-06 21:03 ` [PATCH v1 bpf-next 17/18] selftests/bpf: Enable bpf_scan_ir in the config Anton Protopopov
2026-11-06 21:35   ` bot+bpf-ci
2026-11-09 13:45     ` Anton Protopopov
2026-11-06 21:03 ` [PATCH v1 bpf-next 18/18] bpftool: List and show fmod_ret targets Anton Protopopov
2026-11-06 21:35   ` bot+bpf-ci
2026-11-09 13:40     ` Anton Protopopov
2026-11-09 17:02 ` [PATCH v1 bpf-next 01/18] bpf: Add BTF ID sets for " Anton Protopopov

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=sashiko-outbox-202267@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=a.s.protopopov@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox