AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/11/21 16:35 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "All changes in this patch series are strictly confined to Documentation/ and tools/ (specifically the resolve_btfids build tool, the userspace libbpf library, and selftests under tools/testing/selftests/). No executable code in the kernel image (vmlinux) or standard in-tree kernel modules is modified. Consequently, the changes are not relevant for syzkaller kernel fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/11/21 16:35 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit e066bd26d6cf4230e425ba8d860a7da593f77587\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Sat Nov 21 16:35:29 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst\nindex c7da603cab7730..17043ef15da31c 100644\n--- a/Documentation/bpf/kfuncs.rst\n+++ b/Documentation/bpf/kfuncs.rst\n@@ -800,6 +800,89 @@ 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 binds a kfunc by name, ignoring any ``___suffix`` in the BPF program's\n+declaration, if the declared prototype is compatible with the kernel's.\n+Otherwise, it looks for a kfunc named ``\u003cname\u003e___\u003canything\u003e`` with a compatible\n+prototype.\n+\n+Prototypes are compatible if they have the same number of parameters and the\n+same kind (integer, enum, pointer, struct, union, ...) of each parameter and of\n+the return value. A pointer's kind includes the kind it points to: ``int *``\n+and ``struct task_struct *`` differ, ``struct file *`` and\n+``struct task_struct *`` don't. Integer sizes and signedness don't matter, nor\n+do the names and members of structs, unions and enums. Typedefs, ``const`` and\n+``volatile`` are looked through.\n+\n+A change that keeps the prototype compatible, e.g. widening an integer or adding\n+``const``, is done in place. Otherwise the new prototype keeps the name, and the\n+old one stays available as ``\u003cname\u003e___v1`` (``___v2`` for the next change, and\n+so on) for a deprecation period, usually as a thin wrapper registered with the\n+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+Only libbpf 1.9 and later look for ``bpf_foo___v1``. Older libbpf and light\n+skeletons see only ``bpf_foo``, as after an in-place change.\n+\n+Two kfuncs whose names differ only in the ``___`` suffix must not have\n+compatible prototypes: libbpf couldn't tell them apart, and ``resolve_btfids``\n+fails the build. The one exception is an alias of ``\u003cname\u003e``: a kfunc with the\n+identical prototype, parameter names included (BTF dedup compares them).\n+\n+For example, this widens an offset to 64 bits and keeps the old prototype as\n+``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 compatible prototypes, libbpf cannot tell them apart\n+\n+Widening keeps the prototype compatible, so it is done in place instead: drop\n+``bpf_bar___v1``, and programs built against the old prototype bind\n+``bpf_bar``.\n+\n+Give the new prototype a new name that doesn't start with ``\u003cname\u003e___`` if\n+programs loaded by older libbpf or light skeletons must keep working, or if the\n+prototypes are compatible but the change breaks callers, e.g. two integer\n+parameters swap places.\n+\n+Don't rename a ``\u003cname\u003e___vN`` kfunc in place: BPF programs may call it by that\n+name. To give its prototype to ``\u003cname\u003e``, keep it as an alias for a\n+deprecation period.\n+\n 4. Core kfuncs\n ==============\n \ndiff --git a/tools/bpf/resolve_btfids/btf_colors.c b/tools/bpf/resolve_btfids/btf_colors.c\nindex 5d307d70e7f220..91c10106319eba 100644\n--- a/tools/bpf/resolve_btfids/btf_colors.c\n+++ b/tools/bpf/resolve_btfids/btf_colors.c\n@@ -13,6 +13,17 @@ void btf_sha256(const void *data, size_t len,\n \tlibbpf_sha256(data, len, out);\n }\n \n+size_t btf_essential_name_len(const char *name)\n+{\n+\treturn bpf_core_essential_name_len(name);\n+}\n+\n+int btf_types_are_compat(const struct btf *btf1, __u32 id1,\n+\t\t\t const struct btf *btf2, __u32 id2)\n+{\n+\treturn bpf_core_types_are_compat(btf1, id1, btf2, id2);\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..3d48194e73b6b9 100644\n--- a/tools/bpf/resolve_btfids/btf_colors.h\n+++ b/tools/bpf/resolve_btfids/btf_colors.h\n@@ -15,6 +15,9 @@ enum btf_color {\n \n void btf_sha256(const void *data, size_t len,\n \t\t__u8 out[BTF_SHA256_DIGEST_LENGTH]);\n+size_t btf_essential_name_len(const char *name);\n+int btf_types_are_compat(const struct btf *btf1, __u32 id1,\n+\t\t\t const struct btf *btf2, __u32 id2);\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..68a5519cf8b698 100644\n--- a/tools/bpf/resolve_btfids/main.c\n+++ b/tools/bpf/resolve_btfids/main.c\n@@ -1917,6 +1917,136 @@ static int sort_btf_by_name(struct btf *btf)\n \treturn err;\n }\n \n+static const char *func_name(const struct btf *btf, u32 id)\n+{\n+\treturn btf__name_by_offset(btf, btf__type_by_id(btf, id)-\u003ename_off);\n+}\n+\n+static int cmp_essential_names(const void *a, const void *b, void *priv)\n+{\n+\tconst char *na = func_name(priv, *(u32 *)a);\n+\tconst char *nb = func_name(priv, *(u32 *)b);\n+\tsize_t la = btf_essential_name_len(na);\n+\tsize_t lb = btf_essential_name_len(nb);\n+\tint r = strncmp(na, nb, min(la, lb));\n+\n+\tif (r != 0)\n+\t\treturn r;\n+\tif (la == lb)\n+\t\treturn 0;\n+\treturn la \u003c lb ? -1 : 1;\n+}\n+\n+/*\n+ * Returns 1 if libbpf can't tell kfuncs a and b of one family apart, 0 if it\n+ * can, or a negative error.\n+ */\n+static int kfuncs_are_ambiguous(const struct btf *btf, u32 a, u32 b, u32 unsuffixed_proto)\n+{\n+\tconst char *na = func_name(btf, a), *nb = func_name(btf, b);\n+\tu32 pa = btf__type_by_id(btf, a)-\u003etype;\n+\tu32 pb = btf__type_by_id(btf, b)-\u003etype;\n+\tint ret;\n+\n+\tif (pa == pb \u0026\u0026 pa == unsuffixed_proto) {\n+\t\tpr_debug(\"kfuncs %s and %s: alias\\n\", na, nb);\n+\t\treturn 0;\n+\t}\n+\tret = btf_types_are_compat(btf, pa, btf, pb);\n+\tif (ret \u003c 0) {\n+\t\tpr_err(\"ERROR: resolve_btfids: failed to compare kfuncs %s and %s: %d\\n\",\n+\t\t       na, nb, ret);\n+\t\treturn ret;\n+\t}\n+\tif (ret == 0)\n+\t\tpr_debug(\"kfuncs %s and %s: distinct\\n\", na, nb);\n+\treturn ret;\n+}\n+\n+static int check_kfunc_family(const struct btf *btf, const u32 *ids, u32 cnt, u32 start_id)\n+{\n+\tsize_t len = btf_essential_name_len(func_name(btf, ids[0]));\n+\tu32 unsuffixed_proto = 0;\n+\tint err, bad = 0;\n+\n+\tfor (u32 i = 0; i \u003c cnt; i++) {\n+\t\tconst char *name = func_name(btf, ids[i]);\n+\n+\t\tif (name[len] == '\\0')\n+\t\t\tunsuffixed_proto = btf__type_by_id(btf, ids[i])-\u003etype;\n+\t}\n+\n+\tfor (u32 i = 0; i \u003c cnt; i++) {\n+\t\tfor (u32 j = i + 1; j \u003c cnt; j++) {\n+\t\t\t/* base BTF pairs were checked when building vmlinux */\n+\t\t\tif (ids[i] \u003c start_id \u0026\u0026 ids[j] \u003c start_id)\n+\t\t\t\tcontinue;\n+\t\t\terr = kfuncs_are_ambiguous(btf, ids[i], ids[j], unsuffixed_proto);\n+\t\t\tif (err \u003c 0)\n+\t\t\t\treturn err;\n+\t\t\tif (err == 0)\n+\t\t\t\tcontinue;\n+\t\t\tpr_err(\"ERROR: resolve_btfids: kfuncs %s and %s have compatible prototypes, libbpf cannot tell them apart\\n\",\n+\t\t\t       func_name(btf, ids[i]), func_name(btf, ids[j]));\n+\t\t\tbad++;\n+\t\t}\n+\t}\n+\n+\treturn bad ? -EINVAL : 0;\n+}\n+\n+/*\n+ * Fail if libbpf can't tell apart two kfuncs sharing an essential name, i.e.\n+ * if bpf_core_types_are_compat() finds their prototypes compatible. An alias\n+ * of the unsuffixed kfunc, which has its type id after dedup, is allowed:\n+ * libbpf binds the unsuffixed kfunc first.\n+ *\n+ * Kfuncs are recognized by their bpf_kfunc decl tags: these are what libbpf\n+ * looks at, and for a module they also cover the vmlinux kfuncs in base BTF.\n+ */\n+static int check_kfunc_families(struct btf *btf)\n+{\n+\tconst struct btf *base = btf__base_btf(btf);\n+\tu32 start_id = base ? btf__type_cnt(base) : 1;\n+\tu32 type_cnt = btf__type_cnt(btf);\n+\tu32 *ids = NULL, nr_ids = 0, cap = 0;\n+\tint ret, err = 0;\n+\n+\tfor (u32 id = 1; id \u003c type_cnt; id++) {\n+\t\tconst struct btf_type *t = btf__type_by_id(btf, id);\n+\t\tconst char *tag_name;\n+\n+\t\tif (!btf_is_decl_tag(t))\n+\t\t\tcontinue;\n+\t\tif (btf_decl_tag(t)-\u003ecomponent_idx != -1)\n+\t\t\tcontinue;\n+\t\ttag_name = btf__name_by_offset(btf, t-\u003ename_off);\n+\t\tif (strcmp(tag_name, DECL_TAG_KFUNC) != 0)\n+\t\t\tcontinue;\n+\t\terr = ensure_mem(\u0026ids, \u0026cap, nr_ids + 1);\n+\t\tif (err)\n+\t\t\tgoto out;\n+\t\tids[nr_ids++] = t-\u003etype;\n+\t}\n+\n+\tqsort_r(ids, nr_ids, sizeof(*ids), cmp_essential_names, btf);\n+\n+\tfor (u32 i = 0, j; i \u003c nr_ids; i = j) {\n+\t\tfor (j = i + 1; j \u003c nr_ids; j++) {\n+\t\t\tif (cmp_essential_names(\u0026ids[i], \u0026ids[j], btf) != 0)\n+\t\t\t\tbreak;\n+\t\t}\n+\t\tif (j - i \u003c 2)\n+\t\t\tcontinue;\n+\t\tret = check_kfunc_family(btf, ids + i, j - i, start_id);\n+\t\tif (ret)\n+\t\t\terr = ret;\n+\t}\n+out:\n+\tfree(ids);\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 +2058,10 @@ static int finalize_btf(struct object *obj)\n \t\treturn err;\n \t}\n \n+\terr = check_kfunc_families(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..9eb13c8a95a5c3 100644\n--- a/tools/lib/bpf/btf.c\n+++ b/tools/lib/bpf/btf.c\n@@ -1164,6 +1164,32 @@ 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 IDs of btf's own types that can have a name\n+ * starting with prefix. On BTF sorted by name these are exactly the ones that\n+ * do, a contiguous run found by binary search; otherwise all own types.\n+ */\n+void btf_name_prefix_range(const struct btf *btf, const char *prefix, __u32 *start, __u32 *end)\n+{\n+\t__u32 i, n = btf__type_cnt(btf);\n+\tsize_t len = strlen(prefix);\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, prefix, 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 *name = btf__str_by_offset(btf, t-\u003ename_off);\n+\n+\t\tif (strncmp(name, prefix, len) != 0)\n+\t\t\tbreak;\n+\t}\n+\t*end = i;\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 {\ndiff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c\nindex 1efc0dd37b2e65..9089e9c55dfdea 100644\n--- a/tools/lib/bpf/libbpf.c\n+++ b/tools/lib/bpf/libbpf.c\n@@ -9513,6 +9513,130 @@ static int bpf_object__resolve_ksym_var_btf_id(struct bpf_object *obj,\n \treturn 0;\n }\n \n+/* t is the bpf_kfunc decl tag of FUNC id */\n+static inline bool btf_is_kfunc_tag(const struct btf *btf, const struct btf_type *t, int id)\n+{\n+\tconst char *name;\n+\n+\tif (!btf_is_decl_tag(t) || t-\u003etype != id)\n+\t\treturn false;\n+\tif (btf_decl_tag(t)-\u003ecomponent_idx != -1)\n+\t\treturn false;\n+\tname = btf__name_by_offset(btf, t-\u003ename_off);\n+\treturn strcmp(name, \"bpf_kfunc\") == 0;\n+}\n+\n+/* FUNC id has the bpf_kfunc decl tag */\n+static bool btf_is_kfunc(const struct btf *btf, int id)\n+{\n+\t__u32 i, n;\n+\n+\tbtf_name_prefix_range(btf, \"bpf_kfunc\", \u0026i, \u0026n);\n+\tfor (; i \u003c n; i++) {\n+\t\tif (btf_is_kfunc_tag(btf, btf__type_by_id(btf, i), id))\n+\t\t\treturn true;\n+\t}\n+\treturn false;\n+}\n+\n+/* id is a kfunc named \u003cname\u003e___\u003cflavor\u003e, where len is strlen(name) */\n+static bool btf_is_kfunc_flavor(const struct btf *btf, int id, const char *name, size_t len)\n+{\n+\tconst struct btf_type *t = btf__type_by_id(btf, id);\n+\tconst char *kname;\n+\n+\tif (!btf_is_func(t))\n+\t\treturn false;\n+\tkname = btf__name_by_offset(btf, t-\u003ename_off);\n+\tif (strncmp(kname, name, len) != 0)\n+\t\treturn false;\n+\t/* kname is \u003cname\u003e itself, already tried by the exact lookup */\n+\tif (kname[len] == '\\0')\n+\t\treturn false;\n+\tif (bpf_core_essential_name_len(kname) != len)\n+\t\treturn false;\n+\treturn btf_is_kfunc(btf, id);\n+}\n+\n+/*\n+ * Find the kfunc named \u003cname\u003e___\u003cflavor\u003e among btf's own types whose\n+ * prototype is compatible with ext's.\n+ *\n+ * Returns the kfunc's type id, 0 if no flavor is compatible, -ESRCH if there\n+ * are no flavors, or -ENOTUNIQ if more than one is compatible.\n+ */\n+static int find_kfunc_flavor(const struct bpf_object *obj, const struct extern_desc *ext,\n+\t\t\t     const struct btf *btf)\n+{\n+\tconst char *name = ext-\u003eessent_name ?: ext-\u003ename;\n+\tsize_t len = strlen(name);\n+\tbool has_flavors = false;\n+\tint found = 0;\n+\t__u32 i, n;\n+\n+\tbtf_name_prefix_range(btf, name, \u0026i, \u0026n);\n+\tfor (; i \u003c n; i++) {\n+\t\tconst struct btf_type *t = btf__type_by_id(btf, i);\n+\n+\t\tif (!btf_is_kfunc_flavor(btf, i, name, len))\n+\t\t\tcontinue;\n+\t\thas_flavors = true;\n+\t\tif (bpf_core_types_are_compat(obj-\u003ebtf, ext-\u003eksym.type_id, btf, t-\u003etype) \u003c= 0)\n+\t\t\tcontinue;\n+\t\tif (found)\n+\t\t\treturn -ENOTUNIQ;\n+\t\tfound = i;\n+\t}\n+\tif (!has_flavors)\n+\t\treturn -ESRCH;\n+\treturn found;\n+}\n+\n+/*\n+ * Like find_ksym_btf_id(), but for a ___flavor of ext's kfunc: vmlinux first,\n+ * then the first module that has any. *res_btf and *res_mod_btf are only set\n+ * when a compatible flavor is found.\n+ */\n+static int find_kfunc_flavor_btf_id(struct bpf_object *obj, const struct extern_desc *ext,\n+\t\t\t\t    struct btf **res_btf, struct module_btf **res_mod_btf)\n+{\n+\tstruct module_btf *mod_btf = NULL;\n+\tstruct btf *btf = obj-\u003ebtf_vmlinux;\n+\tint i, id, err;\n+\n+\tid = find_kfunc_flavor(obj, ext, btf);\n+\tif (id == -ESRCH) {\n+\t\terr = load_module_btfs(obj);\n+\t\tif (err)\n+\t\t\treturn err;\n+\n+\t\tfor (i = 0; i \u003c obj-\u003ebtf_module_cnt \u0026\u0026 id == -ESRCH; i++) {\n+\t\t\tmod_btf = \u0026obj-\u003ebtf_modules[i];\n+\t\t\tbtf = mod_btf-\u003ebtf;\n+\t\t\tid = find_kfunc_flavor(obj, ext, btf);\n+\t\t}\n+\t}\n+\tif (id \u003e 0) {\n+\t\t*res_btf = btf;\n+\t\t*res_mod_btf = mod_btf;\n+\t}\n+\treturn id;\n+}\n+\n+/* ext's kfunc is missing, or kfunc_id's prototype is incompatible with ext's */\n+static bool need_kfunc_flavor(const struct bpf_object *obj, const struct extern_desc *ext,\n+\t\t\t      const struct btf *kern_btf, int kfunc_id)\n+{\n+\tconst struct btf_type *t;\n+\n+\tif (kfunc_id == -ESRCH)\n+\t\treturn true;\n+\tif (kfunc_id \u003c 0)\n+\t\treturn false;\n+\tt = btf__type_by_id(kern_btf, kfunc_id);\n+\treturn bpf_core_types_are_compat(obj-\u003ebtf, ext-\u003eksym.type_id, kern_btf, t-\u003etype) \u003c= 0;\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@@ -9526,6 +9650,17 @@ static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,\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 (need_kfunc_flavor(obj, ext, kern_btf, kfunc_id)) {\n+\t\tret = find_kfunc_flavor_btf_id(obj, ext, \u0026kern_btf, \u0026mod_btf);\n+\t\tif (ret == -ENOTUNIQ) {\n+\t\t\t/* an error even if declared __weak: ambiguity isn't absence */\n+\t\t\tpr_warn(\"extern (func ksym) '%s': more than one compatible kfunc flavor\\n\",\n+\t\t\t\text-\u003ename);\n+\t\t\treturn ret;\n+\t\t}\n+\t\tif (ret \u0026\u0026 ret != -ESRCH)\n+\t\t\tkfunc_id = ret;\n+\t}\n \tif (kfunc_id \u003c 0) {\n \t\tif (kfunc_id == -ESRCH \u0026\u0026 ext-\u003eis_weak)\n \t\t\treturn 0;\n@@ -9579,8 +9714,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 }\ndiff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h\nindex e90b5336bac01a..c84521ea562edc 100644\n--- a/tools/lib/bpf/libbpf_internal.h\n+++ b/tools/lib/bpf/libbpf_internal.h\n@@ -248,6 +248,7 @@ 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_name_prefix_range(const struct btf *btf, const char *prefix, __u32 *start, __u32 *end);\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);\ndiff --git a/tools/testing/selftests/bpf/prog_tests/verifier.c b/tools/testing/selftests/bpf/prog_tests/verifier.c\nindex 57ff2578a991e0..351e53744e376e 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_flavors.skel.h\"\n #include \"verifier_aggregate_arg.skel.h\"\n #include \"verifier_aggregate_ret.skel.h\"\n #include \"verifier_alu_range.skel.h\"\n@@ -220,6 +221,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_flavors(void)                 { RUN_TESTS(kfunc_flavors); }\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_flavors.c b/tools/testing/selftests/bpf/progs/kfunc_flavors.c\nnew file mode 100644\nindex 00000000000000..6b06cb8d84470e\n--- /dev/null\n+++ b/tools/testing/selftests/bpf/progs/kfunc_flavors.c\n@@ -0,0 +1,55 @@\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+/* the old prototype of bpf_kfunc_flavor(), under local flavors */\n+extern int bpf_kfunc_flavor___old(int a) __ksym;\n+extern int bpf_kfunc_flavor___v1___local(int a) __ksym;\n+/* a prototype that no member of the family has */\n+extern int bpf_kfunc_flavor___none(void) __weak __ksym;\n+\n+char _license[] SEC(\"license\") = \"GPL\";\n+\n+/* bpf_kfunc_flavor binds itself, though its alias ___v2 matches too */\n+SEC(\"syscall\")\n+__retval(3)\n+int exact_name(void *ctx)\n+{\n+\treturn bpf_kfunc_flavor(1, 2);\n+}\n+\n+/* the old prototype under a local flavor binds ___v1 */\n+SEC(\"syscall\")\n+__retval(1)\n+int local_flavor(void *ctx)\n+{\n+\treturn bpf_kfunc_flavor___old(1);\n+}\n+\n+/* so does the kernel name, which strips to bpf_kfunc_flavor */\n+SEC(\"syscall\")\n+__retval(1)\n+int kernel_flavor(void *ctx)\n+{\n+\treturn bpf_kfunc_flavor___v1(1);\n+}\n+\n+/* a local flavor on top of the kernel name binds ___v1 by name */\n+SEC(\"syscall\")\n+__retval(1)\n+int stacked_flavor(void *ctx)\n+{\n+\treturn bpf_kfunc_flavor___v1___local(1);\n+}\n+\n+/* a __weak kfunc that matches no member stays unresolved */\n+SEC(\"syscall\")\n+__retval(0)\n+int no_match(void *ctx)\n+{\n+\treturn bpf_ksym_exists(bpf_kfunc_flavor___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 1f8bc0c99a710f..e165596072708a 100644\n--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c\n+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c\n@@ -1926,6 +1926,27 @@ __bpf_kfunc void bpf_kfunc_trigger_ctx_check(void)\n \tirq_work_queue(\u0026ctx_check_irq);\n }\n \n+/*\n+ * A kfunc family for the kfunc_flavors test: bpf_kfunc_flavor() has the\n+ * current prototype, ___v1 an older one, and ___v2 is an alias with its exact\n+ * prototype. ___v2 negates the result, so that the test can tell which of the\n+ * two it called.\n+ */\n+__bpf_kfunc int bpf_kfunc_flavor(int a, int b)\n+{\n+\treturn a + b;\n+}\n+\n+__bpf_kfunc int bpf_kfunc_flavor___v1(int a)\n+{\n+\treturn bpf_kfunc_flavor(a, 0);\n+}\n+\n+__bpf_kfunc int bpf_kfunc_flavor___v2(int a, int b)\n+{\n+\treturn -bpf_kfunc_flavor(a, b);\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@@ -2017,6 +2038,9 @@ 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_flavor)\n+BTF_ID_FLAGS(func, bpf_kfunc_flavor___v1)\n+BTF_ID_FLAGS(func, bpf_kfunc_flavor___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..2c6126e4f0d0b0 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,8 @@ 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_flavor(int a, int b) __ksym;\n+int bpf_kfunc_flavor___v1(int a) __ksym;\n+int bpf_kfunc_flavor___v2(int a, int b) __ksym;\n+\n #endif /* _BPF_TESTMOD_KFUNC_H */\n"
}

2/1 2026/11/21 16:35 agent patch-evaluator
0m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "All changes in this patch series are strictly confined to Documentation/ and tools/ (specifically the resolve_btfids build tool, the userspace libbpf library, and selftests under tools/testing/selftests/). No executable code in the kernel image (vmlinux) or standard in-tree kernel modules is modified. Consequently, the changes are not relevant for syzkaller kernel fuzzing.",
  "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 e066bd26d6cf4230e425ba8d860a7da593f77587
Author: syz-cluster <triage@syzkaller.com>
Date:   Sat Nov 21 16:35:29 2026 +0000

    syz-cluster: applied patch under review

diff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst
index c7da603cab7730..17043ef15da31c 100644
--- a/Documentation/bpf/kfuncs.rst
+++ b/Documentation/bpf/kfuncs.rst
@@ -800,6 +800,89 @@ 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 binds a kfunc by name, ignoring any ``___suffix`` in the BPF program's
+declaration, if the declared prototype is compatible with the kernel's.
+Otherwise, it looks for a kfunc named ``<name>___<anything>`` with a compatible
+prototype.
+
+Prototypes are compatible if they have the same number of parameters and the
+same kind (integer, enum, pointer, struct, union, ...) of each parameter and of
+the return value. A pointer's kind includes the kind it points to: ``int *``
+and ``struct task_struct *`` differ, ``struct file *`` and
+``struct task_struct *`` don't. Integer sizes and signedness don't matter, nor
+do the names and members of structs, unions and enums. Typedefs, ``const`` and
+``volatile`` are looked through.
+
+A change that keeps the prototype compatible, e.g. widening an integer or adding
+``const``, is done 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;
+
+Only libbpf 1.9 and later look for ``bpf_foo___v1``. Older libbpf and light
+skeletons see only ``bpf_foo``, as after an in-place change.
+
+Two kfuncs whose names differ only in the ``___`` suffix must not have
+compatible prototypes: libbpf couldn't tell them apart, and ``resolve_btfids``
+fails the build. The one exception is an alias of ``<name>``: a kfunc with the
+identical prototype, parameter names included (BTF dedup compares them).
+
+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 compatible prototypes, libbpf cannot tell them apart
+
+Widening keeps the prototype compatible, so it is done in place instead: drop
+``bpf_bar___v1``, and programs built against the old prototype bind
+``bpf_bar``.
+
+Give the new prototype a new name that doesn't start with ``<name>___`` if
+programs loaded by older libbpf or light skeletons must keep working, or if the
+prototypes are compatible but the change breaks callers, e.g. two integer
+parameters swap places.
+
+Don't rename a ``<name>___vN`` kfunc in place: BPF programs may call it by that
+name. To give its prototype to ``<name>``, keep it as an alias for a
+deprecation period.
+
 4. Core kfuncs
 ==============
 
diff --git a/tools/bpf/resolve_btfids/btf_colors.c b/tools/bpf/resolve_btfids/btf_colors.c
index 5d307d70e7f220..91c10106319eba 100644
--- a/tools/bpf/resolve_btfids/btf_colors.c
+++ b/tools/bpf/resolve_btfids/btf_colors.c
@@ -13,6 +13,17 @@ void btf_sha256(const void *data, size_t len,
 	libbpf_sha256(data, len, out);
 }
 
+size_t btf_essential_name_len(const char *name)
+{
+	return bpf_core_essential_name_len(name);
+}
+
+int btf_types_are_compat(const struct btf *btf1, __u32 id1,
+			 const struct btf *btf2, __u32 id2)
+{
+	return bpf_core_types_are_compat(btf1, id1, btf2, id2);
+}
+
 /*
  * 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..3d48194e73b6b9 100644
--- a/tools/bpf/resolve_btfids/btf_colors.h
+++ b/tools/bpf/resolve_btfids/btf_colors.h
@@ -15,6 +15,9 @@ enum btf_color {
 
 void btf_sha256(const void *data, size_t len,
 		__u8 out[BTF_SHA256_DIGEST_LENGTH]);
+size_t btf_essential_name_len(const char *name);
+int btf_types_are_compat(const struct btf *btf1, __u32 id1,
+			 const struct btf *btf2, __u32 id2);
 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..68a5519cf8b698 100644
--- a/tools/bpf/resolve_btfids/main.c
+++ b/tools/bpf/resolve_btfids/main.c
@@ -1917,6 +1917,136 @@ static int sort_btf_by_name(struct btf *btf)
 	return err;
 }
 
+static const char *func_name(const struct btf *btf, u32 id)
+{
+	return btf__name_by_offset(btf, btf__type_by_id(btf, id)->name_off);
+}
+
+static int cmp_essential_names(const void *a, const void *b, void *priv)
+{
+	const char *na = func_name(priv, *(u32 *)a);
+	const char *nb = func_name(priv, *(u32 *)b);
+	size_t la = btf_essential_name_len(na);
+	size_t lb = btf_essential_name_len(nb);
+	int r = strncmp(na, nb, min(la, lb));
+
+	if (r != 0)
+		return r;
+	if (la == lb)
+		return 0;
+	return la < lb ? -1 : 1;
+}
+
+/*
+ * Returns 1 if libbpf can't tell kfuncs a and b of one family apart, 0 if it
+ * can, or a negative error.
+ */
+static int kfuncs_are_ambiguous(const struct btf *btf, u32 a, u32 b, u32 unsuffixed_proto)
+{
+	const char *na = func_name(btf, a), *nb = func_name(btf, b);
+	u32 pa = btf__type_by_id(btf, a)->type;
+	u32 pb = btf__type_by_id(btf, b)->type;
+	int ret;
+
+	if (pa == pb && pa == unsuffixed_proto) {
+		pr_debug("kfuncs %s and %s: alias\n", na, nb);
+		return 0;
+	}
+	ret = btf_types_are_compat(btf, pa, btf, pb);
+	if (ret < 0) {
+		pr_err("ERROR: resolve_btfids: failed to compare kfuncs %s and %s: %d\n",
+		       na, nb, ret);
+		return ret;
+	}
+	if (ret == 0)
+		pr_debug("kfuncs %s and %s: distinct\n", na, nb);
+	return ret;
+}
+
+static int check_kfunc_family(const struct btf *btf, const u32 *ids, u32 cnt, u32 start_id)
+{
+	size_t len = btf_essential_name_len(func_name(btf, ids[0]));
+	u32 unsuffixed_proto = 0;
+	int err, bad = 0;
+
+	for (u32 i = 0; i < cnt; i++) {
+		const char *name = func_name(btf, ids[i]);
+
+		if (name[len] == '\0')
+			unsuffixed_proto = btf__type_by_id(btf, ids[i])->type;
+	}
+
+	for (u32 i = 0; i < cnt; i++) {
+		for (u32 j = i + 1; j < cnt; j++) {
+			/* base BTF pairs were checked when building vmlinux */
+			if (ids[i] < start_id && ids[j] < start_id)
+				continue;
+			err = kfuncs_are_ambiguous(btf, ids[i], ids[j], unsuffixed_proto);
+			if (err < 0)
+				return err;
+			if (err == 0)
+				continue;
+			pr_err("ERROR: resolve_btfids: kfuncs %s and %s have compatible prototypes, libbpf cannot tell them apart\n",
+			       func_name(btf, ids[i]), func_name(btf, ids[j]));
+			bad++;
+		}
+	}
+
+	return bad ? -EINVAL : 0;
+}
+
+/*
+ * Fail if libbpf can't tell apart two kfuncs sharing an essential name, i.e.
+ * if bpf_core_types_are_compat() finds their prototypes compatible. An alias
+ * of the unsuffixed kfunc, which has its type id after dedup, is allowed:
+ * libbpf binds the unsuffixed kfunc first.
+ *
+ * Kfuncs are recognized by their bpf_kfunc decl tags: these are what libbpf
+ * looks at, and for a module they also cover the vmlinux kfuncs in base BTF.
+ */
+static int check_kfunc_families(struct btf *btf)
+{
+	const struct btf *base = btf__base_btf(btf);
+	u32 start_id = base ? btf__type_cnt(base) : 1;
+	u32 type_cnt = btf__type_cnt(btf);
+	u32 *ids = NULL, nr_ids = 0, cap = 0;
+	int ret, err = 0;
+
+	for (u32 id = 1; id < type_cnt; id++) {
+		const struct btf_type *t = btf__type_by_id(btf, id);
+		const char *tag_name;
+
+		if (!btf_is_decl_tag(t))
+			continue;
+		if (btf_decl_tag(t)->component_idx != -1)
+			continue;
+		tag_name = btf__name_by_offset(btf, t->name_off);
+		if (strcmp(tag_name, DECL_TAG_KFUNC) != 0)
+			continue;
+		err = ensure_mem(&ids, &cap, nr_ids + 1);
+		if (err)
+			goto out;
+		ids[nr_ids++] = t->type;
+	}
+
+	qsort_r(ids, nr_ids, sizeof(*ids), cmp_essential_names, btf);
+
+	for (u32 i = 0, j; i < nr_ids; i = j) {
+		for (j = i + 1; j < nr_ids; j++) {
+			if (cmp_essential_names(&ids[i], &ids[j], btf) != 0)
+				break;
+		}
+		if (j - i < 2)
+			continue;
+		ret = check_kfunc_family(btf, ids + i, j - i, start_id);
+		if (ret)
+			err = ret;
+	}
+out:
+	free(ids);
+	return err;
+}
+
 static int finalize_btf(struct object *obj)
 {
 	struct btf *base_btf = obj->base_btf, *btf = obj->btf;
@@ -1928,6 +2058,10 @@ static int finalize_btf(struct object *obj)
 		return err;
 	}
 
+	err = check_kfunc_families(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..9eb13c8a95a5c3 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -1164,6 +1164,32 @@ 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 IDs of btf's own types that can have a name
+ * starting with prefix. On BTF sorted by name these are exactly the ones that
+ * do, a contiguous run found by binary search; otherwise all own types.
+ */
+void btf_name_prefix_range(const struct btf *btf, const char *prefix, __u32 *start, __u32 *end)
+{
+	__u32 i, n = btf__type_cnt(btf);
+	size_t len = strlen(prefix);
+
+	if (btf->named_start_id <= 0) {
+		*start = btf->start_id;
+		*end = n;
+		return;
+	}
+	*start = btf_find_type_by_name_bsearch(btf, prefix, btf->named_start_id);
+	for (i = *start; i < n; i++) {
+		const struct btf_type *t = btf_type_by_id(btf, i);
+		const char *name = btf__str_by_offset(btf, t->name_off);
+
+		if (strncmp(name, prefix, len) != 0)
+			break;
+	}
+	*end = i;
+}
+
 static __s32 btf_find_by_name_kind(const struct btf *btf, int start_id,
 				   const char *type_name, __s32 kind)
 {
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 1efc0dd37b2e65..9089e9c55dfdea 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9513,6 +9513,130 @@ static int bpf_object__resolve_ksym_var_btf_id(struct bpf_object *obj,
 	return 0;
 }
 
+/* t is the bpf_kfunc decl tag of FUNC id */
+static inline bool btf_is_kfunc_tag(const struct btf *btf, const struct btf_type *t, int id)
+{
+	const char *name;
+
+	if (!btf_is_decl_tag(t) || t->type != id)
+		return false;
+	if (btf_decl_tag(t)->component_idx != -1)
+		return false;
+	name = btf__name_by_offset(btf, t->name_off);
+	return strcmp(name, "bpf_kfunc") == 0;
+}
+
+/* FUNC id has the bpf_kfunc decl tag */
+static bool btf_is_kfunc(const struct btf *btf, int id)
+{
+	__u32 i, n;
+
+	btf_name_prefix_range(btf, "bpf_kfunc", &i, &n);
+	for (; i < n; i++) {
+		if (btf_is_kfunc_tag(btf, btf__type_by_id(btf, i), id))
+			return true;
+	}
+	return false;
+}
+
+/* id is a kfunc named <name>___<flavor>, where len is strlen(name) */
+static bool btf_is_kfunc_flavor(const struct btf *btf, int id, const char *name, size_t len)
+{
+	const struct btf_type *t = btf__type_by_id(btf, id);
+	const char *kname;
+
+	if (!btf_is_func(t))
+		return false;
+	kname = btf__name_by_offset(btf, t->name_off);
+	if (strncmp(kname, name, len) != 0)
+		return false;
+	/* kname is <name> itself, already tried by the exact lookup */
+	if (kname[len] == '\0')
+		return false;
+	if (bpf_core_essential_name_len(kname) != len)
+		return false;
+	return btf_is_kfunc(btf, id);
+}
+
+/*
+ * Find the kfunc named <name>___<flavor> among btf's own types whose
+ * prototype is compatible with ext's.
+ *
+ * Returns the kfunc's type id, 0 if no flavor is compatible, -ESRCH if there
+ * are no flavors, or -ENOTUNIQ if more than one is compatible.
+ */
+static int find_kfunc_flavor(const struct bpf_object *obj, const struct extern_desc *ext,
+			     const struct btf *btf)
+{
+	const char *name = ext->essent_name ?: ext->name;
+	size_t len = strlen(name);
+	bool has_flavors = false;
+	int found = 0;
+	__u32 i, n;
+
+	btf_name_prefix_range(btf, name, &i, &n);
+	for (; i < n; i++) {
+		const struct btf_type *t = btf__type_by_id(btf, i);
+
+		if (!btf_is_kfunc_flavor(btf, i, name, len))
+			continue;
+		has_flavors = true;
+		if (bpf_core_types_are_compat(obj->btf, ext->ksym.type_id, btf, t->type) <= 0)
+			continue;
+		if (found)
+			return -ENOTUNIQ;
+		found = i;
+	}
+	if (!has_flavors)
+		return -ESRCH;
+	return found;
+}
+
+/*
+ * Like find_ksym_btf_id(), but for a ___flavor of ext's kfunc: vmlinux first,
+ * then the first module that has any. *res_btf and *res_mod_btf are only set
+ * when a compatible flavor is found.
+ */
+static int find_kfunc_flavor_btf_id(struct bpf_object *obj, const struct extern_desc *ext,
+				    struct btf **res_btf, struct module_btf **res_mod_btf)
+{
+	struct module_btf *mod_btf = NULL;
+	struct btf *btf = obj->btf_vmlinux;
+	int i, id, err;
+
+	id = find_kfunc_flavor(obj, ext, btf);
+	if (id == -ESRCH) {
+		err = load_module_btfs(obj);
+		if (err)
+			return err;
+
+		for (i = 0; i < obj->btf_module_cnt && id == -ESRCH; i++) {
+			mod_btf = &obj->btf_modules[i];
+			btf = mod_btf->btf;
+			id = find_kfunc_flavor(obj, ext, btf);
+		}
+	}
+	if (id > 0) {
+		*res_btf = btf;
+		*res_mod_btf = mod_btf;
+	}
+	return id;
+}
+
+/* ext's kfunc is missing, or kfunc_id's prototype is incompatible with ext's */
+static bool need_kfunc_flavor(const struct bpf_object *obj, const struct extern_desc *ext,
+			      const struct btf *kern_btf, int kfunc_id)
+{
+	const struct btf_type *t;
+
+	if (kfunc_id == -ESRCH)
+		return true;
+	if (kfunc_id < 0)
+		return false;
+	t = btf__type_by_id(kern_btf, kfunc_id);
+	return bpf_core_types_are_compat(obj->btf, ext->ksym.type_id, kern_btf, t->type) <= 0;
+}
+
 static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,
 						struct extern_desc *ext)
 {
@@ -9526,6 +9650,17 @@ static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,
 
 	kfunc_id = find_ksym_btf_id(obj, ext->essent_name ?: ext->name, BTF_KIND_FUNC, &kern_btf,
 				    &mod_btf);
+	if (need_kfunc_flavor(obj, ext, kern_btf, kfunc_id)) {
+		ret = find_kfunc_flavor_btf_id(obj, ext, &kern_btf, &mod_btf);
+		if (ret == -ENOTUNIQ) {
+			/* an error even if declared __weak: ambiguity isn't absence */
+			pr_warn("extern (func ksym) '%s': more than one compatible kfunc flavor\n",
+				ext->name);
+			return ret;
+		}
+		if (ret && ret != -ESRCH)
+			kfunc_id = ret;
+	}
 	if (kfunc_id < 0) {
 		if (kfunc_id == -ESRCH && ext->is_weak)
 			return 0;
@@ -9579,8 +9714,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;
 }
diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index e90b5336bac01a..c84521ea562edc 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -248,6 +248,7 @@ 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_name_prefix_range(const struct btf *btf, const char *prefix, __u32 *start, __u32 *end);
 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);
diff --git a/tools/testing/selftests/bpf/prog_tests/verifier.c b/tools/testing/selftests/bpf/prog_tests/verifier.c
index 57ff2578a991e0..351e53744e376e 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_flavors.skel.h"
 #include "verifier_aggregate_arg.skel.h"
 #include "verifier_aggregate_ret.skel.h"
 #include "verifier_alu_range.skel.h"
@@ -220,6 +221,8 @@ void test_arena_kfunc_jit(void)               { RUN_TESTS(arena_kfunc_jit); }
 
 void test_cb_refs(void)                       { RUN_TESTS(cb_refs); }
 
+void test_kfunc_flavors(void)                 { RUN_TESTS(kfunc_flavors); }
+
 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_flavors.c b/tools/testing/selftests/bpf/progs/kfunc_flavors.c
new file mode 100644
index 00000000000000..6b06cb8d84470e
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/kfunc_flavors.c
@@ -0,0 +1,55 @@
+// 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"
+
+/* the old prototype of bpf_kfunc_flavor(), under local flavors */
+extern int bpf_kfunc_flavor___old(int a) __ksym;
+extern int bpf_kfunc_flavor___v1___local(int a) __ksym;
+/* a prototype that no member of the family has */
+extern int bpf_kfunc_flavor___none(void) __weak __ksym;
+
+char _license[] SEC("license") = "GPL";
+
+/* bpf_kfunc_flavor binds itself, though its alias ___v2 matches too */
+SEC("syscall")
+__retval(3)
+int exact_name(void *ctx)
+{
+	return bpf_kfunc_flavor(1, 2);
+}
+
+/* the old prototype under a local flavor binds ___v1 */
+SEC("syscall")
+__retval(1)
+int local_flavor(void *ctx)
+{
+	return bpf_kfunc_flavor___old(1);
+}
+
+/* so does the kernel name, which strips to bpf_kfunc_flavor */
+SEC("syscall")
+__retval(1)
+int kernel_flavor(void *ctx)
+{
+	return bpf_kfunc_flavor___v1(1);
+}
+
+/* a local flavor on top of the kernel name binds ___v1 by name */
+SEC("syscall")
+__retval(1)
+int stacked_flavor(void *ctx)
+{
+	return bpf_kfunc_flavor___v1___local(1);
+}
+
+/* a __weak kfunc that matches no member stays unresolved */
+SEC("syscall")
+__retval(0)
+int no_match(void *ctx)
+{
+	return bpf_ksym_exists(bpf_kfunc_flavor___none);
+}
diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
index 1f8bc0c99a710f..e165596072708a 100644
--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
@@ -1926,6 +1926,27 @@ __bpf_kfunc void bpf_kfunc_trigger_ctx_check(void)
 	irq_work_queue(&ctx_check_irq);
 }
 
+/*
+ * A kfunc family for the kfunc_flavors test: bpf_kfunc_flavor() has the
+ * current prototype, ___v1 an older one, and ___v2 is an alias with its exact
+ * prototype. ___v2 negates the result, so that the test can tell which of the
+ * two it called.
+ */
+__bpf_kfunc int bpf_kfunc_flavor(int a, int b)
+{
+	return a + b;
+}
+
+__bpf_kfunc int bpf_kfunc_flavor___v1(int a)
+{
+	return bpf_kfunc_flavor(a, 0);
+}
+
+__bpf_kfunc int bpf_kfunc_flavor___v2(int a, int b)
+{
+	return -bpf_kfunc_flavor(a, b);
+}
+
 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)
@@ -2017,6 +2038,9 @@ 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_flavor)
+BTF_ID_FLAGS(func, bpf_kfunc_flavor___v1)
+BTF_ID_FLAGS(func, bpf_kfunc_flavor___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..2c6126e4f0d0b0 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,8 @@ 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_flavor(int a, int b) __ksym;
+int bpf_kfunc_flavor___v1(int a) __ksym;
+int bpf_kfunc_flavor___v2(int a, int b) __ksym;
+
 #endif /* _BPF_TESTMOD_KFUNC_H */

3/2 2026/11/21 16:35 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 12014
							output: 115
							thoughts: 3044
						

Thoughts:
**Analysis of the Patch: WorthFuzzing=false**

Okay, let's break this down. First, I see the list of modified files. Right away, my expert eye scans for anything that touches core kernel code – anything that might be in `kernel/`, `net/`, `mm/`, `drivers/`, etc. But no, nothing like that here. I'm seeing:

*   `Documentation/` - Documentation, clearly not kernel code.
*   `tools/bpf/resolve_btfids/` - User-space tool. This resolves BTF IDs. This is a host-side tool used during build time.
*   `tools/lib/bpf/` - User-space library, libbpf.
*   `tools/testing/selftests/` - Self-tests.

So, all the changes are within those user-space or build-time areas. Now, the prompt gives me very specific negative criteria. Let's see... it says I should return `WorthFuzzing=false` if *all* modified code falls into certain categories. The key phrase here is "**that do not affect the compiled kernel image (vmlinux) or kernel modules.**"

Let's carefully check this.

*   `Documentation/bpf/kfuncs.rst` is Documentation, so that is fine.
*   `tools/bpf/resolve_btfids/*` is a build time tool. It resolves BTF IDs during kernel build time. It *doesn't* alter the compiled kernel image or standard kernel modules.
*   `tools/lib/bpf/*` is user-space code. Syzkaller doesn't use it.
*   `tools/testing/selftests/*` contains test modules, like `bpf_testmod`. Critically, this is *specifically* mentioned as an exclusion. The test modules are in `tools/testing/selftests/bpf/test_kmods/` so they are not part of the standard kernel build.

Okay, I'm now certain this meets one of the exclusion criteria. Specifically, the negative triage criteria explicitly states that the changes are: "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."

Let's revisit the changes to `resolve_btfids`: It's a build-time tool. The changes there include a check called `check_kfunc_families` that's added to `main.c`. This check verifies that kfuncs with compatible prototypes have distinct names. It's a build-time sanity check, *not* a modification to the kernel's compiled logic or runtime behavior. It's a build-time check only.

`libbpf` is a userspace library. It's not part of the kernel image or modules.

Let's go back to the explicit negative criteria. Since all of the changes are to documentation, a build tool, a user space library, and selftests, I'm confident that these changes *do not* warrant fuzzing.

My conclusion is:
*   `WorthFuzzing` should be `false` because the patch only touches documentation, a build time tool that does not affect compiled kernel logic, and user-space code (libbpf, and selftests which are *explicitly* excluded). No core kernel or standard kernel driver/module code is affected.

Now, let's prepare the call for `set-results`.

-   `WorthFuzzing`: `false`
-   `Reasoning`: "The patch only modifies documentation, build-time host tooling, the userspace BPF library, and BPF selftests. No kernel code within vmlinux or standard kernel drivers/modules is modified. Build-time validation added to `resolve_btfids` and changes to `libbpf` do not modify compiled C kernel logic or runtime kernel execution. According to negative triage criteria, changes confined to `Documentation/`, `tools/`, and selftests do not warrant fuzzing."
-   `FocusSymbols`: `[]`
-   `EnableConfigs`: `[]`

And I'm all set.



4/2 2026/11/21 16:36 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "All changes in this patch series are strictly confined to Documentation/ and tools/ (specifically the resolve_btfids build tool, the userspace libbpf library, and selftests under tools/testing/selftests/). No executable code in the kernel image (vmlinux) or standard in-tree kernel modules is modified. Consequently, the changes are not relevant for syzkaller kernel fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "All changes in this patch series are strictly confined to Documentation/ and tools/ (specifically the resolve_btfids build tool, the userspace libbpf library, and selftests under tools/testing/selftests/). No executable code in the kernel image (vmlinux) or standard in-tree kernel modules is modified. Consequently, the changes are not relevant for syzkaller kernel fuzzing.",
  "WorthFuzzing": false
}

5/1 2026/11/21 16:36 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)