AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/11/30 04:23 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "All modifications in this patch are confined to Documentation/ (Documentation/bpf/kfuncs.rst), userspace tools and libraries (tools/bpf/bpftool/, tools/lib/bpf/, tools/sched_ext/include/scx/compat.bpf.h), the host build-time tool tools/bpf/resolve_btfids/ (which only adds a compile-time kfunc variant check without altering generated kernel BTF or .BTF_ids), and BPF selftests (tools/testing/selftests/bpf/). None of the changes modify vmlinux or kernel modules, so there is no reachable kernel code to fuzz.",
  "WorthFuzzing": false
}

1/1 2026/11/30 04:23 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit c918ffdc779ecff1e985a97d2947f4f8d59b94c5\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Mon Nov 30 04:23:13 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst\nindex 335dbb833bfe43..caaa6973133938 100644\n--- a/Documentation/bpf/kfuncs.rst\n+++ b/Documentation/bpf/kfuncs.rst\n@@ -800,6 +800,105 @@ procedure is followed for removal:\n 3. After the deprecation period the kfunc will be removed. At this point, BPF\n    programs calling the kfunc will be rejected by the verifier.\n \n+3.2 Changing a kfunc's prototype\n+--------------------------------\n+\n+libbpf drops the last ``___suffix`` from the name of a kfunc declared in a BPF\n+program and from the names of functions in kernel and module BTF, as it does\n+for CO-RE type names. Among the functions with the same remaining name, it\n+binds the one with a prototype that matches the declaration. Types are\n+compared kind by kind, and structs and unions by name only:\n+\n+.. code-block:: c\n+\n+\ttypedef struct task_struct task_t;\n+\n+\t/* these match */\n+\tint bpf_foo(struct task_struct *p, u32 flags);\n+\tint bpf_foo(const task_t *p, u64 flags);\n+\tint bpf_foo(struct task_struct___local *p, int flags);\n+\n+\t/* none of these match the ones above */\n+\tint bpf_foo(struct file *p, u32 flags);\n+\tint bpf_foo(struct task_struct *p);\n+\tvoid bpf_foo(struct task_struct *p, u32 flags);\n+\n+If the old and new prototypes match, change the kfunc in place. Otherwise the\n+new prototype keeps the name, and the old one stays available as\n+``\u003cname\u003e___v1`` (``___v2`` for the next change, and so on) for a deprecation\n+period, usually as a thin wrapper registered with the same flags:\n+\n+.. code-block:: c\n+\n+\t__bpf_kfunc int bpf_foo(struct task_struct *p, u64 flags)\n+\t{\n+\t\t...\n+\t}\n+\n+\t/* bpf_foo() before flags was added */\n+\t__bpf_kfunc int bpf_foo___v1(struct task_struct *p)\n+\t{\n+\t\treturn bpf_foo(p, 0);\n+\t}\n+\n+\tBTF_ID_FLAGS(func, bpf_foo, KF_RCU)\n+\tBTF_ID_FLAGS(func, bpf_foo___v1, KF_RCU)\n+\n+BPF programs built against either prototype then load:\n+\n+.. code-block:: c\n+\n+\t/* built against the old prototype: binds bpf_foo___v1 */\n+\textern int bpf_foo(struct task_struct *p) __ksym;\n+\n+\t/* built against the new prototype: binds bpf_foo */\n+\textern int bpf_foo(struct task_struct *p, u64 flags) __ksym;\n+\n+\t/* the suffix doesn't select a kfunc: both bind bpf_foo___v1 */\n+\textern int bpf_foo___v1(struct task_struct *p) __ksym;\n+\textern int bpf_foo___local(struct task_struct *p) __ksym;\n+\n+\t/* a stacked suffix binds nothing */\n+\textern int bpf_foo___v1___local(struct task_struct *p) __ksym;\n+\n+Only libbpf 1.9 and later look for ``bpf_foo___v1`` when resolving ``bpf_foo``.\n+Older libbpf and light skeletons see only ``bpf_foo``, as after an in-place\n+change.\n+\n+If two kfunc names differ only in the ``___`` suffix, their prototypes must not\n+match, not even for aliases: libbpf can't tell them apart and fails to load a\n+program that declares either one, even as ``__weak``. For example, this widens\n+an offset to 64 bits and keeps the old prototype as ``bpf_bar___v1``:\n+\n+.. code-block:: c\n+\n+\t__bpf_kfunc int bpf_bar(const struct bpf_dynptr *p, u64 offset);\n+\n+\t/* bpf_bar() before offset was widened */\n+\t__bpf_kfunc int bpf_bar___v1(const struct bpf_dynptr *p, u32 offset);\n+\n+``resolve_btfids`` rejects it::\n+\n+\tERROR: resolve_btfids: kfuncs bpf_bar and bpf_bar___v1 have matching prototypes\n+\n+Widening keeps the prototype matching, so it is done in place instead: drop\n+``bpf_bar___v1``, and programs built against the old prototype bind\n+``bpf_bar``. ``resolve_btfids`` checks registered kfuncs within vmlinux or one\n+module. libbpf catches other matches, such as between two modules, when loading\n+the program.\n+\n+Give the new prototype a name outside the family, not ``\u003cname\u003e___*``, if:\n+\n+- programs loaded by older libbpf or light skeletons must keep working, or\n+- the prototypes match but the change breaks callers, e.g. two integer\n+  parameters swap places.\n+\n+Older libbpf resolves ``bpf_foo___v1`` only from a declaration with a stacked\n+suffix, such as ``bpf_foo___v1___compat``, and light skeletons only from\n+``bpf_foo___v1`` itself. Don't rename a ``\u003cname\u003e___vN`` kfunc while programs\n+declaring it that way are in use. libbpf 1.9 and later bind by prototype, so a\n+rename doesn't affect them.\n+\n 4. Core kfuncs\n ==============\n \ndiff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile\nindex 49dabf2eded04d..ded4a9e797281e 100644\n--- a/tools/bpf/bpftool/Makefile\n+++ b/tools/bpf/bpftool/Makefile\n@@ -28,10 +28,10 @@ LIBBPF_BOOTSTRAP_INCLUDE := $(LIBBPF_BOOTSTRAP_DESTDIR)include\n LIBBPF_BOOTSTRAP_HDRS_DIR := $(LIBBPF_BOOTSTRAP_INCLUDE)/bpf\n LIBBPF_BOOTSTRAP := $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a\n \n-# We need to copy hashmap.h, nlattr.h, relo_core.h and libbpf_internal.h\n+# We need to copy hashmap.h, nlattr.h, relo_core.h and libbpf_tools.h\n # which are not otherwise exported by libbpf, but still required by bpftool.\n-LIBBPF_INTERNAL_HDRS := $(addprefix $(LIBBPF_HDRS_DIR)/,hashmap.h nlattr.h relo_core.h libbpf_internal.h)\n-LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hashmap.h relo_core.h libbpf_internal.h)\n+LIBBPF_INTERNAL_HDRS := $(addprefix $(LIBBPF_HDRS_DIR)/,hashmap.h nlattr.h relo_core.h libbpf_tools.h)\n+LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hashmap.h relo_core.h libbpf_tools.h)\n \n $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR) $(LIBBPF_BOOTSTRAP_HDRS_DIR):\n \t$(QUIET_MKDIR)mkdir -p $@\ndiff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c\nindex ca5fa2f0bf9b14..1f2099c17252a4 100644\n--- a/tools/bpf/bpftool/common.c\n+++ b/tools/bpf/bpftool/common.c\n@@ -31,7 +31,7 @@\n #include \u003cbpf/bpf.h\u003e\n #include \u003cbpf/hashmap.h\u003e\n #include \u003cbpf/libbpf.h\u003e /* libbpf_num_possible_cpus */\n-#include \u003cbpf/libbpf_internal.h\u003e\n+#include \u003cbpf/libbpf_tools.h\u003e\n #include \u003cbpf/btf.h\u003e\n #include \u003czlib.h\u003e\n \ndiff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c\nindex ee680f7c211602..dc0adeacf9a812 100644\n--- a/tools/bpf/bpftool/gen.c\n+++ b/tools/bpf/bpftool/gen.c\n@@ -15,7 +15,8 @@\n #include \u003cunistd.h\u003e\n #include \u003cbpf/bpf.h\u003e\n #include \u003cbpf/libbpf.h\u003e\n-#include \u003cbpf/libbpf_internal.h\u003e\n+#include \u003cbpf/libbpf_tools.h\u003e\n+#include \u003cbpf/relo_core.h\u003e\n #include \u003csys/types.h\u003e\n #include \u003csys/stat.h\u003e\n #include \u003csys/mman.h\u003e\ndiff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c\nindex 15efc6eebffb1b..a7b2ea9fbd8072 100644\n--- a/tools/bpf/bpftool/prog.c\n+++ b/tools/bpf/bpftool/prog.c\n@@ -29,7 +29,7 @@\n #include \u003cbpf/btf.h\u003e\n #include \u003cbpf/hashmap.h\u003e\n #include \u003cbpf/libbpf.h\u003e\n-#include \u003cbpf/libbpf_internal.h\u003e\n+#include \u003cbpf/libbpf_tools.h\u003e\n #include \u003cbpf/skel_internal.h\u003e\n \n #include \"cfg.h\"\ndiff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c\nindex 5579173a61e3b5..fc83785c0ae3a1 100644\n--- a/tools/bpf/bpftool/xlated_dumper.c\n+++ b/tools/bpf/bpftool/xlated_dumper.c\n@@ -10,7 +10,7 @@\n #include \u003cstring.h\u003e\n #include \u003csys/types.h\u003e\n #include \u003cbpf/libbpf.h\u003e\n-#include \u003cbpf/libbpf_internal.h\u003e\n+#include \u003cbpf/libbpf_tools.h\u003e\n \n #include \"disasm.h\"\n #include \"json_writer.h\"\ndiff --git a/tools/bpf/resolve_btfids/btf_colors.c b/tools/bpf/resolve_btfids/btf_colors.c\nindex 5d307d70e7f220..7374aa2f8963fd 100644\n--- a/tools/bpf/resolve_btfids/btf_colors.c\n+++ b/tools/bpf/resolve_btfids/btf_colors.c\n@@ -1,18 +1,9 @@\n // SPDX-License-Identifier: GPL-2.0-only\n-#include \u003cbpf/libbpf_internal.h\u003e\n+#include \u003cerrno.h\u003e\n+#include \u003cstdlib.h\u003e\n+#include \u003cbpf/libbpf_tools.h\u003e\n #include \"btf_colors.h\"\n \n-/*\n- * Functions in this file mainly exist to refer to functions from libbpf_internal.h,\n- * which can't be included in main.c because of the u32 poison and pr_warn macro conflicts.\n- */\n-\n-void btf_sha256(const void *data, size_t len,\n-\t\t__u8 out[BTF_SHA256_DIGEST_LENGTH])\n-{\n-\tlibbpf_sha256(data, len, out);\n-}\n-\n /*\n  * Marks `root_id` and local types reachable from it with `color`.\n  * `colors` is indexed by source ID; worklist has room for every local type.\ndiff --git a/tools/bpf/resolve_btfids/btf_colors.h b/tools/bpf/resolve_btfids/btf_colors.h\nindex 56a85a242d6bdc..9cea757cb356ec 100644\n--- a/tools/bpf/resolve_btfids/btf_colors.h\n+++ b/tools/bpf/resolve_btfids/btf_colors.h\n@@ -11,10 +11,6 @@ enum btf_color {\n \tBTF_COLOR_SHARED = BTF_COLOR_MAIN | BTF_COLOR_LOC,\n };\n \n-#define BTF_SHA256_DIGEST_LENGTH\t32\n-\n-void btf_sha256(const void *data, size_t len,\n-\t\t__u8 out[BTF_SHA256_DIGEST_LENGTH]);\n void btf_mark_reachable(struct btf *btf, __u32 root, enum btf_color color,\n \t\t\t__u8 *colors, __u32 *worklist);\n \ndiff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c\nindex 0ac895222a1407..e21ac684387309 100644\n--- a/tools/bpf/resolve_btfids/main.c\n+++ b/tools/bpf/resolve_btfids/main.c\n@@ -93,12 +93,15 @@\n #include \u003clinux/limits.h\u003e\n #include \u003cbpf/btf.h\u003e\n #include \u003cbpf/libbpf.h\u003e\n+#include \u003cbpf/libbpf_tools.h\u003e\n+#include \u003cbpf/relo_core.h\u003e\n #include \"btf_colors.h\"\n #include \"fmodret.h\"\n #include \u003csubcmd/parse-options.h\u003e\n \n #define BTF_IDS_SECTION\t\".BTF_ids\"\n #define BTF_LINK_MODULE_NAME_MAX\t64\n+#define BTF_SHA256_DIGEST_LENGTH\tSHA256_DIGEST_LENGTH\n #define BTF_ID_PREFIX\t\"__BTF_ID__\"\n \n #define BTF_STRUCT\t\"struct\"\n@@ -1205,8 +1208,7 @@ static int patch_btf_link(struct object *obj, const struct btf_link *link)\n \t}\n \tmemset(data-\u003ed_buf, 0, data-\u003ed_size);\n \tmemcpy(data-\u003ed_buf, link-\u003emodule, strlen(link-\u003emodule) + 1);\n-\tbtf_sha256(raw_btf_data, raw_btf_size,\n-\t\t   (u8 *)data-\u003ed_buf + module_name_len);\n+\tlibbpf_sha256(raw_btf_data, raw_btf_size, (u8 *)data-\u003ed_buf + module_name_len);\n \tsize = (u8 *)data-\u003ed_buf + module_name_len + BTF_SHA256_DIGEST_LENGTH;\n \tif (obj-\u003eefile.encoding == ELFDATA2LSB) {\n \t\tsize[0] = raw_btf_size;\n@@ -1917,6 +1919,70 @@ static int sort_btf_by_name(struct btf *btf)\n \treturn err;\n }\n \n+struct kfunc_variant {\n+\tconst char *name;\n+\tsize_t essent_len;\n+\tu32 id;\n+};\n+\n+static int cmp_kfunc_variants(const void *lhs, const void *rhs)\n+{\n+\tconst struct kfunc_variant *a = lhs, *b = rhs;\n+\tint ret = strncmp(a-\u003ename, b-\u003ename, min(a-\u003eessent_len, b-\u003eessent_len));\n+\n+\treturn ret ?: (a-\u003eessent_len \u003e b-\u003eessent_len) - (a-\u003eessent_len \u003c b-\u003eessent_len);\n+}\n+\n+/* libbpf rejects a declaration that matches more than one kfunc variant */\n+static int check_kfunc_variants(const struct btf *btf)\n+{\n+\tconst struct btf *base = btf__base_btf(btf);\n+\tstruct kfunc_variant *kfuncs = NULL;\n+\tu32 cnt = 0, cap = 0;\n+\tint err = 0;\n+\n+\tfor (u32 id = base ? btf__type_cnt(base) : 1; id \u003c btf__type_cnt(btf); id++) {\n+\t\tconst struct btf_type *t = btf__type_by_id(btf, id);\n+\t\tconst char *name;\n+\n+\t\tif (!btf_is_decl_tag(t) || btf_decl_tag(t)-\u003ecomponent_idx != -1)\n+\t\t\tcontinue;\n+\t\tif (strcmp(btf__name_by_offset(btf, t-\u003ename_off), DECL_TAG_KFUNC) != 0)\n+\t\t\tcontinue;\n+\n+\t\terr = ensure_mem(\u0026kfuncs, \u0026cap, cnt + 1);\n+\t\tif (err)\n+\t\t\tgoto out;\n+\t\tname = btf__name_by_offset(btf, btf__type_by_id(btf, t-\u003etype)-\u003ename_off);\n+\t\tkfuncs[cnt++] = (struct kfunc_variant){\n+\t\t\t.name = name,\n+\t\t\t.essent_len = bpf_core_essential_name_len(name),\n+\t\t\t.id = t-\u003etype,\n+\t\t};\n+\t}\n+\tqsort(kfuncs, cnt, sizeof(*kfuncs), cmp_kfunc_variants);\n+\n+\tfor (u32 i = 0; i \u003c cnt; i++) {\n+\t\tconst struct btf_type *a = btf__type_by_id(btf, kfuncs[i].id);\n+\n+\t\tfor (u32 j = i + 1; j \u003c cnt; j++) {\n+\t\t\tconst struct btf_type *b;\n+\n+\t\t\tif (cmp_kfunc_variants(\u0026kfuncs[i], \u0026kfuncs[j]) != 0)\n+\t\t\t\tbreak;\n+\t\t\tb = btf__type_by_id(btf, kfuncs[j].id);\n+\t\t\tif (btf_kfunc_proto_match(btf, a-\u003etype, btf, b-\u003etype) \u003c= 0)\n+\t\t\t\tcontinue;\n+\t\t\tpr_err(\"ERROR: resolve_btfids: kfuncs %s and %s have matching prototypes\\n\",\n+\t\t\t       kfuncs[i].name, kfuncs[j].name);\n+\t\t\terr = -EINVAL;\n+\t\t}\n+\t}\n+out:\n+\tfree(kfuncs);\n+\treturn err;\n+}\n+\n static int finalize_btf(struct object *obj)\n {\n \tstruct btf *base_btf = obj-\u003ebase_btf, *btf = obj-\u003ebtf;\n@@ -1928,6 +1994,10 @@ static int finalize_btf(struct object *obj)\n \t\treturn err;\n \t}\n \n+\terr = check_kfunc_variants(obj-\u003ebtf);\n+\tif (err)\n+\t\treturn err;\n+\n \tif (obj-\u003ebase_btf \u0026\u0026 obj-\u003edistill_base) {\n \t\terr = btf__distill_base(obj-\u003ebtf, \u0026base_btf, \u0026btf);\n \t\tif (err) {\ndiff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c\nindex a4bf01403a4338..71cba0b9bbfec0 100644\n--- a/tools/lib/bpf/btf.c\n+++ b/tools/lib/bpf/btf.c\n@@ -1140,7 +1140,7 @@ static void btf_check_sorted(struct btf *btf)\n }\n \n static __s32 btf_find_type_by_name_bsearch(const struct btf *btf, const char *name,\n-\t\t\t\t\t   __s32 start_id)\n+\t\t\t\t\t   size_t name_len, __s32 start_id)\n {\n \tconst struct btf_type *t;\n \tconst char *tname;\n@@ -1152,7 +1152,7 @@ static __s32 btf_find_type_by_name_bsearch(const struct btf *btf, const char *na\n \t\tm = l + (r - l) / 2;\n \t\tt = btf_type_by_id(btf, m);\n \t\ttname = btf__str_by_offset(btf, t-\u003ename_off);\n-\t\tif (strcmp(tname, name) \u003e= 0) {\n+\t\tif (strncmp(tname, name, name_len) \u003e= 0) {\n \t\t\tif (l == r)\n \t\t\t\treturn r;\n \t\t\tr = m;\n@@ -1164,6 +1164,99 @@ static __s32 btf_find_type_by_name_bsearch(const struct btf *btf, const char *na\n \treturn btf__type_cnt(btf);\n }\n \n+/*\n+ * Set [*start, *end) to the range of own type IDs that may match the\n+ * first name_len bytes of name. For unsorted BTF, include all own type IDs.\n+ */\n+void btf_name_prefix_range(const struct btf *btf, const char *name, size_t name_len,\n+\t\t\t   __u32 *start, __u32 *end)\n+{\n+\t__u32 i, n = btf__type_cnt(btf);\n+\n+\tif (btf-\u003enamed_start_id \u003c= 0) {\n+\t\t*start = btf-\u003estart_id;\n+\t\t*end = n;\n+\t\treturn;\n+\t}\n+\t*start = btf_find_type_by_name_bsearch(btf, name, name_len, btf-\u003enamed_start_id);\n+\tfor (i = *start; i \u003c n; i++) {\n+\t\tconst struct btf_type *t = btf_type_by_id(btf, i);\n+\t\tconst char *tname = btf__str_by_offset(btf, t-\u003ename_off);\n+\n+\t\tif (strncmp(tname, name, name_len) != 0)\n+\t\t\tbreak;\n+\t}\n+\t*end = i;\n+}\n+\n+static __u16 kfunc_type_kind(const struct btf_type *t)\n+{\n+\tif (btf_is_fwd(t))\n+\t\treturn btf_kflag(t) ? BTF_KIND_UNION : BTF_KIND_STRUCT;\n+\tif (btf_is_enum64(t))\n+\t\treturn BTF_KIND_ENUM;\n+\treturn btf_kind(t);\n+}\n+\n+/*\n+ * Return 1 if the types match, 0 if they don't, or -EINVAL if a type\n+ * can't be looked up or the types nest deeper than depth.\n+ */\n+static int kfunc_type_match(const struct btf *a, __u32 a_id,\n+\t\t\t    const struct btf *b, __u32 b_id, int depth)\n+{\n+\tconst struct btf_type *at = skip_mods_and_typedefs(a, a_id, NULL);\n+\tconst struct btf_type *bt = skip_mods_and_typedefs(b, b_id, NULL);\n+\t__u16 kind;\n+\tint i, ret;\n+\n+\tif (!at || !bt || !depth)\n+\t\treturn -EINVAL;\n+\n+\tkind = kfunc_type_kind(at);\n+\tif (kind != kfunc_type_kind(bt))\n+\t\treturn 0;\n+\n+\tswitch (kind) {\n+\tcase BTF_KIND_STRUCT:\n+\tcase BTF_KIND_UNION: {\n+\t\tconst char *an = btf__name_by_offset(a, at-\u003ename_off);\n+\t\tconst char *bn = btf__name_by_offset(b, bt-\u003ename_off);\n+\t\tsize_t name_len = bpf_core_essential_name_len(an);\n+\n+\t\treturn name_len == bpf_core_essential_name_len(bn) \u0026\u0026\n+\t\t       strncmp(an, bn, name_len) == 0;\n+\t}\n+\tcase BTF_KIND_UNKN:\n+\tcase BTF_KIND_ENUM:\n+\t\treturn 1;\n+\tcase BTF_KIND_INT:\n+\t\treturn btf_int_offset(at) == 0 \u0026\u0026 btf_int_offset(bt) == 0;\n+\tcase BTF_KIND_PTR:\n+\t\treturn kfunc_type_match(a, at-\u003etype, b, bt-\u003etype, depth - 1);\n+\tcase BTF_KIND_ARRAY:\n+\t\treturn kfunc_type_match(a, btf_array(at)-\u003etype, b, btf_array(bt)-\u003etype, depth - 1);\n+\tcase BTF_KIND_FUNC_PROTO:\n+\t\tif (btf_vlen(at) != btf_vlen(bt))\n+\t\t\treturn 0;\n+\t\tfor (i = 0; i \u003c btf_vlen(at); i++) {\n+\t\t\tret = kfunc_type_match(a, btf_params(at)[i].type,\n+\t\t\t\t\t       b, btf_params(bt)[i].type, depth - 1);\n+\t\t\tif (ret \u003c= 0)\n+\t\t\t\treturn ret;\n+\t\t}\n+\t\treturn kfunc_type_match(a, at-\u003etype, b, bt-\u003etype, depth - 1);\n+\tdefault:\n+\t\treturn 0;\n+\t}\n+}\n+\n+int btf_kfunc_proto_match(const struct btf *a, __u32 a_id,\n+\t\t\t  const struct btf *b, __u32 b_id)\n+{\n+\treturn kfunc_type_match(a, a_id, b, b_id, 32);\n+}\n+\n static __s32 btf_find_by_name_kind(const struct btf *btf, int start_id,\n \t\t\t\t   const char *type_name, __s32 kind)\n {\n@@ -1185,7 +1278,7 @@ static __s32 btf_find_by_name_kind(const struct btf *btf, int start_id,\n \n \tif (btf-\u003enamed_start_id \u003e 0 \u0026\u0026 type_name[0]) {\n \t\tstart_id = max(start_id, btf-\u003enamed_start_id);\n-\t\tid = btf_find_type_by_name_bsearch(btf, type_name, start_id);\n+\t\tid = btf_find_type_by_name_bsearch(btf, type_name, strlen(type_name), start_id);\n \t\tfor (; id \u003c nr_types; id++) {\n \t\t\tt = btf__type_by_id(btf, id);\n \t\t\ttname = btf__str_by_offset(btf, t-\u003ename_off);\ndiff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c\nindex 1efc0dd37b2e65..dadf446daa0b14 100644\n--- a/tools/lib/bpf/libbpf.c\n+++ b/tools/lib/bpf/libbpf.c\n@@ -641,7 +641,6 @@ struct extern_desc {\n \tint btf_id;\n \tint sec_btf_id;\n \tchar *name;\n-\tchar *essent_name;\n \tbool is_set;\n \tbool is_weak;\n \tunion {\n@@ -4446,7 +4445,6 @@ static int bpf_object__collect_externs(struct bpf_object *obj)\n \tstruct extern_desc *ext;\n \tint i, n, off, dummy_var_btf_id;\n \tconst char *ext_name, *sec_name;\n-\tsize_t ext_essent_len;\n \tElf_Scn *scn;\n \tElf64_Shdr *sh;\n \n@@ -4498,14 +4496,6 @@ static int bpf_object__collect_externs(struct bpf_object *obj)\n \t\text-\u003esym_idx = i;\n \t\text-\u003eis_weak = ELF64_ST_BIND(sym-\u003est_info) == STB_WEAK;\n \n-\t\text_essent_len = bpf_core_essential_name_len(ext-\u003ename);\n-\t\text-\u003eessent_name = NULL;\n-\t\tif (ext_essent_len != strlen(ext-\u003ename)) {\n-\t\t\text-\u003eessent_name = strndup(ext-\u003ename, ext_essent_len);\n-\t\t\tif (!ext-\u003eessent_name)\n-\t\t\t\treturn -ENOMEM;\n-\t\t}\n-\n \t\text-\u003esec_btf_id = find_extern_sec_btf_id(obj-\u003ebtf, ext-\u003ebtf_id);\n \t\tif (ext-\u003esec_btf_id \u003c= 0) {\n \t\t\tpr_warn(\"failed to find BTF for extern '%s' [%d] section: %d\\n\",\n@@ -9513,41 +9503,96 @@ static int bpf_object__resolve_ksym_var_btf_id(struct bpf_object *obj,\n \treturn 0;\n }\n \n+/* t is a FUNC whose essential name is the first name_len bytes of name */\n+static bool btf_is_kfunc_candidate(const struct btf *btf, const struct btf_type *t,\n+\t\t\t\t   const char *name, size_t name_len)\n+{\n+\tconst char *tname;\n+\n+\tif (!btf_is_func(t))\n+\t\treturn false;\n+\ttname = btf__name_by_offset(btf, t-\u003ename_off);\n+\tif (strncmp(tname, name, name_len) != 0)\n+\t\treturn false;\n+\treturn bpf_core_essential_name_len(tname) == name_len;\n+}\n+\n+/*\n+ * Search vmlinux and module BTFs. Return:\n+ *   - a BTF ID for a unique match;\n+ *   - -ESRCH if the family is absent;\n+ *   - -EINVAL if no candidate has a compatible prototype;\n+ *   - -ENOTUNIQ if more than one candidate has a compatible prototype.\n+ */\n+static int find_kfunc_btf_id(struct bpf_object *obj, const struct extern_desc *ext,\n+\t\t\t     struct btf **res_btf, struct module_btf **res_mod_btf)\n+{\n+\tsize_t name_len = bpf_core_essential_name_len(ext-\u003ename);\n+\tint kfunc_id = 0, nr_cands = 0;\n+\tsize_t i;\n+\n+\tfor (i = 0; i \u003c= obj-\u003ebtf_module_cnt; i++) {\n+\t\tstruct module_btf *mod = i ? \u0026obj-\u003ebtf_modules[i - 1] : NULL;\n+\t\tstruct btf *btf = mod ? mod-\u003ebtf : obj-\u003ebtf_vmlinux;\n+\t\t__u32 id, end;\n+\n+\t\tbtf_name_prefix_range(btf, ext-\u003ename, name_len, \u0026id, \u0026end);\n+\t\tfor (; id \u003c end; id++) {\n+\t\t\tconst struct btf_type *t = btf__type_by_id(btf, id);\n+\n+\t\t\tif (!btf_is_kfunc_candidate(btf, t, ext-\u003ename, name_len))\n+\t\t\t\tcontinue;\n+\t\t\tnr_cands++;\n+\t\t\tif (btf_kfunc_proto_match(obj-\u003ebtf, ext-\u003eksym.type_id, btf, t-\u003etype) \u003c= 0)\n+\t\t\t\tcontinue;\n+\t\t\tif (kfunc_id)\n+\t\t\t\treturn -ENOTUNIQ;\n+\t\t\tkfunc_id = id;\n+\t\t\t*res_btf = btf;\n+\t\t\t*res_mod_btf = mod;\n+\t\t}\n+\t}\n+\tif (!nr_cands)\n+\t\treturn -ESRCH;\n+\tif (!kfunc_id)\n+\t\treturn -EINVAL;\n+\treturn kfunc_id;\n+}\n+\n static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,\n \t\t\t\t\t\tstruct extern_desc *ext)\n {\n-\tint local_func_proto_id, kfunc_proto_id, kfunc_id;\n \tstruct module_btf *mod_btf = NULL;\n \tconst struct btf_type *kern_func;\n \tstruct btf *kern_btf = NULL;\n-\tint ret;\n+\tint kfunc_id, ret;\n \n-\tlocal_func_proto_id = ext-\u003eksym.type_id;\n+\tret = load_module_btfs(obj);\n+\tif (ret)\n+\t\treturn ret;\n \n-\tkfunc_id = find_ksym_btf_id(obj, ext-\u003eessent_name ?: ext-\u003ename, BTF_KIND_FUNC, \u0026kern_btf,\n-\t\t\t\t    \u0026mod_btf);\n-\tif (kfunc_id \u003c 0) {\n-\t\tif (kfunc_id == -ESRCH \u0026\u0026 ext-\u003eis_weak)\n+\tkfunc_id = find_kfunc_btf_id(obj, ext, \u0026kern_btf, \u0026mod_btf);\n+\tif (kfunc_id == -ESRCH) {\n+\t\tif (ext-\u003eis_weak)\n \t\t\treturn 0;\n \t\tpr_warn(\"extern (func ksym) '%s': not found in kernel or module BTFs\\n\",\n \t\t\text-\u003ename);\n \t\treturn kfunc_id;\n \t}\n-\n-\tkern_func = btf__type_by_id(kern_btf, kfunc_id);\n-\tkfunc_proto_id = kern_func-\u003etype;\n-\n-\tret = bpf_core_types_are_compat(obj-\u003ebtf, local_func_proto_id,\n-\t\t\t\t\tkern_btf, kfunc_proto_id);\n-\tif (ret \u003c= 0) {\n+\tif (kfunc_id == -EINVAL) {\n \t\tif (ext-\u003eis_weak)\n \t\t\treturn 0;\n-\n-\t\tpr_warn(\"extern (func ksym) '%s': func_proto [%d] incompatible with %s [%d]\\n\",\n-\t\t\text-\u003ename, local_func_proto_id,\n-\t\t\tmod_btf ? mod_btf-\u003ename : \"vmlinux\", kfunc_proto_id);\n-\t\treturn -EINVAL;\n+\t\tpr_warn(\"extern (func ksym) '%s': no compatible prototype in kernel or module BTFs\\n\",\n+\t\t\text-\u003ename);\n+\t\treturn kfunc_id;\n \t}\n+\t/* an error even for a weak kfunc: ambiguity isn't absence */\n+\tif (kfunc_id == -ENOTUNIQ) {\n+\t\tpr_warn(\"extern (func ksym) '%s': more than one compatible prototype in kernel or module BTFs\\n\",\n+\t\t\text-\u003ename);\n+\t\treturn kfunc_id;\n+\t}\n+\tkern_func = btf__type_by_id(kern_btf, kfunc_id);\n \n \t/* set index for module BTF fd in fd_array, if unset */\n \tif (mod_btf \u0026\u0026 !mod_btf-\u003efd_array_idx) {\n@@ -9579,8 +9624,9 @@ static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,\n \t * {kernel_btf_id, kernel_btf_obj_fd} -\u003e fixup ld_imm64.\n \t */\n \text-\u003eksym.kernel_btf_obj_fd = mod_btf ? mod_btf-\u003efd : 0;\n-\tpr_debug(\"extern (func ksym) '%s': resolved to %s [%d]\\n\",\n-\t\t ext-\u003ename, mod_btf ? mod_btf-\u003ename : \"vmlinux\", kfunc_id);\n+\tpr_debug(\"extern (func ksym) '%s': resolved to %s '%s' [%d]\\n\",\n+\t\t ext-\u003ename, mod_btf ? mod_btf-\u003ename : \"vmlinux\",\n+\t\t btf__name_by_offset(kern_btf, kern_func-\u003ename_off), kfunc_id);\n \n \treturn 0;\n }\n@@ -10441,10 +10487,8 @@ void bpf_object__close(struct bpf_object *obj)\n \tzfree(\u0026obj-\u003ebtf_custom_path);\n \tzfree(\u0026obj-\u003ekconfig);\n \n-\tfor (i = 0; i \u003c obj-\u003enr_extern; i++) {\n+\tfor (i = 0; i \u003c obj-\u003enr_extern; i++)\n \t\tzfree(\u0026obj-\u003eexterns[i].name);\n-\t\tzfree(\u0026obj-\u003eexterns[i].essent_name);\n-\t}\n \n \tzfree(\u0026obj-\u003eexterns);\n \tobj-\u003enr_extern = 0;\ndiff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h\nindex e90b5336bac01a..389c48548222bd 100644\n--- a/tools/lib/bpf/libbpf_internal.h\n+++ b/tools/lib/bpf/libbpf_internal.h\n@@ -18,6 +18,7 @@\n #include \u003cunistd.h\u003e\n #include \u003csys/syscall.h\u003e\n #include \u003clibelf.h\u003e\n+#include \"libbpf_tools.h\"\n #include \"relo_core.h\"\n \n /* Android's libc doesn't support AT_EACCESS in faccessat() implementation\n@@ -94,12 +95,6 @@\n #define BTF_TYPE_TYPE_TAG_ENC(value, type) \\\n \tBTF_TYPE_ENC(value, BTF_INFO_ENC(BTF_KIND_TYPE_TAG, 0, 0), type)\n \n-#ifndef likely\n-#define likely(x) __builtin_expect(!!(x), 1)\n-#endif\n-#ifndef unlikely\n-#define unlikely(x) __builtin_expect(!!(x), 0)\n-#endif\n #ifndef min\n # define min(x, y) ((x) \u003c (y) ? (x) : (y))\n #endif\n@@ -184,10 +179,6 @@ const char *libbpf_errstr(int err);\n \n #define errstr(err) libbpf_errstr(err)\n \n-#ifndef __has_builtin\n-#define __has_builtin(x) 0\n-#endif\n-\n struct bpf_link {\n \tint (*detach)(struct bpf_link *link);\n \tvoid (*dealloc)(struct bpf_link *link);\n@@ -196,30 +187,6 @@ struct bpf_link {\n \tbool disconnected;\n };\n \n-/*\n- * Re-implement glibc's reallocarray() for libbpf internal-only use.\n- * reallocarray(), unfortunately, is not available in all versions of glibc,\n- * so requires extra feature detection and using reallocarray() stub from\n- * \u003ctools/libc_compat.h\u003e and COMPAT_NEED_REALLOCARRAY. All this complicates\n- * build of libbpf unnecessarily and is just a maintenance burden. Instead,\n- * it's trivial to implement libbpf-specific internal version and use it\n- * throughout libbpf.\n- */\n-static inline void *libbpf_reallocarray(void *ptr, size_t nmemb, size_t size)\n-{\n-\tsize_t total;\n-\n-#if __has_builtin(__builtin_mul_overflow)\n-\tif (unlikely(__builtin_mul_overflow(nmemb, size, \u0026total)))\n-\t\treturn NULL;\n-#else\n-\tif (size == 0 || nmemb \u003e ULONG_MAX / size)\n-\t\treturn NULL;\n-\ttotal = nmemb * size;\n-#endif\n-\treturn realloc(ptr, total);\n-}\n-\n /* Copy up to sz - 1 bytes from zero-terminated src string and ensure that dst\n  * is zero-terminated string no matter what (unless sz == 0, in which case\n  * it's a no-op). It's conceptually close to FreeBSD's strlcpy(), but differs\n@@ -245,12 +212,11 @@ struct btf;\n struct btf_type;\n \n struct btf_type *btf_type_by_id(const struct btf *btf, __u32 type_id);\n-const char *btf_kind_str(const struct btf_type *t);\n-const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);\n-const struct btf_header *btf_header(const struct btf *btf);\n void btf_set_base_btf(struct btf *btf, const struct btf *base_btf);\n int btf_relocate(struct btf *btf, const struct btf *base_btf, __u32 **id_map,\n \t\t __u32 **str_map);\n+void btf_name_prefix_range(const struct btf *btf, const char *name, size_t name_len,\n+\t\t\t   __u32 *start, __u32 *end);\n bool btf_type_is_traceable_func(const struct btf *btf, const struct btf_type *t);\n \n static inline enum btf_func_linkage btf_func_linkage(const struct btf_type *t)\n@@ -431,7 +397,6 @@ int probe_memcg_account(int token_fd);\n int bump_rlimit_memlock(void);\n \n int parse_cpu_mask_str(const char *s, bool **mask, int *mask_sz);\n-int parse_cpu_mask_file(const char *fcpu, bool **mask, int *mask_sz);\n int libbpf__load_raw_btf(const char *raw_types, size_t types_len,\n \t\t\t const char *str_sec, size_t str_len,\n \t\t\t int token_fd);\n@@ -448,92 +413,6 @@ struct btf *btf_get_from_fd(int btf_fd, struct btf *base_btf);\n void btf_get_kernel_prefix_kind(enum bpf_attach_type attach_type,\n \t\t\t\tconst char **prefix, int *kind);\n \n-struct btf_ext_info {\n-\t/*\n-\t * info points to the individual info section (e.g. func_info and\n-\t * line_info) from the .BTF.ext. It does not include the __u32 rec_size.\n-\t */\n-\tvoid *info;\n-\t__u32 rec_size;\n-\t__u32 len;\n-\t/* optional (maintained internally by libbpf) mapping between .BTF.ext\n-\t * section and corresponding ELF section. This is used to join\n-\t * information like CO-RE relocation records with corresponding BPF\n-\t * programs defined in ELF sections\n-\t */\n-\t__u32 *sec_idxs;\n-\tint sec_cnt;\n-};\n-\n-#define for_each_btf_ext_sec(seg, sec)\t\t\t\t\t\\\n-\tfor (sec = (seg)-\u003einfo;\t\t\t\t\t\t\\\n-\t     (void *)sec \u003c (seg)-\u003einfo + (seg)-\u003elen;\t\t\t\\\n-\t     sec = (void *)sec + sizeof(struct btf_ext_info_sec) +\t\\\n-\t\t   (seg)-\u003erec_size * sec-\u003enum_info)\n-\n-#define for_each_btf_ext_rec(seg, sec, i, rec)\t\t\t\t\\\n-\tfor (i = 0, rec = (void *)\u0026(sec)-\u003edata;\t\t\t\t\\\n-\t     i \u003c (sec)-\u003enum_info;\t\t\t\t\t\\\n-\t     i++, rec = (void *)rec + (seg)-\u003erec_size)\n-\n-/*\n- * The .BTF.ext ELF section layout defined as\n- *   struct btf_ext_header\n- *   func_info subsection\n- *\n- * The func_info subsection layout:\n- *   record size for struct bpf_func_info in the func_info subsection\n- *   struct btf_ext_info_sec for section #1\n- *   a list of bpf_func_info records for section #1\n- *     where struct bpf_func_info mimics one in include/uapi/linux/bpf.h\n- *     but may not be identical\n- *   struct btf_ext_info_sec for section #2\n- *   a list of bpf_func_info records for section #2\n- *   ......\n- *\n- * Note that the bpf_func_info record size in .BTF.ext may not\n- * be the same as the one defined in include/uapi/linux/bpf.h.\n- * The loader should ensure that record_size meets minimum\n- * requirement and pass the record as is to the kernel. The\n- * kernel will handle the func_info properly based on its contents.\n- */\n-struct btf_ext_header {\n-\t__u16\tmagic;\n-\t__u8\tversion;\n-\t__u8\tflags;\n-\t__u32\thdr_len;\n-\n-\t/* All offsets are in bytes relative to the end of this header */\n-\t__u32\tfunc_info_off;\n-\t__u32\tfunc_info_len;\n-\t__u32\tline_info_off;\n-\t__u32\tline_info_len;\n-\n-\t/* optional part of .BTF.ext header */\n-\t__u32\tcore_relo_off;\n-\t__u32\tcore_relo_len;\n-};\n-\n-struct btf_ext {\n-\tunion {\n-\t\tstruct btf_ext_header *hdr;\n-\t\tvoid *data;\n-\t};\n-\tvoid *data_swapped;\n-\tbool swapped_endian;\n-\tstruct btf_ext_info func_info;\n-\tstruct btf_ext_info line_info;\n-\tstruct btf_ext_info core_relo_info;\n-\t__u32 data_size;\n-};\n-\n-struct btf_ext_info_sec {\n-\t__u32\tsec_name_off;\n-\t__u32\tnum_info;\n-\t/* Followed by num_info * record_size number of bytes */\n-\t__u8\tdata[];\n-};\n-\n /* The minimum bpf_func_info checked by the loader */\n struct bpf_func_info_min {\n \t__u32   insn_off;\n@@ -574,31 +453,6 @@ static inline void bpf_core_relo_bswap(struct bpf_core_relo *i)\n \ti-\u003ekind = bswap_32(i-\u003ekind);\n }\n \n-enum btf_field_iter_kind {\n-\tBTF_FIELD_ITER_IDS,\n-\tBTF_FIELD_ITER_STRS,\n-};\n-\n-struct btf_field_desc {\n-\t/* once-per-type offsets */\n-\tint t_off_cnt, t_offs[2];\n-\t/* member struct size, or zero, if no members */\n-\tint m_sz;\n-\t/* repeated per-member offsets */\n-\tint m_off_cnt, m_offs[2];\n-};\n-\n-struct btf_field_iter {\n-\tstruct btf_field_desc desc;\n-\tvoid *p;\n-\tint m_idx;\n-\tint off_idx;\n-\tint vlen;\n-};\n-\n-int btf_field_iter_init(struct btf_field_iter *it, struct btf_type *t, enum btf_field_iter_kind iter_kind);\n-__u32 *btf_field_iter_next(struct btf_field_iter *it);\n-\n typedef int (*type_id_visit_fn)(__u32 *type_id, void *ctx);\n typedef int (*str_off_visit_fn)(__u32 *str_off, void *ctx);\n int btf_ext_visit_type_ids(struct btf_ext *btf_ext, type_id_visit_fn visit, void *ctx);\n@@ -721,15 +575,6 @@ static inline int reuse_fd(int fixed_fd, int tmp_fd)\n \treturn err;\n }\n \n-/* The following two functions are exposed to bpftool */\n-int bpf_core_add_cands(struct bpf_core_cand *local_cand,\n-\t\t       size_t local_essent_len,\n-\t\t       const struct btf *targ_btf,\n-\t\t       const char *targ_btf_name,\n-\t\t       int targ_start_id,\n-\t\t       struct bpf_core_cand_list *cands);\n-void bpf_core_free_cands(struct bpf_core_cand_list *cands);\n-\n struct usdt_manager *usdt_manager_new(struct bpf_object *obj);\n void usdt_manager_free(struct usdt_manager *man);\n struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man,\n@@ -772,8 +617,5 @@ int elf_resolve_pattern_offsets(const char *binary_path, const char *pattern,\n \n int probe_fd(int fd);\n \n-#define SHA256_DIGEST_LENGTH 32\n-\n-void libbpf_sha256(const void *data, size_t len, __u8 out[SHA256_DIGEST_LENGTH]);\n int probe_sys_bpf_ext(void);\n #endif /* __LIBBPF_LIBBPF_INTERNAL_H */\ndiff --git a/tools/lib/bpf/libbpf_tools.h b/tools/lib/bpf/libbpf_tools.h\nnew file mode 100644\nindex 00000000000000..cd9137376d443a\n--- /dev/null\n+++ b/tools/lib/bpf/libbpf_tools.h\n@@ -0,0 +1,186 @@\n+/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */\n+#ifndef __LIBBPF_TOOLS_H\n+#define __LIBBPF_TOOLS_H\n+\n+#include \u003climits.h\u003e\n+#include \u003cstdbool.h\u003e\n+#include \u003cstddef.h\u003e\n+#include \u003cstdlib.h\u003e\n+#include \u003clinux/types.h\u003e\n+\n+/* Internal interfaces for kernel tools that link libbpf statically. */\n+\n+#ifndef likely\n+#define likely(x) __builtin_expect(!!(x), 1)\n+#endif\n+#ifndef unlikely\n+#define unlikely(x) __builtin_expect(!!(x), 0)\n+#endif\n+\n+#ifndef __has_builtin\n+#define __has_builtin(x) 0\n+#endif\n+\n+/*\n+ * Re-implement glibc's reallocarray() for libbpf internal-only use.\n+ * reallocarray(), unfortunately, is not available in all versions of glibc,\n+ * so requires extra feature detection and using reallocarray() stub from\n+ * \u003ctools/libc_compat.h\u003e and COMPAT_NEED_REALLOCARRAY. All this complicates\n+ * build of libbpf unnecessarily and is just a maintenance burden. Instead,\n+ * it's trivial to implement libbpf-specific internal version and use it\n+ * throughout libbpf.\n+ */\n+static inline void *libbpf_reallocarray(void *ptr, size_t nmemb, size_t size)\n+{\n+\tsize_t total;\n+\n+#if __has_builtin(__builtin_mul_overflow)\n+\tif (unlikely(__builtin_mul_overflow(nmemb, size, \u0026total)))\n+\t\treturn NULL;\n+#else\n+\tif (size == 0 || nmemb \u003e ULONG_MAX / size)\n+\t\treturn NULL;\n+\ttotal = nmemb * size;\n+#endif\n+\treturn realloc(ptr, total);\n+}\n+\n+struct btf;\n+struct btf_header;\n+struct btf_type;\n+struct bpf_core_cand;\n+struct bpf_core_cand_list;\n+\n+const struct btf_header *btf_header(const struct btf *btf);\n+int btf_kfunc_proto_match(const struct btf *a, __u32 a_id,\n+\t\t\t  const struct btf *b, __u32 b_id);\n+const char *btf_kind_str(const struct btf_type *t);\n+const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);\n+\n+enum btf_field_iter_kind {\n+\tBTF_FIELD_ITER_IDS,\n+\tBTF_FIELD_ITER_STRS,\n+};\n+\n+struct btf_field_desc {\n+\t/* once-per-type offsets */\n+\tint t_off_cnt, t_offs[2];\n+\t/* member struct size, or zero, if no members */\n+\tint m_sz;\n+\t/* repeated per-member offsets */\n+\tint m_off_cnt, m_offs[2];\n+};\n+\n+struct btf_field_iter {\n+\tstruct btf_field_desc desc;\n+\tvoid *p;\n+\tint m_idx;\n+\tint off_idx;\n+\tint vlen;\n+};\n+\n+int btf_field_iter_init(struct btf_field_iter *it, struct btf_type *t,\n+\t\t\tenum btf_field_iter_kind iter_kind);\n+__u32 *btf_field_iter_next(struct btf_field_iter *it);\n+\n+struct btf_ext_info {\n+\t/*\n+\t * info points to the individual info section (e.g. func_info and\n+\t * line_info) from the .BTF.ext. It does not include the __u32 rec_size.\n+\t */\n+\tvoid *info;\n+\t__u32 rec_size;\n+\t__u32 len;\n+\t/* optional (maintained internally by libbpf) mapping between .BTF.ext\n+\t * section and corresponding ELF section. This is used to join\n+\t * information like CO-RE relocation records with corresponding BPF\n+\t * programs defined in ELF sections\n+\t */\n+\t__u32 *sec_idxs;\n+\tint sec_cnt;\n+};\n+\n+#define for_each_btf_ext_sec(seg, sec)\t\t\t\t\t\\\n+\tfor (sec = (seg)-\u003einfo;\t\t\t\t\t\t\\\n+\t     (void *)sec \u003c (seg)-\u003einfo + (seg)-\u003elen;\t\t\t\\\n+\t     sec = (void *)sec + sizeof(struct btf_ext_info_sec) +\t\\\n+\t\t   (seg)-\u003erec_size * sec-\u003enum_info)\n+\n+#define for_each_btf_ext_rec(seg, sec, i, rec)\t\t\t\t\\\n+\tfor (i = 0, rec = (void *)\u0026(sec)-\u003edata;\t\t\t\t\\\n+\t     i \u003c (sec)-\u003enum_info;\t\t\t\t\t\\\n+\t     i++, rec = (void *)rec + (seg)-\u003erec_size)\n+\n+/*\n+ * The .BTF.ext ELF section layout defined as\n+ *   struct btf_ext_header\n+ *   func_info subsection\n+ *\n+ * The func_info subsection layout:\n+ *   record size for struct bpf_func_info in the func_info subsection\n+ *   struct btf_ext_info_sec for section #1\n+ *   a list of bpf_func_info records for section #1\n+ *     where struct bpf_func_info mimics one in include/uapi/linux/bpf.h\n+ *     but may not be identical\n+ *   struct btf_ext_info_sec for section #2\n+ *   a list of bpf_func_info records for section #2\n+ *   ......\n+ *\n+ * Note that the bpf_func_info record size in .BTF.ext may not\n+ * be the same as the one defined in include/uapi/linux/bpf.h.\n+ * The loader should ensure that record_size meets minimum\n+ * requirement and pass the record as is to the kernel. The\n+ * kernel will handle the func_info properly based on its contents.\n+ */\n+struct btf_ext_header {\n+\t__u16\tmagic;\n+\t__u8\tversion;\n+\t__u8\tflags;\n+\t__u32\thdr_len;\n+\n+\t/* All offsets are in bytes relative to the end of this header */\n+\t__u32\tfunc_info_off;\n+\t__u32\tfunc_info_len;\n+\t__u32\tline_info_off;\n+\t__u32\tline_info_len;\n+\n+\t/* optional part of .BTF.ext header */\n+\t__u32\tcore_relo_off;\n+\t__u32\tcore_relo_len;\n+};\n+\n+struct btf_ext {\n+\tunion {\n+\t\tstruct btf_ext_header *hdr;\n+\t\tvoid *data;\n+\t};\n+\tvoid *data_swapped;\n+\tbool swapped_endian;\n+\tstruct btf_ext_info func_info;\n+\tstruct btf_ext_info line_info;\n+\tstruct btf_ext_info core_relo_info;\n+\t__u32 data_size;\n+};\n+\n+struct btf_ext_info_sec {\n+\t__u32\tsec_name_off;\n+\t__u32\tnum_info;\n+\t/* Followed by num_info * record_size number of bytes */\n+\t__u8\tdata[];\n+};\n+\n+int bpf_core_add_cands(struct bpf_core_cand *local_cand,\n+\t\t       size_t local_essent_len,\n+\t\t       const struct btf *targ_btf,\n+\t\t       const char *targ_btf_name,\n+\t\t       int targ_start_id,\n+\t\t       struct bpf_core_cand_list *cands);\n+void bpf_core_free_cands(struct bpf_core_cand_list *cands);\n+\n+int parse_cpu_mask_file(const char *fcpu, bool **mask, int *mask_sz);\n+\n+#define SHA256_DIGEST_LENGTH 32\n+\n+void libbpf_sha256(const void *data, size_t len, __u8 out[SHA256_DIGEST_LENGTH]);\n+\n+#endif /* __LIBBPF_TOOLS_H */\ndiff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h\nindex 254882bd8ce615..fcbf7908defdaf 100644\n--- a/tools/sched_ext/include/scx/compat.bpf.h\n+++ b/tools/sched_ext/include/scx/compat.bpf.h\n@@ -29,8 +29,10 @@ struct cgroup *scx_bpf_task_cgroup___new(struct task_struct *p) __ksym __weak;\n  * scx_bpf_dispatch_from_dsq() and friends were added during v6.12 by\n  * 4c30f5ce4f7a (\"sched_ext: Implement scx_bpf_dispatch[_vtime]_from_dsq()\").\n  *\n- * v7.1: scx_bpf_dsq_move_to_local___v2() to add @enq_flags.\n+ * v7.1: scx_bpf_dsq_move_to_local___v2() to add @enq_flags. Older libbpf can\n+ * resolve it only through the extra ___compat suffix.\n  */\n+bool scx_bpf_dsq_move_to_local___v2(u64 dsq_id, u64 enq_flags) __ksym __weak;\n bool scx_bpf_dsq_move_to_local___v2___compat(u64 dsq_id, u64 enq_flags) __ksym __weak;\n bool scx_bpf_dsq_move_to_local___v1(u64 dsq_id) __ksym __weak;\n void scx_bpf_dsq_move_set_slice___new(struct bpf_iter_scx_dsq *it__iter, u64 slice) __ksym __weak;\n@@ -45,11 +47,13 @@ bool scx_bpf_dispatch_from_dsq___old(struct bpf_iter_scx_dsq *it__iter, struct t\n bool scx_bpf_dispatch_vtime_from_dsq___old(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak;\n \n #define scx_bpf_dsq_move_to_local(dsq_id, enq_flags)\t\t\t\t\\\n-\t(bpf_ksym_exists(scx_bpf_dsq_move_to_local___v2___compat) ?\t\t\\\n-\t scx_bpf_dsq_move_to_local___v2___compat((dsq_id), (enq_flags)) :\t\\\n-\t (bpf_ksym_exists(scx_bpf_dsq_move_to_local___v1) ?\t\t\t\\\n-\t  scx_bpf_dsq_move_to_local___v1((dsq_id)) :\t\t\t\t\\\n-\t  scx_bpf_consume___old((dsq_id))))\n+\t(bpf_ksym_exists(scx_bpf_dsq_move_to_local___v2) ?\t\t\t\\\n+\t scx_bpf_dsq_move_to_local___v2((dsq_id), (enq_flags)) :\t\t\\\n+\t (bpf_ksym_exists(scx_bpf_dsq_move_to_local___v2___compat) ?\t\t\\\n+\t  scx_bpf_dsq_move_to_local___v2___compat((dsq_id), (enq_flags)) :\t\\\n+\t  (bpf_ksym_exists(scx_bpf_dsq_move_to_local___v1) ?\t\t\t\\\n+\t   scx_bpf_dsq_move_to_local___v1((dsq_id)) :\t\t\t\t\\\n+\t   scx_bpf_consume___old((dsq_id)))))\n \n #define scx_bpf_dsq_move_set_slice(it__iter, slice)\t\t\t\t\\\n \t(bpf_ksym_exists(scx_bpf_dsq_move_set_slice___new) ?\t\t\t\\\n@@ -430,12 +434,13 @@ scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id, u64 slice, u64 vtime\n /*\n  * v6.19: scx_bpf_dsq_insert() now returns bool instead of void. Move\n  * scx_bpf_dsq_insert() decl to common.bpf.h and drop compat helper after v6.22.\n- * The extra ___compat suffix is to work around libbpf not ignoring __SUFFIX on\n- * kernel side. The entire suffix can be dropped later.\n+ * Older libbpf can resolve scx_bpf_dsq_insert___v2() only through the extra\n+ * ___compat suffix.\n  *\n  * v6.13: scx_bpf_dsq_insert() renaming is also handled here. See the block on\n  * dispatch renaming above for more details.\n  */\n+bool scx_bpf_dsq_insert___v2(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags) __ksym __weak;\n bool scx_bpf_dsq_insert___v2___compat(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags) __ksym __weak;\n void scx_bpf_dsq_insert___v1(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags) __ksym __weak;\n void scx_bpf_dispatch___compat(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags) __ksym __weak;\n@@ -443,7 +448,9 @@ void scx_bpf_dispatch___compat(struct task_struct *p, u64 dsq_id, u64 slice, u64\n static inline bool\n scx_bpf_dsq_insert(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags)\n {\n-\tif (bpf_ksym_exists(scx_bpf_dsq_insert___v2___compat)) {\n+\tif (bpf_ksym_exists(scx_bpf_dsq_insert___v2)) {\n+\t\treturn scx_bpf_dsq_insert___v2(p, dsq_id, slice, enq_flags);\n+\t} else if (bpf_ksym_exists(scx_bpf_dsq_insert___v2___compat)) {\n \t\treturn scx_bpf_dsq_insert___v2___compat(p, dsq_id, slice, enq_flags);\n \t} else if (bpf_ksym_exists(scx_bpf_dsq_insert___v1)) {\n \t\tscx_bpf_dsq_insert___v1(p, dsq_id, slice, enq_flags);\n@@ -506,23 +513,32 @@ static inline bool __COMPAT_has_dsq_reenq_task(void)\n \n /*\n  * v6.19: The new void variant can be called from anywhere while the older v1\n- * variant can only be called from ops.cpu_release(). The double ___ prefixes on\n- * the v2 variant need to be removed once libbpf is updated to ignore ___ prefix\n- * on kernel side. Drop the wrapper and move the decl to common.bpf.h after\n- * v6.22.\n+ * variant can only be called from ops.cpu_release(). Older libbpf can resolve\n+ * the v2 variant only through the extra ___compat suffix. Drop the wrapper and\n+ * move the decl to common.bpf.h after v6.22.\n  */\n u32 scx_bpf_reenqueue_local___v1(void) __ksym __weak;\n+void scx_bpf_reenqueue_local___v2(void) __ksym __weak;\n void scx_bpf_reenqueue_local___v2___compat(void) __ksym __weak;\n \n static inline bool __COMPAT_scx_bpf_reenqueue_local_from_anywhere(void)\n {\n-\treturn bpf_ksym_exists(scx_bpf_reenqueue_local___v2___compat);\n+\tbool v2 = bpf_ksym_exists(scx_bpf_reenqueue_local___v2);\n+\n+\t/*\n+\t * Without the barrier, clang folds || into a bitwise OR of the two ksym\n+\t * addresses, which the verifier rejects.\n+\t */\n+\tbarrier_var(v2);\n+\treturn v2 || bpf_ksym_exists(scx_bpf_reenqueue_local___v2___compat);\n }\n \n static inline void scx_bpf_reenqueue_local(void)\n {\n \tif (__COMPAT_has_generic_reenq())\n \t\tscx_bpf_dsq_reenq___compat(SCX_DSQ_LOCAL, 0);\n+\telse if (bpf_ksym_exists(scx_bpf_reenqueue_local___v2))\n+\t\tscx_bpf_reenqueue_local___v2();\n \telse if (__COMPAT_scx_bpf_reenqueue_local_from_anywhere())\n \t\tscx_bpf_reenqueue_local___v2___compat();\n \telse\n@@ -541,6 +557,10 @@ static inline int scx_bpf_reenqueue_local_from_anywhere(void)\n \t\tscx_bpf_dsq_reenq___compat(SCX_DSQ_LOCAL, 0);\n \t\treturn 0;\n \t}\n+\tif (bpf_ksym_exists(scx_bpf_reenqueue_local___v2)) {\n+\t\tscx_bpf_reenqueue_local___v2();\n+\t\treturn 0;\n+\t}\n \tif (__COMPAT_scx_bpf_reenqueue_local_from_anywhere()) {\n \t\tscx_bpf_reenqueue_local___v2___compat();\n \t\treturn 0;\ndiff --git a/tools/testing/selftests/bpf/prog_tests/verifier.c b/tools/testing/selftests/bpf/prog_tests/verifier.c\nindex 816ab3cfafc745..157267f901771b 100644\n--- a/tools/testing/selftests/bpf/prog_tests/verifier.c\n+++ b/tools/testing/selftests/bpf/prog_tests/verifier.c\n@@ -8,6 +8,7 @@\n #include \"cap_helpers.h\"\n #include \"sysctl_helpers.h\"\n #include \"cb_refs.skel.h\"\n+#include \"kfunc_variants.skel.h\"\n #include \"verifier_aggregate_arg.skel.h\"\n #include \"verifier_aggregate_ret.skel.h\"\n #include \"verifier_alu_range.skel.h\"\n@@ -225,6 +226,8 @@ void test_arena_kfunc_jit(void)               { RUN_TESTS(arena_kfunc_jit); }\n \n void test_cb_refs(void)                       { RUN_TESTS(cb_refs); }\n \n+void test_kfunc_variants(void)                { RUN_TESTS(kfunc_variants); }\n+\n void test_verifier_aggregate_arg(void)        { RUN_TESTS(verifier_aggregate_arg); }\n void test_verifier_aggregate_ret(void)        { RUN_TESTS(verifier_aggregate_ret); }\n void test_verifier_alu_range(void)            { RUN(verifier_alu_range); }\ndiff --git a/tools/testing/selftests/bpf/progs/kfunc_variants.c b/tools/testing/selftests/bpf/progs/kfunc_variants.c\nnew file mode 100644\nindex 00000000000000..a9c393ea9d82e0\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/progs/kfunc_variants.c\n@@ -0,0 +1,32 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */\n+\n+#include \u003cvmlinux.h\u003e\n+#include \u003cbpf/bpf_helpers.h\u003e\n+#include \"bpf_misc.h\"\n+#include \"../test_kmods/bpf_testmod_kfunc.h\"\n+\n+extern int bpf_kfunc_variant___none(struct inode *p) __weak __ksym;\n+\n+char _license[] SEC(\"license\") = \"GPL\";\n+\n+SEC(\"syscall\")\n+__retval(1)\n+int unsuffixed_name(void *ctx)\n+{\n+\treturn bpf_kfunc_variant(NULL);\n+}\n+\n+SEC(\"syscall\")\n+__retval(2)\n+int kernel_variant(void *ctx)\n+{\n+\treturn bpf_kfunc_variant___v2(NULL);\n+}\n+\n+SEC(\"syscall\")\n+__retval(0)\n+int no_match(void *ctx)\n+{\n+\treturn bpf_ksym_exists(bpf_kfunc_variant___none);\n+}\ndiff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c\nindex 1fbc0061cc2408..764877cdce6e20 100644\n--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c\n+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c\n@@ -1928,6 +1928,16 @@ __bpf_kfunc void bpf_kfunc_trigger_ctx_check(void)\n \tirq_work_queue(\u0026ctx_check_irq);\n }\n \n+__bpf_kfunc int bpf_kfunc_variant(struct task_struct *p__nullable)\n+{\n+\treturn 1;\n+}\n+\n+__bpf_kfunc int bpf_kfunc_variant___v2(struct file *p__nullable)\n+{\n+\treturn 2;\n+}\n+\n BTF_KFUNCS_START(bpf_testmod_check_kfunc_ids)\n BTF_ID_FLAGS(func, bpf_testmod_test_mod_kfunc, KF_SPINLOCK_SAFE)\n BTF_ID_FLAGS(func, bpf_kfunc_call_test1)\n@@ -2019,6 +2029,8 @@ BTF_ID_FLAGS(func, bpf_kfunc_implicit_arg, KF_IMPLICIT_ARGS)\n BTF_ID_FLAGS(func, bpf_kfunc_implicit_arg_legacy, KF_IMPLICIT_ARGS)\n BTF_ID_FLAGS(func, bpf_kfunc_implicit_arg_legacy_impl)\n BTF_ID_FLAGS(func, bpf_kfunc_trigger_ctx_check)\n+BTF_ID_FLAGS(func, bpf_kfunc_variant)\n+BTF_ID_FLAGS(func, bpf_kfunc_variant___v2)\n BTF_KFUNCS_END(bpf_testmod_check_kfunc_ids)\n \n static int bpf_testmod_ops_init(struct btf *btf)\ndiff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h b/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h\nindex 0a7df179860332..ce579eede88d53 100644\n--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h\n+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h\n@@ -381,4 +381,7 @@ void bpf_testmod_test_hardirq_fn(void);\n void bpf_testmod_test_softirq_fn(void);\n void bpf_kfunc_trigger_ctx_check(void) __ksym;\n \n+int bpf_kfunc_variant(struct task_struct *p__nullable) __ksym;\n+int bpf_kfunc_variant___v2(struct file *p__nullable) __ksym;\n+\n #endif /* _BPF_TESTMOD_KFUNC_H */\n"
}

2/1 2026/11/30 04:23 agent patch-evaluator
0m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "All modifications in this patch are confined to Documentation/ (Documentation/bpf/kfuncs.rst), userspace tools and libraries (tools/bpf/bpftool/, tools/lib/bpf/, tools/sched_ext/include/scx/compat.bpf.h), the host build-time tool tools/bpf/resolve_btfids/ (which only adds a compile-time kfunc variant check without altering generated kernel BTF or .BTF_ids), and BPF selftests (tools/testing/selftests/bpf/). None of the changes modify vmlinux or kernel modules, so there is no reachable kernel code to fuzz.",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit c918ffdc779ecff1e985a97d2947f4f8d59b94c5
Author: syz-cluster <triage@syzkaller.com>
Date:   Mon Nov 30 04:23:13 2026 +0000

    syz-cluster: applied patch under review

diff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst
index 335dbb833bfe43..caaa6973133938 100644
--- a/Documentation/bpf/kfuncs.rst
+++ b/Documentation/bpf/kfuncs.rst
@@ -800,6 +800,105 @@ procedure is followed for removal:
 3. After the deprecation period the kfunc will be removed. At this point, BPF
    programs calling the kfunc will be rejected by the verifier.
 
+3.2 Changing a kfunc's prototype
+--------------------------------
+
+libbpf drops the last ``___suffix`` from the name of a kfunc declared in a BPF
+program and from the names of functions in kernel and module BTF, as it does
+for CO-RE type names. Among the functions with the same remaining name, it
+binds the one with a prototype that matches the declaration. Types are
+compared kind by kind, and structs and unions by name only:
+
+.. code-block:: c
+
+	typedef struct task_struct task_t;
+
+	/* these match */
+	int bpf_foo(struct task_struct *p, u32 flags);
+	int bpf_foo(const task_t *p, u64 flags);
+	int bpf_foo(struct task_struct___local *p, int flags);
+
+	/* none of these match the ones above */
+	int bpf_foo(struct file *p, u32 flags);
+	int bpf_foo(struct task_struct *p);
+	void bpf_foo(struct task_struct *p, u32 flags);
+
+If the old and new prototypes match, change the kfunc in place. Otherwise the
+new prototype keeps the name, and the old one stays available as
+``<name>___v1`` (``___v2`` for the next change, and so on) for a deprecation
+period, usually as a thin wrapper registered with the same flags:
+
+.. code-block:: c
+
+	__bpf_kfunc int bpf_foo(struct task_struct *p, u64 flags)
+	{
+		...
+	}
+
+	/* bpf_foo() before flags was added */
+	__bpf_kfunc int bpf_foo___v1(struct task_struct *p)
+	{
+		return bpf_foo(p, 0);
+	}
+
+	BTF_ID_FLAGS(func, bpf_foo, KF_RCU)
+	BTF_ID_FLAGS(func, bpf_foo___v1, KF_RCU)
+
+BPF programs built against either prototype then load:
+
+.. code-block:: c
+
+	/* built against the old prototype: binds bpf_foo___v1 */
+	extern int bpf_foo(struct task_struct *p) __ksym;
+
+	/* built against the new prototype: binds bpf_foo */
+	extern int bpf_foo(struct task_struct *p, u64 flags) __ksym;
+
+	/* the suffix doesn't select a kfunc: both bind bpf_foo___v1 */
+	extern int bpf_foo___v1(struct task_struct *p) __ksym;
+	extern int bpf_foo___local(struct task_struct *p) __ksym;
+
+	/* a stacked suffix binds nothing */
+	extern int bpf_foo___v1___local(struct task_struct *p) __ksym;
+
+Only libbpf 1.9 and later look for ``bpf_foo___v1`` when resolving ``bpf_foo``.
+Older libbpf and light skeletons see only ``bpf_foo``, as after an in-place
+change.
+
+If two kfunc names differ only in the ``___`` suffix, their prototypes must not
+match, not even for aliases: libbpf can't tell them apart and fails to load a
+program that declares either one, even as ``__weak``. For example, this widens
+an offset to 64 bits and keeps the old prototype as ``bpf_bar___v1``:
+
+.. code-block:: c
+
+	__bpf_kfunc int bpf_bar(const struct bpf_dynptr *p, u64 offset);
+
+	/* bpf_bar() before offset was widened */
+	__bpf_kfunc int bpf_bar___v1(const struct bpf_dynptr *p, u32 offset);
+
+``resolve_btfids`` rejects it::
+
+	ERROR: resolve_btfids: kfuncs bpf_bar and bpf_bar___v1 have matching prototypes
+
+Widening keeps the prototype matching, so it is done in place instead: drop
+``bpf_bar___v1``, and programs built against the old prototype bind
+``bpf_bar``. ``resolve_btfids`` checks registered kfuncs within vmlinux or one
+module. libbpf catches other matches, such as between two modules, when loading
+the program.
+
+Give the new prototype a name outside the family, not ``<name>___*``, if:
+
+- programs loaded by older libbpf or light skeletons must keep working, or
+- the prototypes match but the change breaks callers, e.g. two integer
+  parameters swap places.
+
+Older libbpf resolves ``bpf_foo___v1`` only from a declaration with a stacked
+suffix, such as ``bpf_foo___v1___compat``, and light skeletons only from
+``bpf_foo___v1`` itself. Don't rename a ``<name>___vN`` kfunc while programs
+declaring it that way are in use. libbpf 1.9 and later bind by prototype, so a
+rename doesn't affect them.
+
 4. Core kfuncs
 ==============
 
diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index 49dabf2eded04d..ded4a9e797281e 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -28,10 +28,10 @@ LIBBPF_BOOTSTRAP_INCLUDE := $(LIBBPF_BOOTSTRAP_DESTDIR)include
 LIBBPF_BOOTSTRAP_HDRS_DIR := $(LIBBPF_BOOTSTRAP_INCLUDE)/bpf
 LIBBPF_BOOTSTRAP := $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a
 
-# We need to copy hashmap.h, nlattr.h, relo_core.h and libbpf_internal.h
+# We need to copy hashmap.h, nlattr.h, relo_core.h and libbpf_tools.h
 # which are not otherwise exported by libbpf, but still required by bpftool.
-LIBBPF_INTERNAL_HDRS := $(addprefix $(LIBBPF_HDRS_DIR)/,hashmap.h nlattr.h relo_core.h libbpf_internal.h)
-LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hashmap.h relo_core.h libbpf_internal.h)
+LIBBPF_INTERNAL_HDRS := $(addprefix $(LIBBPF_HDRS_DIR)/,hashmap.h nlattr.h relo_core.h libbpf_tools.h)
+LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hashmap.h relo_core.h libbpf_tools.h)
 
 $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR) $(LIBBPF_BOOTSTRAP_HDRS_DIR):
 	$(QUIET_MKDIR)mkdir -p $@
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index ca5fa2f0bf9b14..1f2099c17252a4 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -31,7 +31,7 @@
 #include <bpf/bpf.h>
 #include <bpf/hashmap.h>
 #include <bpf/libbpf.h> /* libbpf_num_possible_cpus */
-#include <bpf/libbpf_internal.h>
+#include <bpf/libbpf_tools.h>
 #include <bpf/btf.h>
 #include <zlib.h>
 
diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index ee680f7c211602..dc0adeacf9a812 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -15,7 +15,8 @@
 #include <unistd.h>
 #include <bpf/bpf.h>
 #include <bpf/libbpf.h>
-#include <bpf/libbpf_internal.h>
+#include <bpf/libbpf_tools.h>
+#include <bpf/relo_core.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 15efc6eebffb1b..a7b2ea9fbd8072 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -29,7 +29,7 @@
 #include <bpf/btf.h>
 #include <bpf/hashmap.h>
 #include <bpf/libbpf.h>
-#include <bpf/libbpf_internal.h>
+#include <bpf/libbpf_tools.h>
 #include <bpf/skel_internal.h>
 
 #include "cfg.h"
diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c
index 5579173a61e3b5..fc83785c0ae3a1 100644
--- a/tools/bpf/bpftool/xlated_dumper.c
+++ b/tools/bpf/bpftool/xlated_dumper.c
@@ -10,7 +10,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <bpf/libbpf.h>
-#include <bpf/libbpf_internal.h>
+#include <bpf/libbpf_tools.h>
 
 #include "disasm.h"
 #include "json_writer.h"
diff --git a/tools/bpf/resolve_btfids/btf_colors.c b/tools/bpf/resolve_btfids/btf_colors.c
index 5d307d70e7f220..7374aa2f8963fd 100644
--- a/tools/bpf/resolve_btfids/btf_colors.c
+++ b/tools/bpf/resolve_btfids/btf_colors.c
@@ -1,18 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0-only
-#include <bpf/libbpf_internal.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <bpf/libbpf_tools.h>
 #include "btf_colors.h"
 
-/*
- * Functions in this file mainly exist to refer to functions from libbpf_internal.h,
- * which can't be included in main.c because of the u32 poison and pr_warn macro conflicts.
- */
-
-void btf_sha256(const void *data, size_t len,
-		__u8 out[BTF_SHA256_DIGEST_LENGTH])
-{
-	libbpf_sha256(data, len, out);
-}
-
 /*
  * Marks `root_id` and local types reachable from it with `color`.
  * `colors` is indexed by source ID; worklist has room for every local type.
diff --git a/tools/bpf/resolve_btfids/btf_colors.h b/tools/bpf/resolve_btfids/btf_colors.h
index 56a85a242d6bdc..9cea757cb356ec 100644
--- a/tools/bpf/resolve_btfids/btf_colors.h
+++ b/tools/bpf/resolve_btfids/btf_colors.h
@@ -11,10 +11,6 @@ enum btf_color {
 	BTF_COLOR_SHARED = BTF_COLOR_MAIN | BTF_COLOR_LOC,
 };
 
-#define BTF_SHA256_DIGEST_LENGTH	32
-
-void btf_sha256(const void *data, size_t len,
-		__u8 out[BTF_SHA256_DIGEST_LENGTH]);
 void btf_mark_reachable(struct btf *btf, __u32 root, enum btf_color color,
 			__u8 *colors, __u32 *worklist);
 
diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c
index 0ac895222a1407..e21ac684387309 100644
--- a/tools/bpf/resolve_btfids/main.c
+++ b/tools/bpf/resolve_btfids/main.c
@@ -93,12 +93,15 @@
 #include <linux/limits.h>
 #include <bpf/btf.h>
 #include <bpf/libbpf.h>
+#include <bpf/libbpf_tools.h>
+#include <bpf/relo_core.h>
 #include "btf_colors.h"
 #include "fmodret.h"
 #include <subcmd/parse-options.h>
 
 #define BTF_IDS_SECTION	".BTF_ids"
 #define BTF_LINK_MODULE_NAME_MAX	64
+#define BTF_SHA256_DIGEST_LENGTH	SHA256_DIGEST_LENGTH
 #define BTF_ID_PREFIX	"__BTF_ID__"
 
 #define BTF_STRUCT	"struct"
@@ -1205,8 +1208,7 @@ static int patch_btf_link(struct object *obj, const struct btf_link *link)
 	}
 	memset(data->d_buf, 0, data->d_size);
 	memcpy(data->d_buf, link->module, strlen(link->module) + 1);
-	btf_sha256(raw_btf_data, raw_btf_size,
-		   (u8 *)data->d_buf + module_name_len);
+	libbpf_sha256(raw_btf_data, raw_btf_size, (u8 *)data->d_buf + module_name_len);
 	size = (u8 *)data->d_buf + module_name_len + BTF_SHA256_DIGEST_LENGTH;
 	if (obj->efile.encoding == ELFDATA2LSB) {
 		size[0] = raw_btf_size;
@@ -1917,6 +1919,70 @@ static int sort_btf_by_name(struct btf *btf)
 	return err;
 }
 
+struct kfunc_variant {
+	const char *name;
+	size_t essent_len;
+	u32 id;
+};
+
+static int cmp_kfunc_variants(const void *lhs, const void *rhs)
+{
+	const struct kfunc_variant *a = lhs, *b = rhs;
+	int ret = strncmp(a->name, b->name, min(a->essent_len, b->essent_len));
+
+	return ret ?: (a->essent_len > b->essent_len) - (a->essent_len < b->essent_len);
+}
+
+/* libbpf rejects a declaration that matches more than one kfunc variant */
+static int check_kfunc_variants(const struct btf *btf)
+{
+	const struct btf *base = btf__base_btf(btf);
+	struct kfunc_variant *kfuncs = NULL;
+	u32 cnt = 0, cap = 0;
+	int err = 0;
+
+	for (u32 id = base ? btf__type_cnt(base) : 1; id < btf__type_cnt(btf); id++) {
+		const struct btf_type *t = btf__type_by_id(btf, id);
+		const char *name;
+
+		if (!btf_is_decl_tag(t) || btf_decl_tag(t)->component_idx != -1)
+			continue;
+		if (strcmp(btf__name_by_offset(btf, t->name_off), DECL_TAG_KFUNC) != 0)
+			continue;
+
+		err = ensure_mem(&kfuncs, &cap, cnt + 1);
+		if (err)
+			goto out;
+		name = btf__name_by_offset(btf, btf__type_by_id(btf, t->type)->name_off);
+		kfuncs[cnt++] = (struct kfunc_variant){
+			.name = name,
+			.essent_len = bpf_core_essential_name_len(name),
+			.id = t->type,
+		};
+	}
+	qsort(kfuncs, cnt, sizeof(*kfuncs), cmp_kfunc_variants);
+
+	for (u32 i = 0; i < cnt; i++) {
+		const struct btf_type *a = btf__type_by_id(btf, kfuncs[i].id);
+
+		for (u32 j = i + 1; j < cnt; j++) {
+			const struct btf_type *b;
+
+			if (cmp_kfunc_variants(&kfuncs[i], &kfuncs[j]) != 0)
+				break;
+			b = btf__type_by_id(btf, kfuncs[j].id);
+			if (btf_kfunc_proto_match(btf, a->type, btf, b->type) <= 0)
+				continue;
+			pr_err("ERROR: resolve_btfids: kfuncs %s and %s have matching prototypes\n",
+			       kfuncs[i].name, kfuncs[j].name);
+			err = -EINVAL;
+		}
+	}
+out:
+	free(kfuncs);
+	return err;
+}
+
 static int finalize_btf(struct object *obj)
 {
 	struct btf *base_btf = obj->base_btf, *btf = obj->btf;
@@ -1928,6 +1994,10 @@ static int finalize_btf(struct object *obj)
 		return err;
 	}
 
+	err = check_kfunc_variants(obj->btf);
+	if (err)
+		return err;
+
 	if (obj->base_btf && obj->distill_base) {
 		err = btf__distill_base(obj->btf, &base_btf, &btf);
 		if (err) {
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index a4bf01403a4338..71cba0b9bbfec0 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -1140,7 +1140,7 @@ static void btf_check_sorted(struct btf *btf)
 }
 
 static __s32 btf_find_type_by_name_bsearch(const struct btf *btf, const char *name,
-					   __s32 start_id)
+					   size_t name_len, __s32 start_id)
 {
 	const struct btf_type *t;
 	const char *tname;
@@ -1152,7 +1152,7 @@ static __s32 btf_find_type_by_name_bsearch(const struct btf *btf, const char *na
 		m = l + (r - l) / 2;
 		t = btf_type_by_id(btf, m);
 		tname = btf__str_by_offset(btf, t->name_off);
-		if (strcmp(tname, name) >= 0) {
+		if (strncmp(tname, name, name_len) >= 0) {
 			if (l == r)
 				return r;
 			r = m;
@@ -1164,6 +1164,99 @@ static __s32 btf_find_type_by_name_bsearch(const struct btf *btf, const char *na
 	return btf__type_cnt(btf);
 }
 
+/*
+ * Set [*start, *end) to the range of own type IDs that may match the
+ * first name_len bytes of name. For unsorted BTF, include all own type IDs.
+ */
+void btf_name_prefix_range(const struct btf *btf, const char *name, size_t name_len,
+			   __u32 *start, __u32 *end)
+{
+	__u32 i, n = btf__type_cnt(btf);
+
+	if (btf->named_start_id <= 0) {
+		*start = btf->start_id;
+		*end = n;
+		return;
+	}
+	*start = btf_find_type_by_name_bsearch(btf, name, name_len, btf->named_start_id);
+	for (i = *start; i < n; i++) {
+		const struct btf_type *t = btf_type_by_id(btf, i);
+		const char *tname = btf__str_by_offset(btf, t->name_off);
+
+		if (strncmp(tname, name, name_len) != 0)
+			break;
+	}
+	*end = i;
+}
+
+static __u16 kfunc_type_kind(const struct btf_type *t)
+{
+	if (btf_is_fwd(t))
+		return btf_kflag(t) ? BTF_KIND_UNION : BTF_KIND_STRUCT;
+	if (btf_is_enum64(t))
+		return BTF_KIND_ENUM;
+	return btf_kind(t);
+}
+
+/*
+ * Return 1 if the types match, 0 if they don't, or -EINVAL if a type
+ * can't be looked up or the types nest deeper than depth.
+ */
+static int kfunc_type_match(const struct btf *a, __u32 a_id,
+			    const struct btf *b, __u32 b_id, int depth)
+{
+	const struct btf_type *at = skip_mods_and_typedefs(a, a_id, NULL);
+	const struct btf_type *bt = skip_mods_and_typedefs(b, b_id, NULL);
+	__u16 kind;
+	int i, ret;
+
+	if (!at || !bt || !depth)
+		return -EINVAL;
+
+	kind = kfunc_type_kind(at);
+	if (kind != kfunc_type_kind(bt))
+		return 0;
+
+	switch (kind) {
+	case BTF_KIND_STRUCT:
+	case BTF_KIND_UNION: {
+		const char *an = btf__name_by_offset(a, at->name_off);
+		const char *bn = btf__name_by_offset(b, bt->name_off);
+		size_t name_len = bpf_core_essential_name_len(an);
+
+		return name_len == bpf_core_essential_name_len(bn) &&
+		       strncmp(an, bn, name_len) == 0;
+	}
+	case BTF_KIND_UNKN:
+	case BTF_KIND_ENUM:
+		return 1;
+	case BTF_KIND_INT:
+		return btf_int_offset(at) == 0 && btf_int_offset(bt) == 0;
+	case BTF_KIND_PTR:
+		return kfunc_type_match(a, at->type, b, bt->type, depth - 1);
+	case BTF_KIND_ARRAY:
+		return kfunc_type_match(a, btf_array(at)->type, b, btf_array(bt)->type, depth - 1);
+	case BTF_KIND_FUNC_PROTO:
+		if (btf_vlen(at) != btf_vlen(bt))
+			return 0;
+		for (i = 0; i < btf_vlen(at); i++) {
+			ret = kfunc_type_match(a, btf_params(at)[i].type,
+					       b, btf_params(bt)[i].type, depth - 1);
+			if (ret <= 0)
+				return ret;
+		}
+		return kfunc_type_match(a, at->type, b, bt->type, depth - 1);
+	default:
+		return 0;
+	}
+}
+
+int btf_kfunc_proto_match(const struct btf *a, __u32 a_id,
+			  const struct btf *b, __u32 b_id)
+{
+	return kfunc_type_match(a, a_id, b, b_id, 32);
+}
+
 static __s32 btf_find_by_name_kind(const struct btf *btf, int start_id,
 				   const char *type_name, __s32 kind)
 {
@@ -1185,7 +1278,7 @@ static __s32 btf_find_by_name_kind(const struct btf *btf, int start_id,
 
 	if (btf->named_start_id > 0 && type_name[0]) {
 		start_id = max(start_id, btf->named_start_id);
-		id = btf_find_type_by_name_bsearch(btf, type_name, start_id);
+		id = btf_find_type_by_name_bsearch(btf, type_name, strlen(type_name), start_id);
 		for (; id < nr_types; id++) {
 			t = btf__type_by_id(btf, id);
 			tname = btf__str_by_offset(btf, t->name_off);
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 1efc0dd37b2e65..dadf446daa0b14 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -641,7 +641,6 @@ struct extern_desc {
 	int btf_id;
 	int sec_btf_id;
 	char *name;
-	char *essent_name;
 	bool is_set;
 	bool is_weak;
 	union {
@@ -4446,7 +4445,6 @@ static int bpf_object__collect_externs(struct bpf_object *obj)
 	struct extern_desc *ext;
 	int i, n, off, dummy_var_btf_id;
 	const char *ext_name, *sec_name;
-	size_t ext_essent_len;
 	Elf_Scn *scn;
 	Elf64_Shdr *sh;
 
@@ -4498,14 +4496,6 @@ static int bpf_object__collect_externs(struct bpf_object *obj)
 		ext->sym_idx = i;
 		ext->is_weak = ELF64_ST_BIND(sym->st_info) == STB_WEAK;
 
-		ext_essent_len = bpf_core_essential_name_len(ext->name);
-		ext->essent_name = NULL;
-		if (ext_essent_len != strlen(ext->name)) {
-			ext->essent_name = strndup(ext->name, ext_essent_len);
-			if (!ext->essent_name)
-				return -ENOMEM;
-		}
-
 		ext->sec_btf_id = find_extern_sec_btf_id(obj->btf, ext->btf_id);
 		if (ext->sec_btf_id <= 0) {
 			pr_warn("failed to find BTF for extern '%s' [%d] section: %d\n",
@@ -9513,41 +9503,96 @@ static int bpf_object__resolve_ksym_var_btf_id(struct bpf_object *obj,
 	return 0;
 }
 
+/* t is a FUNC whose essential name is the first name_len bytes of name */
+static bool btf_is_kfunc_candidate(const struct btf *btf, const struct btf_type *t,
+				   const char *name, size_t name_len)
+{
+	const char *tname;
+
+	if (!btf_is_func(t))
+		return false;
+	tname = btf__name_by_offset(btf, t->name_off);
+	if (strncmp(tname, name, name_len) != 0)
+		return false;
+	return bpf_core_essential_name_len(tname) == name_len;
+}
+
+/*
+ * Search vmlinux and module BTFs. Return:
+ *   - a BTF ID for a unique match;
+ *   - -ESRCH if the family is absent;
+ *   - -EINVAL if no candidate has a compatible prototype;
+ *   - -ENOTUNIQ if more than one candidate has a compatible prototype.
+ */
+static int find_kfunc_btf_id(struct bpf_object *obj, const struct extern_desc *ext,
+			     struct btf **res_btf, struct module_btf **res_mod_btf)
+{
+	size_t name_len = bpf_core_essential_name_len(ext->name);
+	int kfunc_id = 0, nr_cands = 0;
+	size_t i;
+
+	for (i = 0; i <= obj->btf_module_cnt; i++) {
+		struct module_btf *mod = i ? &obj->btf_modules[i - 1] : NULL;
+		struct btf *btf = mod ? mod->btf : obj->btf_vmlinux;
+		__u32 id, end;
+
+		btf_name_prefix_range(btf, ext->name, name_len, &id, &end);
+		for (; id < end; id++) {
+			const struct btf_type *t = btf__type_by_id(btf, id);
+
+			if (!btf_is_kfunc_candidate(btf, t, ext->name, name_len))
+				continue;
+			nr_cands++;
+			if (btf_kfunc_proto_match(obj->btf, ext->ksym.type_id, btf, t->type) <= 0)
+				continue;
+			if (kfunc_id)
+				return -ENOTUNIQ;
+			kfunc_id = id;
+			*res_btf = btf;
+			*res_mod_btf = mod;
+		}
+	}
+	if (!nr_cands)
+		return -ESRCH;
+	if (!kfunc_id)
+		return -EINVAL;
+	return kfunc_id;
+}
+
 static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,
 						struct extern_desc *ext)
 {
-	int local_func_proto_id, kfunc_proto_id, kfunc_id;
 	struct module_btf *mod_btf = NULL;
 	const struct btf_type *kern_func;
 	struct btf *kern_btf = NULL;
-	int ret;
+	int kfunc_id, ret;
 
-	local_func_proto_id = ext->ksym.type_id;
+	ret = load_module_btfs(obj);
+	if (ret)
+		return ret;
 
-	kfunc_id = find_ksym_btf_id(obj, ext->essent_name ?: ext->name, BTF_KIND_FUNC, &kern_btf,
-				    &mod_btf);
-	if (kfunc_id < 0) {
-		if (kfunc_id == -ESRCH && ext->is_weak)
+	kfunc_id = find_kfunc_btf_id(obj, ext, &kern_btf, &mod_btf);
+	if (kfunc_id == -ESRCH) {
+		if (ext->is_weak)
 			return 0;
 		pr_warn("extern (func ksym) '%s': not found in kernel or module BTFs\n",
 			ext->name);
 		return kfunc_id;
 	}
-
-	kern_func = btf__type_by_id(kern_btf, kfunc_id);
-	kfunc_proto_id = kern_func->type;
-
-	ret = bpf_core_types_are_compat(obj->btf, local_func_proto_id,
-					kern_btf, kfunc_proto_id);
-	if (ret <= 0) {
+	if (kfunc_id == -EINVAL) {
 		if (ext->is_weak)
 			return 0;
-
-		pr_warn("extern (func ksym) '%s': func_proto [%d] incompatible with %s [%d]\n",
-			ext->name, local_func_proto_id,
-			mod_btf ? mod_btf->name : "vmlinux", kfunc_proto_id);
-		return -EINVAL;
+		pr_warn("extern (func ksym) '%s': no compatible prototype in kernel or module BTFs\n",
+			ext->name);
+		return kfunc_id;
 	}
+	/* an error even for a weak kfunc: ambiguity isn't absence */
+	if (kfunc_id == -ENOTUNIQ) {
+		pr_warn("extern (func ksym) '%s': more than one compatible prototype in kernel or module BTFs\n",
+			ext->name);
+		return kfunc_id;
+	}
+	kern_func = btf__type_by_id(kern_btf, kfunc_id);
 
 	/* set index for module BTF fd in fd_array, if unset */
 	if (mod_btf && !mod_btf->fd_array_idx) {
@@ -9579,8 +9624,9 @@ static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,
 	 * {kernel_btf_id, kernel_btf_obj_fd} -> fixup ld_imm64.
 	 */
 	ext->ksym.kernel_btf_obj_fd = mod_btf ? mod_btf->fd : 0;
-	pr_debug("extern (func ksym) '%s': resolved to %s [%d]\n",
-		 ext->name, mod_btf ? mod_btf->name : "vmlinux", kfunc_id);
+	pr_debug("extern (func ksym) '%s': resolved to %s '%s' [%d]\n",
+		 ext->name, mod_btf ? mod_btf->name : "vmlinux",
+		 btf__name_by_offset(kern_btf, kern_func->name_off), kfunc_id);
 
 	return 0;
 }
@@ -10441,10 +10487,8 @@ void bpf_object__close(struct bpf_object *obj)
 	zfree(&obj->btf_custom_path);
 	zfree(&obj->kconfig);
 
-	for (i = 0; i < obj->nr_extern; i++) {
+	for (i = 0; i < obj->nr_extern; i++)
 		zfree(&obj->externs[i].name);
-		zfree(&obj->externs[i].essent_name);
-	}
 
 	zfree(&obj->externs);
 	obj->nr_extern = 0;
diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index e90b5336bac01a..389c48548222bd 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -18,6 +18,7 @@
 #include <unistd.h>
 #include <sys/syscall.h>
 #include <libelf.h>
+#include "libbpf_tools.h"
 #include "relo_core.h"
 
 /* Android's libc doesn't support AT_EACCESS in faccessat() implementation
@@ -94,12 +95,6 @@
 #define BTF_TYPE_TYPE_TAG_ENC(value, type) \
 	BTF_TYPE_ENC(value, BTF_INFO_ENC(BTF_KIND_TYPE_TAG, 0, 0), type)
 
-#ifndef likely
-#define likely(x) __builtin_expect(!!(x), 1)
-#endif
-#ifndef unlikely
-#define unlikely(x) __builtin_expect(!!(x), 0)
-#endif
 #ifndef min
 # define min(x, y) ((x) < (y) ? (x) : (y))
 #endif
@@ -184,10 +179,6 @@ const char *libbpf_errstr(int err);
 
 #define errstr(err) libbpf_errstr(err)
 
-#ifndef __has_builtin
-#define __has_builtin(x) 0
-#endif
-
 struct bpf_link {
 	int (*detach)(struct bpf_link *link);
 	void (*dealloc)(struct bpf_link *link);
@@ -196,30 +187,6 @@ struct bpf_link {
 	bool disconnected;
 };
 
-/*
- * Re-implement glibc's reallocarray() for libbpf internal-only use.
- * reallocarray(), unfortunately, is not available in all versions of glibc,
- * so requires extra feature detection and using reallocarray() stub from
- * <tools/libc_compat.h> and COMPAT_NEED_REALLOCARRAY. All this complicates
- * build of libbpf unnecessarily and is just a maintenance burden. Instead,
- * it's trivial to implement libbpf-specific internal version and use it
- * throughout libbpf.
- */
-static inline void *libbpf_reallocarray(void *ptr, size_t nmemb, size_t size)
-{
-	size_t total;
-
-#if __has_builtin(__builtin_mul_overflow)
-	if (unlikely(__builtin_mul_overflow(nmemb, size, &total)))
-		return NULL;
-#else
-	if (size == 0 || nmemb > ULONG_MAX / size)
-		return NULL;
-	total = nmemb * size;
-#endif
-	return realloc(ptr, total);
-}
-
 /* Copy up to sz - 1 bytes from zero-terminated src string and ensure that dst
  * is zero-terminated string no matter what (unless sz == 0, in which case
  * it's a no-op). It's conceptually close to FreeBSD's strlcpy(), but differs
@@ -245,12 +212,11 @@ struct btf;
 struct btf_type;
 
 struct btf_type *btf_type_by_id(const struct btf *btf, __u32 type_id);
-const char *btf_kind_str(const struct btf_type *t);
-const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);
-const struct btf_header *btf_header(const struct btf *btf);
 void btf_set_base_btf(struct btf *btf, const struct btf *base_btf);
 int btf_relocate(struct btf *btf, const struct btf *base_btf, __u32 **id_map,
 		 __u32 **str_map);
+void btf_name_prefix_range(const struct btf *btf, const char *name, size_t name_len,
+			   __u32 *start, __u32 *end);
 bool btf_type_is_traceable_func(const struct btf *btf, const struct btf_type *t);
 
 static inline enum btf_func_linkage btf_func_linkage(const struct btf_type *t)
@@ -431,7 +397,6 @@ int probe_memcg_account(int token_fd);
 int bump_rlimit_memlock(void);
 
 int parse_cpu_mask_str(const char *s, bool **mask, int *mask_sz);
-int parse_cpu_mask_file(const char *fcpu, bool **mask, int *mask_sz);
 int libbpf__load_raw_btf(const char *raw_types, size_t types_len,
 			 const char *str_sec, size_t str_len,
 			 int token_fd);
@@ -448,92 +413,6 @@ struct btf *btf_get_from_fd(int btf_fd, struct btf *base_btf);
 void btf_get_kernel_prefix_kind(enum bpf_attach_type attach_type,
 				const char **prefix, int *kind);
 
-struct btf_ext_info {
-	/*
-	 * info points to the individual info section (e.g. func_info and
-	 * line_info) from the .BTF.ext. It does not include the __u32 rec_size.
-	 */
-	void *info;
-	__u32 rec_size;
-	__u32 len;
-	/* optional (maintained internally by libbpf) mapping between .BTF.ext
-	 * section and corresponding ELF section. This is used to join
-	 * information like CO-RE relocation records with corresponding BPF
-	 * programs defined in ELF sections
-	 */
-	__u32 *sec_idxs;
-	int sec_cnt;
-};
-
-#define for_each_btf_ext_sec(seg, sec)					\
-	for (sec = (seg)->info;						\
-	     (void *)sec < (seg)->info + (seg)->len;			\
-	     sec = (void *)sec + sizeof(struct btf_ext_info_sec) +	\
-		   (seg)->rec_size * sec->num_info)
-
-#define for_each_btf_ext_rec(seg, sec, i, rec)				\
-	for (i = 0, rec = (void *)&(sec)->data;				\
-	     i < (sec)->num_info;					\
-	     i++, rec = (void *)rec + (seg)->rec_size)
-
-/*
- * The .BTF.ext ELF section layout defined as
- *   struct btf_ext_header
- *   func_info subsection
- *
- * The func_info subsection layout:
- *   record size for struct bpf_func_info in the func_info subsection
- *   struct btf_ext_info_sec for section #1
- *   a list of bpf_func_info records for section #1
- *     where struct bpf_func_info mimics one in include/uapi/linux/bpf.h
- *     but may not be identical
- *   struct btf_ext_info_sec for section #2
- *   a list of bpf_func_info records for section #2
- *   ......
- *
- * Note that the bpf_func_info record size in .BTF.ext may not
- * be the same as the one defined in include/uapi/linux/bpf.h.
- * The loader should ensure that record_size meets minimum
- * requirement and pass the record as is to the kernel. The
- * kernel will handle the func_info properly based on its contents.
- */
-struct btf_ext_header {
-	__u16	magic;
-	__u8	version;
-	__u8	flags;
-	__u32	hdr_len;
-
-	/* All offsets are in bytes relative to the end of this header */
-	__u32	func_info_off;
-	__u32	func_info_len;
-	__u32	line_info_off;
-	__u32	line_info_len;
-
-	/* optional part of .BTF.ext header */
-	__u32	core_relo_off;
-	__u32	core_relo_len;
-};
-
-struct btf_ext {
-	union {
-		struct btf_ext_header *hdr;
-		void *data;
-	};
-	void *data_swapped;
-	bool swapped_endian;
-	struct btf_ext_info func_info;
-	struct btf_ext_info line_info;
-	struct btf_ext_info core_relo_info;
-	__u32 data_size;
-};
-
-struct btf_ext_info_sec {
-	__u32	sec_name_off;
-	__u32	num_info;
-	/* Followed by num_info * record_size number of bytes */
-	__u8	data[];
-};
-
 /* The minimum bpf_func_info checked by the loader */
 struct bpf_func_info_min {
 	__u32   insn_off;
@@ -574,31 +453,6 @@ static inline void bpf_core_relo_bswap(struct bpf_core_relo *i)
 	i->kind = bswap_32(i->kind);
 }
 
-enum btf_field_iter_kind {
-	BTF_FIELD_ITER_IDS,
-	BTF_FIELD_ITER_STRS,
-};
-
-struct btf_field_desc {
-	/* once-per-type offsets */
-	int t_off_cnt, t_offs[2];
-	/* member struct size, or zero, if no members */
-	int m_sz;
-	/* repeated per-member offsets */
-	int m_off_cnt, m_offs[2];
-};
-
-struct btf_field_iter {
-	struct btf_field_desc desc;
-	void *p;
-	int m_idx;
-	int off_idx;
-	int vlen;
-};
-
-int btf_field_iter_init(struct btf_field_iter *it, struct btf_type *t, enum btf_field_iter_kind iter_kind);
-__u32 *btf_field_iter_next(struct btf_field_iter *it);
-
 typedef int (*type_id_visit_fn)(__u32 *type_id, void *ctx);
 typedef int (*str_off_visit_fn)(__u32 *str_off, void *ctx);
 int btf_ext_visit_type_ids(struct btf_ext *btf_ext, type_id_visit_fn visit, void *ctx);
@@ -721,15 +575,6 @@ static inline int reuse_fd(int fixed_fd, int tmp_fd)
 	return err;
 }
 
-/* The following two functions are exposed to bpftool */
-int bpf_core_add_cands(struct bpf_core_cand *local_cand,
-		       size_t local_essent_len,
-		       const struct btf *targ_btf,
-		       const char *targ_btf_name,
-		       int targ_start_id,
-		       struct bpf_core_cand_list *cands);
-void bpf_core_free_cands(struct bpf_core_cand_list *cands);
-
 struct usdt_manager *usdt_manager_new(struct bpf_object *obj);
 void usdt_manager_free(struct usdt_manager *man);
 struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man,
@@ -772,8 +617,5 @@ int elf_resolve_pattern_offsets(const char *binary_path, const char *pattern,
 
 int probe_fd(int fd);
 
-#define SHA256_DIGEST_LENGTH 32
-
-void libbpf_sha256(const void *data, size_t len, __u8 out[SHA256_DIGEST_LENGTH]);
 int probe_sys_bpf_ext(void);
 #endif /* __LIBBPF_LIBBPF_INTERNAL_H */
diff --git a/tools/lib/bpf/libbpf_tools.h b/tools/lib/bpf/libbpf_tools.h
new file mode 100644
index 00000000000000..cd9137376d443a
--- /dev/null
+++ b/tools/lib/bpf/libbpf_tools.h
@@ -0,0 +1,186 @@
+/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
+#ifndef __LIBBPF_TOOLS_H
+#define __LIBBPF_TOOLS_H
+
+#include <limits.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <linux/types.h>
+
+/* Internal interfaces for kernel tools that link libbpf statically. */
+
+#ifndef likely
+#define likely(x) __builtin_expect(!!(x), 1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#endif
+
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+
+/*
+ * Re-implement glibc's reallocarray() for libbpf internal-only use.
+ * reallocarray(), unfortunately, is not available in all versions of glibc,
+ * so requires extra feature detection and using reallocarray() stub from
+ * <tools/libc_compat.h> and COMPAT_NEED_REALLOCARRAY. All this complicates
+ * build of libbpf unnecessarily and is just a maintenance burden. Instead,
+ * it's trivial to implement libbpf-specific internal version and use it
+ * throughout libbpf.
+ */
+static inline void *libbpf_reallocarray(void *ptr, size_t nmemb, size_t size)
+{
+	size_t total;
+
+#if __has_builtin(__builtin_mul_overflow)
+	if (unlikely(__builtin_mul_overflow(nmemb, size, &total)))
+		return NULL;
+#else
+	if (size == 0 || nmemb > ULONG_MAX / size)
+		return NULL;
+	total = nmemb * size;
+#endif
+	return realloc(ptr, total);
+}
+
+struct btf;
+struct btf_header;
+struct btf_type;
+struct bpf_core_cand;
+struct bpf_core_cand_list;
+
+const struct btf_header *btf_header(const struct btf *btf);
+int btf_kfunc_proto_match(const struct btf *a, __u32 a_id,
+			  const struct btf *b, __u32 b_id);
+const char *btf_kind_str(const struct btf_type *t);
+const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);
+
+enum btf_field_iter_kind {
+	BTF_FIELD_ITER_IDS,
+	BTF_FIELD_ITER_STRS,
+};
+
+struct btf_field_desc {
+	/* once-per-type offsets */
+	int t_off_cnt, t_offs[2];
+	/* member struct size, or zero, if no members */
+	int m_sz;
+	/* repeated per-member offsets */
+	int m_off_cnt, m_offs[2];
+};
+
+struct btf_field_iter {
+	struct btf_field_desc desc;
+	void *p;
+	int m_idx;
+	int off_idx;
+	int vlen;
+};
+
+int btf_field_iter_init(struct btf_field_iter *it, struct btf_type *t,
+			enum btf_field_iter_kind iter_kind);
+__u32 *btf_field_iter_next(struct btf_field_iter *it);
+
+struct btf_ext_info {
+	/*
+	 * info points to the individual info section (e.g. func_info and
+	 * line_info) from the .BTF.ext. It does not include the __u32 rec_size.
+	 */
+	void *info;
+	__u32 rec_size;
+	__u32 len;
+	/* optional (maintained internally by libbpf) mapping between .BTF.ext
+	 * section and corresponding ELF section. This is used to join
+	 * information like CO-RE relocation records with corresponding BPF
+	 * programs defined in ELF sections
+	 */
+	__u32 *sec_idxs;
+	int sec_cnt;
+};
+
+#define for_each_btf_ext_sec(seg, sec)					\
+	for (sec = (seg)->info;						\
+	     (void *)sec < (seg)->info + (seg)->len;			\
+	     sec = (void *)sec + sizeof(struct btf_ext_info_sec) +	\
+		   (seg)->rec_size * sec->num_info)
+
+#define for_each_btf_ext_rec(seg, sec, i, rec)				\
+	for (i = 0, rec = (void *)&(sec)->data;				\
+	     i < (sec)->num_info;					\
+	     i++, rec = (void *)rec + (seg)->rec_size)
+
+/*
+ * The .BTF.ext ELF section layout defined as
+ *   struct btf_ext_header
+ *   func_info subsection
+ *
+ * The func_info subsection layout:
+ *   record size for struct bpf_func_info in the func_info subsection
+ *   struct btf_ext_info_sec for section #1
+ *   a list of bpf_func_info records for section #1
+ *     where struct bpf_func_info mimics one in include/uapi/linux/bpf.h
+ *     but may not be identical
+ *   struct btf_ext_info_sec for section #2
+ *   a list of bpf_func_info records for section #2
+ *   ......
+ *
+ * Note that the bpf_func_info record size in .BTF.ext may not
+ * be the same as the one defined in include/uapi/linux/bpf.h.
+ * The loader should ensure that record_size meets minimum
+ * requirement and pass the record as is to the kernel. The
+ * kernel will handle the func_info properly based on its contents.
+ */
+struct btf_ext_header {
+	__u16	magic;
+	__u8	version;
+	__u8	flags;
+	__u32	hdr_len;
+
+	/* All offsets are in bytes relative to the end of this header */
+	__u32	func_info_off;
+	__u32	func_info_len;
+	__u32	line_info_off;
+	__u32	line_info_len;
+
+	/* optional part of .BTF.ext header */
+	__u32	core_relo_off;
+	__u32	core_relo_len;
+};
+
+struct btf_ext {
+	union {
+		struct btf_ext_header *hdr;
+		void *data;
+	};
+	void *data_swapped;
+	bool swapped_endian;
+	struct btf_ext_info func_info;
+	struct btf_ext_info line_info;
+	struct btf_ext_info core_relo_info;
+	__u32 data_size;
+};
+
+struct btf_ext_info_sec {
+	__u32	sec_name_off;
+	__u32	num_info;
+	/* Followed by num_info * record_size number of bytes */
+	__u8	data[];
+};
+
+int bpf_core_add_cands(struct bpf_core_cand *local_cand,
+		       size_t local_essent_len,
+		       const struct btf *targ_btf,
+		       const char *targ_btf_name,
+		       int targ_start_id,
+		       struct bpf_core_cand_list *cands);
+void bpf_core_free_cands(struct bpf_core_cand_list *cands);
+
+int parse_cpu_mask_file(const char *fcpu, bool **mask, int *mask_sz);
+
+#define SHA256_DIGEST_LENGTH 32
+
+void libbpf_sha256(const void *data, size_t len, __u8 out[SHA256_DIGEST_LENGTH]);
+
+#endif /* __LIBBPF_TOOLS_H */
diff --git a/tools/sched_ext/include/scx/compat.bpf.h b/tools/sched_ext/include/scx/compat.bpf.h
index 254882bd8ce615..fcbf7908defdaf 100644
--- a/tools/sched_ext/include/scx/compat.bpf.h
+++ b/tools/sched_ext/include/scx/compat.bpf.h
@@ -29,8 +29,10 @@ struct cgroup *scx_bpf_task_cgroup___new(struct task_struct *p) __ksym __weak;
  * scx_bpf_dispatch_from_dsq() and friends were added during v6.12 by
  * 4c30f5ce4f7a ("sched_ext: Implement scx_bpf_dispatch[_vtime]_from_dsq()").
  *
- * v7.1: scx_bpf_dsq_move_to_local___v2() to add @enq_flags.
+ * v7.1: scx_bpf_dsq_move_to_local___v2() to add @enq_flags. Older libbpf can
+ * resolve it only through the extra ___compat suffix.
  */
+bool scx_bpf_dsq_move_to_local___v2(u64 dsq_id, u64 enq_flags) __ksym __weak;
 bool scx_bpf_dsq_move_to_local___v2___compat(u64 dsq_id, u64 enq_flags) __ksym __weak;
 bool scx_bpf_dsq_move_to_local___v1(u64 dsq_id) __ksym __weak;
 void scx_bpf_dsq_move_set_slice___new(struct bpf_iter_scx_dsq *it__iter, u64 slice) __ksym __weak;
@@ -45,11 +47,13 @@ bool scx_bpf_dispatch_from_dsq___old(struct bpf_iter_scx_dsq *it__iter, struct t
 bool scx_bpf_dispatch_vtime_from_dsq___old(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak;
 
 #define scx_bpf_dsq_move_to_local(dsq_id, enq_flags)				\
-	(bpf_ksym_exists(scx_bpf_dsq_move_to_local___v2___compat) ?		\
-	 scx_bpf_dsq_move_to_local___v2___compat((dsq_id), (enq_flags)) :	\
-	 (bpf_ksym_exists(scx_bpf_dsq_move_to_local___v1) ?			\
-	  scx_bpf_dsq_move_to_local___v1((dsq_id)) :				\
-	  scx_bpf_consume___old((dsq_id))))
+	(bpf_ksym_exists(scx_bpf_dsq_move_to_local___v2) ?			\
+	 scx_bpf_dsq_move_to_local___v2((dsq_id), (enq_flags)) :		\
+	 (bpf_ksym_exists(scx_bpf_dsq_move_to_local___v2___compat) ?		\
+	  scx_bpf_dsq_move_to_local___v2___compat((dsq_id), (enq_flags)) :	\
+	  (bpf_ksym_exists(scx_bpf_dsq_move_to_local___v1) ?			\
+	   scx_bpf_dsq_move_to_local___v1((dsq_id)) :				\
+	   scx_bpf_consume___old((dsq_id)))))
 
 #define scx_bpf_dsq_move_set_slice(it__iter, slice)				\
 	(bpf_ksym_exists(scx_bpf_dsq_move_set_slice___new) ?			\
@@ -430,12 +434,13 @@ scx_bpf_dsq_insert_vtime(struct task_struct *p, u64 dsq_id, u64 slice, u64 vtime
 /*
  * v6.19: scx_bpf_dsq_insert() now returns bool instead of void. Move
  * scx_bpf_dsq_insert() decl to common.bpf.h and drop compat helper after v6.22.
- * The extra ___compat suffix is to work around libbpf not ignoring __SUFFIX on
- * kernel side. The entire suffix can be dropped later.
+ * Older libbpf can resolve scx_bpf_dsq_insert___v2() only through the extra
+ * ___compat suffix.
  *
  * v6.13: scx_bpf_dsq_insert() renaming is also handled here. See the block on
  * dispatch renaming above for more details.
  */
+bool scx_bpf_dsq_insert___v2(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags) __ksym __weak;
 bool scx_bpf_dsq_insert___v2___compat(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags) __ksym __weak;
 void scx_bpf_dsq_insert___v1(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags) __ksym __weak;
 void scx_bpf_dispatch___compat(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags) __ksym __weak;
@@ -443,7 +448,9 @@ void scx_bpf_dispatch___compat(struct task_struct *p, u64 dsq_id, u64 slice, u64
 static inline bool
 scx_bpf_dsq_insert(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags)
 {
-	if (bpf_ksym_exists(scx_bpf_dsq_insert___v2___compat)) {
+	if (bpf_ksym_exists(scx_bpf_dsq_insert___v2)) {
+		return scx_bpf_dsq_insert___v2(p, dsq_id, slice, enq_flags);
+	} else if (bpf_ksym_exists(scx_bpf_dsq_insert___v2___compat)) {
 		return scx_bpf_dsq_insert___v2___compat(p, dsq_id, slice, enq_flags);
 	} else if (bpf_ksym_exists(scx_bpf_dsq_insert___v1)) {
 		scx_bpf_dsq_insert___v1(p, dsq_id, slice, enq_flags);
@@ -506,23 +513,32 @@ static inline bool __COMPAT_has_dsq_reenq_task(void)
 
 /*
  * v6.19: The new void variant can be called from anywhere while the older v1
- * variant can only be called from ops.cpu_release(). The double ___ prefixes on
- * the v2 variant need to be removed once libbpf is updated to ignore ___ prefix
- * on kernel side. Drop the wrapper and move the decl to common.bpf.h after
- * v6.22.
+ * variant can only be called from ops.cpu_release(). Older libbpf can resolve
+ * the v2 variant only through the extra ___compat suffix. Drop the wrapper and
+ * move the decl to common.bpf.h after v6.22.
  */
 u32 scx_bpf_reenqueue_local___v1(void) __ksym __weak;
+void scx_bpf_reenqueue_local___v2(void) __ksym __weak;
 void scx_bpf_reenqueue_local___v2___compat(void) __ksym __weak;
 
 static inline bool __COMPAT_scx_bpf_reenqueue_local_from_anywhere(void)
 {
-	return bpf_ksym_exists(scx_bpf_reenqueue_local___v2___compat);
+	bool v2 = bpf_ksym_exists(scx_bpf_reenqueue_local___v2);
+
+	/*
+	 * Without the barrier, clang folds || into a bitwise OR of the two ksym
+	 * addresses, which the verifier rejects.
+	 */
+	barrier_var(v2);
+	return v2 || bpf_ksym_exists(scx_bpf_reenqueue_local___v2___compat);
 }
 
 static inline void scx_bpf_reenqueue_local(void)
 {
 	if (__COMPAT_has_generic_reenq())
 		scx_bpf_dsq_reenq___compat(SCX_DSQ_LOCAL, 0);
+	else if (bpf_ksym_exists(scx_bpf_reenqueue_local___v2))
+		scx_bpf_reenqueue_local___v2();
 	else if (__COMPAT_scx_bpf_reenqueue_local_from_anywhere())
 		scx_bpf_reenqueue_local___v2___compat();
 	else
@@ -541,6 +557,10 @@ static inline int scx_bpf_reenqueue_local_from_anywhere(void)
 		scx_bpf_dsq_reenq___compat(SCX_DSQ_LOCAL, 0);
 		return 0;
 	}
+	if (bpf_ksym_exists(scx_bpf_reenqueue_local___v2)) {
+		scx_bpf_reenqueue_local___v2();
+		return 0;
+	}
 	if (__COMPAT_scx_bpf_reenqueue_local_from_anywhere()) {
 		scx_bpf_reenqueue_local___v2___compat();
 		return 0;
diff --git a/tools/testing/selftests/bpf/prog_tests/verifier.c b/tools/testing/selftests/bpf/prog_tests/verifier.c
index 816ab3cfafc745..157267f901771b 100644
--- a/tools/testing/selftests/bpf/prog_tests/verifier.c
+++ b/tools/testing/selftests/bpf/prog_tests/verifier.c
@@ -8,6 +8,7 @@
 #include "cap_helpers.h"
 #include "sysctl_helpers.h"
 #include "cb_refs.skel.h"
+#include "kfunc_variants.skel.h"
 #include "verifier_aggregate_arg.skel.h"
 #include "verifier_aggregate_ret.skel.h"
 #include "verifier_alu_range.skel.h"
@@ -225,6 +226,8 @@ void test_arena_kfunc_jit(void)               { RUN_TESTS(arena_kfunc_jit); }
 
 void test_cb_refs(void)                       { RUN_TESTS(cb_refs); }
 
+void test_kfunc_variants(void)                { RUN_TESTS(kfunc_variants); }
+
 void test_verifier_aggregate_arg(void)        { RUN_TESTS(verifier_aggregate_arg); }
 void test_verifier_aggregate_ret(void)        { RUN_TESTS(verifier_aggregate_ret); }
 void test_verifier_alu_range(void)            { RUN(verifier_alu_range); }
diff --git a/tools/testing/selftests/bpf/progs/kfunc_variants.c b/tools/testing/selftests/bpf/progs/kfunc_variants.c
new file mode 100644
index 00000000000000..a9c393ea9d82e0
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/kfunc_variants.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
+
+#include <vmlinux.h>
+#include <bpf/bpf_helpers.h>
+#include "bpf_misc.h"
+#include "../test_kmods/bpf_testmod_kfunc.h"
+
+extern int bpf_kfunc_variant___none(struct inode *p) __weak __ksym;
+
+char _license[] SEC("license") = "GPL";
+
+SEC("syscall")
+__retval(1)
+int unsuffixed_name(void *ctx)
+{
+	return bpf_kfunc_variant(NULL);
+}
+
+SEC("syscall")
+__retval(2)
+int kernel_variant(void *ctx)
+{
+	return bpf_kfunc_variant___v2(NULL);
+}
+
+SEC("syscall")
+__retval(0)
+int no_match(void *ctx)
+{
+	return bpf_ksym_exists(bpf_kfunc_variant___none);
+}
diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
index 1fbc0061cc2408..764877cdce6e20 100644
--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
@@ -1928,6 +1928,16 @@ __bpf_kfunc void bpf_kfunc_trigger_ctx_check(void)
 	irq_work_queue(&ctx_check_irq);
 }
 
+__bpf_kfunc int bpf_kfunc_variant(struct task_struct *p__nullable)
+{
+	return 1;
+}
+
+__bpf_kfunc int bpf_kfunc_variant___v2(struct file *p__nullable)
+{
+	return 2;
+}
+
 BTF_KFUNCS_START(bpf_testmod_check_kfunc_ids)
 BTF_ID_FLAGS(func, bpf_testmod_test_mod_kfunc, KF_SPINLOCK_SAFE)
 BTF_ID_FLAGS(func, bpf_kfunc_call_test1)
@@ -2019,6 +2029,8 @@ BTF_ID_FLAGS(func, bpf_kfunc_implicit_arg, KF_IMPLICIT_ARGS)
 BTF_ID_FLAGS(func, bpf_kfunc_implicit_arg_legacy, KF_IMPLICIT_ARGS)
 BTF_ID_FLAGS(func, bpf_kfunc_implicit_arg_legacy_impl)
 BTF_ID_FLAGS(func, bpf_kfunc_trigger_ctx_check)
+BTF_ID_FLAGS(func, bpf_kfunc_variant)
+BTF_ID_FLAGS(func, bpf_kfunc_variant___v2)
 BTF_KFUNCS_END(bpf_testmod_check_kfunc_ids)
 
 static int bpf_testmod_ops_init(struct btf *btf)
diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h b/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h
index 0a7df179860332..ce579eede88d53 100644
--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h
+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h
@@ -381,4 +381,7 @@ void bpf_testmod_test_hardirq_fn(void);
 void bpf_testmod_test_softirq_fn(void);
 void bpf_kfunc_trigger_ctx_check(void) __ksym;
 
+int bpf_kfunc_variant(struct task_struct *p__nullable) __ksym;
+int bpf_kfunc_variant___v2(struct file *p__nullable) __ksym;
+
 #endif /* _BPF_TESTMOD_KFUNC_H */

3/2 2026/11/30 04:23 llm patch-evaluator
0m Model:
gemini-4-hydrogen

Args:
null

Results:
null

Tokens:
							input: 21563
							output: 79
							thoughts: 962
						

Thoughts:
**Patch Analysis: WorthFuzzing Evaluation**

Alright, let's break down this patch. My initial scan of the files reveals: primarily documentation updates (`Documentation/bpf/kfuncs.rst`), user-space tools (`bpftool`), build-time tooling (`resolve_btfids`), the user-space library (`libbpf`), a BPF program header for `sched_ext`, and various selftests.

My immediate concern is always, "Does this touch the kernel itself, in a way that could introduce fuzzing targets?" I need to verify that. I know `resolve_btfids` runs during the kernel build process, populating `.BTF_ids` and checking kfunc variants at build time with `check_kfunc_variants(obj->btf)`. Critically, it *should* only be returning `-EINVAL` on build failure due to duplicate matching prototypes and not touching any runtime kernel code. User-space `libbpf`, `bpftool`, and the header in `tools/sched_ext` are clearly not directly involved in runtime kernel behavior. Selftests, including `bpf_testmod.c`, are also off-limits, being isolated in the `tools/testing/selftests/bpf/test_kmods/` directory.

I need to confirm that these tools don't get compiled into the kernel space. A quick check of file paths confirms that all the `tools/` directory content are host-side tools, userspace libraries, or selftests.

Now, let's cross-reference this with the "WorthFuzzing" criteria. The instructions specify: "Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/) that do not affect the compiled kernel image (vmlinux) or kernel modules."

So, the critical question: Does `resolve_btfids` affect the *compiled* kernel image? Let's drill into the code.

I see that `tools/bpf/resolve_btfids/main.c` has a refactoring from `btf_sha256` to `libbpf_sha256`, which is just a header file change, and the new `check_kfunc_variants(obj->btf)` in `finalize_btf(struct object *obj)` function. This function iterates through kfunc BTF tags, sorts them, compares matching names, and if a duplicate matching prototype is found, throws an error and returns `-EINVAL`. This does *not* modify any bytes within vmlinux or modules. The check happens at build time, and the failure of the check results in a build failure.

Just to be absolutely sure, I'll double-check this critical area with `read-file` on `tools/bpf/resolve_btfids/main.c`. My conclusion is that this is not worth fuzzing.



4/2 2026/11/30 04:23 tool read-file
0m Args:
{
  "File": "tools/bpf/resolve_btfids/main.c",
  "FirstLine": 1965,
  "LineCount": 65
}

Results:
{
  "Contents": "1965:\t\tfor (u32 i = 0; i \u003c cnt; i++) {\n1966:\t\t\tconst struct btf_type *a = btf__type_by_id(btf, kfuncs[i].id);\n1967:\t\n1968:\t\t\tfor (u32 j = i + 1; j \u003c cnt; j++) {\n1969:\t\t\t\tconst struct btf_type *b;\n1970:\t\n1971:\t\t\t\tif (cmp_kfunc_variants(\u0026kfuncs[i], \u0026kfuncs[j]) != 0)\n1972:\t\t\t\t\tbreak;\n1973:\t\t\t\tb = btf__type_by_id(btf, kfuncs[j].id);\n1974:\t\t\t\tif (btf_kfunc_proto_match(btf, a-\u003etype, btf, b-\u003etype) \u003c= 0)\n1975:\t\t\t\t\tcontinue;\n1976:\t\t\t\tpr_err(\"ERROR: resolve_btfids: kfuncs %s and %s have matching prototypes\\n\",\n1977:\t\t\t\t       kfuncs[i].name, kfuncs[j].name);\n1978:\t\t\t\terr = -EINVAL;\n1979:\t\t\t}\n1980:\t\t}\n1981:\tout:\n1982:\t\tfree(kfuncs);\n1983:\t\treturn err;\n1984:\t}\n1985:\t\n1986:\tstatic int finalize_btf(struct object *obj)\n1987:\t{\n1988:\t\tstruct btf *base_btf = obj-\u003ebase_btf, *btf = obj-\u003ebtf;\n1989:\t\tint err;\n1990:\t\n1991:\t\terr = btf__dedup(obj-\u003ebtf, NULL);\n1992:\t\tif (err) {\n1993:\t\t\tpr_err(\"FAILED to dedup BTF: %s\\n\", strerror(errno));\n1994:\t\t\treturn err;\n1995:\t\t}\n1996:\t\n1997:\t\terr = check_kfunc_variants(obj-\u003ebtf);\n1998:\t\tif (err)\n1999:\t\t\treturn err;\n2000:\t\n2001:\t\tif (obj-\u003ebase_btf \u0026\u0026 obj-\u003edistill_base) {\n2002:\t\t\terr = btf__distill_base(obj-\u003ebtf, \u0026base_btf, \u0026btf);\n2003:\t\t\tif (err) {\n2004:\t\t\t\tpr_err(\"FAILED to distill base BTF: %s\\n\", strerror(errno));\n2005:\t\t\t\treturn err;\n2006:\t\t\t}\n2007:\t\n2008:\t\t\tbtf__free(obj-\u003ebase_btf);\n2009:\t\t\tbtf__free(obj-\u003ebtf);\n2010:\t\t\tobj-\u003ebase_btf = base_btf;\n2011:\t\t\tobj-\u003ebtf = btf;\n2012:\t\t}\n2013:\t\n2014:\t\terr = sort_btf_by_name(obj-\u003ebtf);\n2015:\t\tif (err) {\n2016:\t\t\tpr_err(\"FAILED to sort BTF: %s\\n\", strerror(errno));\n2017:\t\t\treturn err;\n2018:\t\t}\n2019:\t\n2020:\t\tif (obj-\u003eextract_inline) {\n2021:\t\t\terr = extract_inline_btf(obj);\n2022:\t\t\tif (err) {\n2023:\t\t\t\tpr_err(\"FAILED to extract inline BTF: %s\\n\", strerror(-err));\n2024:\t\t\t\treturn err;\n2025:\t\t\t}\n2026:\t\t}\n2027:\t\n2028:\t\treturn 0;\n2029:\t}\n"
}

5/2 2026/11/30 04:23 tool grepper
0m Args:
{
  "Expression": "libbpf_sha256",
  "PathPrefixes": [
    "tools/"
  ]
}

Results:
{
  "Output": "tools/bpf/resolve_btfids/main.c=1100=static int patch_btf_link(struct object *obj, const struct btf_link *link)\n--\ntools/bpf/resolve_btfids/main.c-1210-\tmemcpy(data-\u003ed_buf, link-\u003emodule, strlen(link-\u003emodule) + 1);\ntools/bpf/resolve_btfids/main.c:1211:\tlibbpf_sha256(raw_btf_data, raw_btf_size, (u8 *)data-\u003ed_buf + module_name_len);\ntools/bpf/resolve_btfids/main.c-1212-\tsize = (u8 *)data-\u003ed_buf + module_name_len + BTF_SHA256_DIGEST_LENGTH;\n--\ntools/lib/bpf/features.c=124=static int probe_kern_excl_map_fd_array_cnt(int token_fd)\n--\ntools/lib/bpf/features.c-143-\ntools/lib/bpf/features.c:144:\tlibbpf_sha256(insns, sizeof(insns), hash);\ntools/lib/bpf/features.c-145-\tmap = bpf_map_create(BPF_MAP_TYPE_ARRAY, \"libbpf_det_excl\", sizeof(int), sizeof(int), 1,\n--\ntools/lib/bpf/libbpf.c=4713=static int bpf_prog_compute_hash(struct bpf_program *prog)\n--\ntools/lib/bpf/libbpf.c-4743-\t}\ntools/lib/bpf/libbpf.c:4744:\tlibbpf_sha256(purged, prog-\u003einsns_cnt * sizeof(struct bpf_insn),\ntools/lib/bpf/libbpf.c-4745-\t\t      prog-\u003ehash);\n--\ntools/lib/bpf/libbpf_tools.h=180=int parse_cpu_mask_file(const char *fcpu, bool **mask, int *mask_sz);\n--\ntools/lib/bpf/libbpf_tools.h-183-\ntools/lib/bpf/libbpf_tools.h:184:void libbpf_sha256(const void *data, size_t len, __u8 out[SHA256_DIGEST_LENGTH]);\ntools/lib/bpf/libbpf_tools.h-185-\n--\ntools/lib/bpf/libbpf_utils.c=195=static void sha256_blocks(__u32 state[8], const __u8 *data, size_t nblocks)\n--\ntools/lib/bpf/libbpf_utils.c-235-\ntools/lib/bpf/libbpf_utils.c:236:void libbpf_sha256(const void *data, size_t len, __u8 out[SHA256_DIGEST_LENGTH])\ntools/lib/bpf/libbpf_utils.c-237-{\n--\ntools/testing/selftests/bpf/prog_tests/sha256.c-8-\ntools/testing/selftests/bpf/prog_tests/sha256.c:9:/* Test libbpf_sha256() for all lengths from 0 to MAX_LEN inclusively. */\ntools/testing/selftests/bpf/prog_tests/sha256.c-10-void test_sha256(void)\n--\ntools/testing/selftests/bpf/prog_tests/sha256.c-13-\t * The correctness of this value was verified by running this test with\ntools/testing/selftests/bpf/prog_tests/sha256.c:14:\t * libbpf_sha256() replaced by OpenSSL's SHA256().\ntools/testing/selftests/bpf/prog_tests/sha256.c-15-\t */\n--\ntools/testing/selftests/bpf/prog_tests/sha256.c-41-\tfor (i = 0; i \u003c= MAX_LEN; i++)\ntools/testing/selftests/bpf/prog_tests/sha256.c:42:\t\tlibbpf_sha256(data, i, \u0026digests[i * SHA256_DIGEST_LENGTH]);\ntools/testing/selftests/bpf/prog_tests/sha256.c-43-\ntools/testing/selftests/bpf/prog_tests/sha256.c-44-\t/* Calculate and verify the digest of all the digests. */\ntools/testing/selftests/bpf/prog_tests/sha256.c:45:\tlibbpf_sha256(digests, (MAX_LEN + 1) * SHA256_DIGEST_LENGTH,\ntools/testing/selftests/bpf/prog_tests/sha256.c-46-\t\t      digest_of_digests);\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-15-\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:16:#include \"bpf/libbpf_internal.h\" /* for libbpf_sha256() */\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-17-#include \"bpf/skel_internal.h\"\t /* for loader ctx layout (bpf_loader_ctx etc) */\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c=290=static int gen_loader_fixture_init(struct gen_loader_fixture *f)\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-327-\t/* excl_prog_hash = SHA256(loader insns) == the loader's prog-\u003edigest. */\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:328:\tlibbpf_sha256(gopts.insns, gopts.insns_sz, f-\u003eexcl);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-329-\treturn 0;\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c=990=static void metadata_ctx_max_entries_ignored(void)\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1027-\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1028:\tlibbpf_sha256(gopts.insns, gopts.insns_sz, excl);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1029-\tdata_sz = gopts.data_sz;\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c=1075=static void metadata_ctx_initial_value_ignored(void)\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1113-\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1114:\tlibbpf_sha256(gopts.insns, gopts.insns_sz, excl);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1115-\tdata_sz = gopts.data_sz;\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c=1167=static void signature_authenticates_insns(void)\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1219-\tmemcpy(blob, gopts.data, data_sz);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1220:\tlibbpf_sha256(insns, insns_sz, excl);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1221-\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1249-\t */\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1250:\tlibbpf_sha256(tampered, insns_sz, excl);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1251-\tmemset(ctx, 0, ctx_sz);\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c=1267=static void signature_authenticates_metadata(void)\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1317-\tmemcpy(blob, gopts.data, data_sz);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1318:\tlibbpf_sha256(insns, insns_sz, excl);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1319-\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c=1443=static void map_hash_matches_libbpf(void)\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1451-\t * The signing scheme assumes the kernel's map hash equals what libbpf\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1452:\t * computes over the same bytes (gen_loader bakes libbpf_sha256(blob);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1453-\t * the kernel recomputes via array_map_get_hash). Pin that they agree.\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1466-\tif (ASSERT_OK(bpf_map_get_info_by_fd(fd, \u0026info, \u0026ilen), \"get_hash\")) {\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1467:\t\tlibbpf_sha256(val, sizeof(val), lbuf);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1468-\t\tASSERT_EQ(memcmp(kbuf, lbuf, sizeof(kbuf)), 0,\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1469:\t\t\t  \"kernel map hash matches libbpf_sha256\");\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1470-\t}\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c=1474=static void map_hash_multi_element(void)\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1486-\t * no padding, so pin that a \u003e1-entry array's kernel hash equals\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1487:\t * libbpf_sha256() over the full, concatenated element contents.\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1488-\t */\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1507-\tif (ASSERT_OK(bpf_map_get_info_by_fd(fd, \u0026info, \u0026ilen), \"get_hash\")) {\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1508:\t\tlibbpf_sha256(full, (size_t)nr * value_size, lbuf);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1509-\t\tASSERT_EQ(memcmp(kbuf, lbuf, sizeof(kbuf)), 0,\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c=1786=static void loadtime_verify(struct bpf_object *obj, int expect_maps)\n--\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1837-\t/* excl_prog_hash = SHA256(loader insns) == the loader's prog-\u003edigest. */\ntools/testing/selftests/bpf/prog_tests/signed_loader.c:1838:\tlibbpf_sha256(gopts.insns, gopts.insns_sz, excl);\ntools/testing/selftests/bpf/prog_tests/signed_loader.c-1839-\n"
}

6/2 2026/11/30 04:23 llm patch-evaluator
0m Model:
gemini-4-hydrogen

Args:
null

Results:
null

Tokens:
							input: 26768
							output: 170
							thoughts: 216
						

Thoughts:
**My Assessment of the Code Changes**

Okay, after carefully reviewing the scope of these modifications, I've reached a definitive conclusion. It's clear that the changes are isolated entirely to the user-space and supporting tooling, specifically within: `Documentation/`, `tools/bpf/bpftool/`, `tools/bpf/resolve_btfids/`, `tools/lib/bpf/`, `tools/sched_ext/`, and `tools/testing/selftests/bpf/`. Crucially, none of these modifications touch the compiled kernel image (`vmlinux`) or any standard kernel module executables. The build-time check `check_kfunc_variants` in `tools/bpf/resolve_btfids/`, while new, doesn't alter generated BTF data.

Given this thorough isolation, fuzzing the kernel itself isn't warranted. The potential attack surface remains unchanged within the kernel's core functionality. Therefore, `WorthFuzzing` is demonstrably `false`.

Now, it's time to call `set-results` and record this assessment.



7/2 2026/11/30 04:23 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "All modifications in this patch are confined to Documentation/ (Documentation/bpf/kfuncs.rst), userspace tools and libraries (tools/bpf/bpftool/, tools/lib/bpf/, tools/sched_ext/include/scx/compat.bpf.h), the host build-time tool tools/bpf/resolve_btfids/ (which only adds a compile-time kfunc variant check without altering generated kernel BTF or .BTF_ids), and BPF selftests (tools/testing/selftests/bpf/). None of the changes modify vmlinux or kernel modules, so there is no reachable kernel code to fuzz.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "All modifications in this patch are confined to Documentation/ (Documentation/bpf/kfuncs.rst), userspace tools and libraries (tools/bpf/bpftool/, tools/lib/bpf/, tools/sched_ext/include/scx/compat.bpf.h), the host build-time tool tools/bpf/resolve_btfids/ (which only adds a compile-time kfunc variant check without altering generated kernel BTF or .BTF_ids), and BPF selftests (tools/testing/selftests/bpf/). None of the changes modify vmlinux or kernel modules, so there is no reachable kernel code to fuzz.",
  "WorthFuzzing": false
}

8/1 2026/11/30 04:23 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)