| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/09/29 21:20 | flow | patch-triage |
4mArgs:null Results: {
"EnableConfigs": [
"BPF_SYSCALL",
"DEBUG_INFO_BTF"
],
"FocusSymbols": [
"btf_check_func_arg_match",
"gen_subprog_arg_proto",
"check_func_args",
"check_func_arg",
"btf_check_subprog_call",
"check_func_call"
],
"KMSANReasoning": "The patch refactors BPF subprogram argument verification in `kernel/bpf/verifier.c` to unify it with the helper/kfunc argument checking path (`check_func_args()`), avoiding duplicated logic in `btf_check_func_arg_match()`.\n\nAll newly introduced or modified structures, such as `env-\u003ebpf_subprog_scratch` and the stack-allocated `struct bpf_call_arg_meta meta`, are explicitly cleared with `memset` before use, leaving no uninitialized fields. Furthermore, the patch does not introduce or modify any copy operations to userspace, does not alter buffer initialization, and does not introduce conditional branches based on uninitialized memory. Any potential regressions or bugs in verifier type-checking or register tracking would manifest as logical errors, out-of-bounds access, or invalid pointer dereferences, which are already covered by KASAN and standard verifier assertions. Consequently, there is no risk of uninitialized memory usage or info-leaks that would require a dedicated KMSAN fuzzing session.",
"NeedsKMSAN": false,
"Reasoning": "The patch refactors the BPF verifier's argument validation logic for subprogram calls to reuse the unified helper/kfunc argument checking infrastructure (check_func_args and check_func_arg) via a synthetic bpf_func_proto generated in gen_subprog_arg_proto. This directly touches core verifier logic in kernel/bpf/verifier.c reachable via the bpf(BPF_PROG_LOAD) syscall when loading eBPF programs containing subprograms with BTF type information. Fuzzing is warranted to detect regressions, type confusion, or verifier invariant violations.",
"WorthFuzzing": true
} |
| 1/1 | 2026/09/29 21:20 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit fe5e0d8bef154f9d665413ae1df92e68032ce883\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Tue Sep 29 21:20:42 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h\nindex 646e447cebd84..385a63edc0952 100644\n--- a/include/linux/bpf_verifier.h\n+++ b/include/linux/bpf_verifier.h\n@@ -972,6 +972,7 @@ struct bpf_verifier_env {\n \tconst struct bpf_line_info *prev_linfo;\n \tstruct bpf_verifier_log log;\n \tstruct bpf_diag *diag;\n+\tstruct bpf_func_proto bpf_subprog_scratch;\n \tstruct bpf_subprog_info subprog_info[BPF_MAX_SUBPROGS + 2]; /* max + 2 for the fake and exception subprogs */\n \t/* subprog indices sorted in topological order: leaves first, callers last */\n \tint subprog_topo_order[BPF_MAX_SUBPROGS + 2];\n@@ -1638,6 +1639,7 @@ struct bpf_call_arg_meta {\n \tstruct btf *btf;\n \tu32 func_id;\n \tconst struct bpf_func_proto *fn;\n+\tconst struct btf_type *func_proto;\n \tu8 release_regno;\n \tu32 ret_btf_id;\n \tu32 subprogno;\n@@ -1647,10 +1649,12 @@ struct bpf_call_arg_meta {\n \tstruct ret_mem_desc ret_mem;\n \tstruct arg_raw_mem_desc arg_raw_mem;\n \n+\t/* Only set by subprog */\n+\tbool subprog_may_change_pkt;\n+\n \t/* Only set by kfunc */\n \tbool r0_rdonly;\n \tu32 kfunc_flags;\n-\tconst struct btf_type *func_proto;\n \tconst char *func_name;\n \tstruct arg_constant_desc arg_constant;\n \ndiff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c\nindex 5c8626215ee6c..1a0a11a4894fd 100644\n--- a/kernel/bpf/verifier.c\n+++ b/kernel/bpf/verifier.c\n@@ -7702,6 +7702,11 @@ static int check_mem_size_reg(struct bpf_verifier_env *env,\n \treturn err;\n }\n \n+static bool is_subprog(const struct bpf_call_arg_meta *meta)\n+{\n+\treturn meta-\u003ebtf \u0026\u0026 !meta-\u003efunc_id;\n+}\n+\n static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\n \t\t\t argno_t argno, u32 mem_size, enum bpf_access_type access_type,\n \t\t\t struct bpf_call_arg_meta *meta, bool *known_memory)\n@@ -7720,10 +7725,11 @@ static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg\n \t}\n \n \t/*\n-\t * Only a global subprog (meta == NULL) may read poisoned stack slots:\n+\t * Only a global subprog may read poisoned stack slots:\n \t * its static stack liveness proved the callee body skips them.\n \t */\n-\tsize = (!meta \u0026\u0026 base_type(reg-\u003etype) == PTR_TO_STACK) ? -(int)mem_size : mem_size;\n+\tsize = (is_subprog(meta) \u0026\u0026\n+\t\tbase_type(reg-\u003etype) == PTR_TO_STACK) ? -(int)mem_size : mem_size;\n \n \tif (access_type \u0026 BPF_READ)\n \t\terr = check_helper_mem_access(env, reg, argno, size, BPF_READ, true, meta,\n@@ -8263,12 +8269,12 @@ static bool is_kfunc_arg_iter(struct bpf_call_arg_meta *meta, int arg_idx,\n \treturn btf_param_match_suffix(meta-\u003ebtf, arg, \"__iter\");\n }\n \n-static int process_iter_arg(struct bpf_verifier_env *env, struct bpf_reg_state *reg, argno_t argno, int insn_idx,\n+static int process_iter_arg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\n+\t\t\t u32 arg, argno_t argno, int insn_idx,\n \t\t\t struct bpf_call_arg_meta *meta)\n {\n \tstruct bpf_func_state *state = bpf_func(env, reg);\n \tconst struct btf_type *t;\n-\tu32 arg_idx = arg_idx_from_argno(argno);\n \tint spi, err, i, nr_slots, btf_id;\n \n \tif (reg-\u003etype != PTR_TO_STACK) {\n@@ -8288,7 +8294,7 @@ static int process_iter_arg(struct bpf_verifier_env *env, struct bpf_reg_state *\n \t * to any kfunc, if arg has \"__iter\" suffix, we need to be a bit more\n \t * conservative here.\n \t */\n-\tbtf_id = btf_check_iter_arg(meta-\u003ebtf, meta-\u003efunc_proto, arg_idx);\n+\tbtf_id = btf_check_iter_arg(meta-\u003ebtf, meta-\u003efunc_proto, arg);\n \tif (btf_id \u003c 0) {\n \t\tverbose(env, \"expected valid iter pointer as %s\\n\",\n \t\t\treg_arg_name(env, argno));\n@@ -8638,18 +8644,27 @@ static bool arg_type_is_scalar(enum bpf_arg_type type)\n }\n \n /*\n- * A kfunc is named by a BTF ID, which can take the same numeric value as an\n- * enum bpf_func_id. Only test meta-\u003efunc_id against a BPF_FUNC_* once the call\n- * is known to be to a helper; meta-\u003ebtf is set only for a kfunc.\n+ * A helper has no BTF and a nonzero function ID. A kfunc has both, while a\n+ * BPF subprogram has BTF and a zero function ID.\n */\n+static bool is_helper(const struct bpf_call_arg_meta *meta)\n+{\n+\treturn !meta-\u003ebtf \u0026\u0026 meta-\u003efunc_id;\n+}\n+\n static bool is_helper_call(const struct bpf_call_arg_meta *meta, enum bpf_func_id func_id)\n {\n-\treturn !meta-\u003ebtf \u0026\u0026 meta-\u003efunc_id == func_id;\n+\treturn is_helper(meta) \u0026\u0026 meta-\u003efunc_id == func_id;\n+}\n+\n+static bool is_kfunc(const struct bpf_call_arg_meta *meta)\n+{\n+\treturn meta-\u003ebtf \u0026\u0026 meta-\u003efunc_id;\n }\n \n static bool is_kfunc_call(const struct bpf_call_arg_meta *meta, u32 btf_id)\n {\n-\treturn meta-\u003ebtf \u0026\u0026 meta-\u003efunc_id == btf_id;\n+\treturn is_kfunc(meta) \u0026\u0026 meta-\u003efunc_id == btf_id;\n }\n \n static int resolve_map_arg_type(struct bpf_verifier_env *env,\n@@ -8919,7 +8934,7 @@ __printf(6, 7) static void bpf_diag_call_arg_fmt(struct bpf_verifier_env *env, u\n }\n \n static int check_func_arg_nullability(struct bpf_verifier_env *env,\n-\t\t\t\t struct bpf_reg_state *reg, argno_t argno,\n+\t\t\t\t struct bpf_reg_state *reg, u32 arg, argno_t argno,\n \t\t\t\t enum bpf_arg_type arg_type,\n \t\t\t\t struct bpf_call_arg_meta *meta, int insn_idx)\n {\n@@ -8932,7 +8947,7 @@ static int check_func_arg_nullability(struct bpf_verifier_env *env,\n \tif (meta-\u003ebtf) {\n \t\tu32 arg_btf_id;\n \n-\t\targ_btf_id = btf_params(meta-\u003efunc_proto)[arg_idx_from_argno(argno)].type;\n+\t\targ_btf_id = btf_params(meta-\u003efunc_proto)[arg].type;\n \t\texpected_type = bpf_diag_fmt(env, \"value of type %s\",\n \t\t\t\t\t bpf_diag_fmt_btf_type(env, meta-\u003ebtf, arg_btf_id));\n \t}\n@@ -8947,7 +8962,7 @@ static int check_func_arg_nullability(struct bpf_verifier_env *env,\n }\n \n static int check_func_arg_release(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\n-\t\t\t\t argno_t argno, enum bpf_arg_type arg_type,\n+\t\t\t\t u32 arg, argno_t argno, enum bpf_arg_type arg_type,\n \t\t\t\t struct bpf_call_arg_meta *meta, int insn_idx)\n {\n \tconst char *expected_type = \"pointer\";\n@@ -8962,12 +8977,12 @@ static int check_func_arg_release(struct bpf_verifier_env *env, struct bpf_reg_s\n \tverbose(env, \"release function %s expects referenced PTR_TO_BTF_ID passed to %s\\n\",\n \t\tmeta-\u003efunc_name, reg_arg_name(env, argno));\n \n-\tif (meta-\u003ebtf) {\n+\tif (is_kfunc(meta)) {\n \t\tconst struct btf_param *btf_arg;\n \t\tconst struct btf_type *t;\n \t\tu32 ref_id;\n \n-\t\tbtf_arg = \u0026btf_params(meta-\u003efunc_proto)[arg_idx_from_argno(argno)];\n+\t\tbtf_arg = \u0026btf_params(meta-\u003efunc_proto)[arg];\n \t\tref_id = btf_arg-\u003etype;\n \t\tt = btf_type_skip_modifiers(meta-\u003ebtf, btf_arg-\u003etype, NULL);\n \t\tif (btf_type_is_ptr(t))\n@@ -9016,7 +9031,7 @@ static int check_reg_type(struct bpf_verifier_env *env, struct bpf_reg_state *re\n \t\tverifier_bug(env, \"unsupported arg type %d\", arg_type);\n \t\treturn -EFAULT;\n \t}\n-\tif (meta-\u003ebtf \u0026\u0026 base_type(arg_type) == ARG_PTR_TO_BTF_ID \u0026\u0026\n+\tif (is_kfunc(meta) \u0026\u0026 base_type(arg_type) == ARG_PTR_TO_BTF_ID \u0026\u0026\n \t (base_type(type) == PTR_TO_BTF_ID || reg2btf_ids[base_type(type)]))\n \t\tgoto found;\n \n@@ -9038,8 +9053,8 @@ static int check_reg_type(struct bpf_verifier_env *env, struct bpf_reg_state *re\n \t\ttype \u0026= ~PTR_MAYBE_NULL;\n \tif (base_type(arg_type) == ARG_PTR_TO_MEM)\n \t\ttype \u0026= ~DYNPTR_TYPE_FLAG_MASK;\n-\t/* Allow allocated memory for kfunc ARG_PTR_TO_MEM but not helper. */\n-\tif (meta-\u003ebtf \u0026\u0026 base_type(arg_type) == ARG_PTR_TO_MEM \u0026\u0026\n+\t/* Allow allocated memory for BTF-defined ARG_PTR_TO_MEM but not helpers. */\n+\tif (!is_helper(meta) \u0026\u0026 base_type(arg_type) == ARG_PTR_TO_MEM \u0026\u0026\n \t type_is_ptr_alloc_obj(type))\n \t\ttype = PTR_TO_MEM;\n \n@@ -9362,7 +9377,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p\n \t\t\t struct bpf_call_arg_meta *meta,\n \t\t\t int insn_idx)\n {\n-\tconst struct btf_param *btf_arg = meta-\u003ebtf ? \u0026btf_params(meta-\u003efunc_proto)[arg] : NULL;\n+\tconst struct btf_param *btf_arg = is_kfunc(meta) ?\n+\t\t\t\t\t \u0026btf_params(meta-\u003efunc_proto)[arg] : NULL;\n \tconst struct bpf_func_proto *fn = meta-\u003efn;\n \tstruct bpf_func_state *caller = cur_func(env);\n \tstruct bpf_reg_state *regs = cur_regs(env);\n@@ -9412,7 +9428,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p\n \t\treturn 0;\n \t}\n \n-\terr = check_func_arg_nullability(env, reg, argno, arg_type, meta, insn_idx);\n+\terr = check_func_arg_nullability(env, reg, arg, argno, arg_type, meta, insn_idx);\n \tif (err)\n \t\treturn err;\n \n@@ -9424,7 +9440,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p\n \tif (err)\n \t\treturn err;\n \n-\terr = check_func_arg_release(env, reg, argno, arg_type, meta, insn_idx);\n+\terr = check_func_arg_release(env, reg, arg, argno, arg_type, meta, insn_idx);\n \tif (err)\n \t\treturn err;\n \n@@ -9502,7 +9518,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p\n \tcase ARG_PTR_TO_BTF_ID_SOCK_COMMON:\n \t{\n \t\tconst u32 *arg_btf_id = fn-\u003earg_btf_id[arg];\n-\t\tconst struct btf *arg_btf = meta-\u003ebtf ?: btf_vmlinux;\n+\t\tconst struct btf *arg_btf = is_kfunc(meta) ? meta-\u003ebtf : btf_vmlinux;\n \n \t\tif (!meta-\u003ebtf) {\n \t\t\tconst struct bpf_reg_types *compatible;\n@@ -9530,8 +9546,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p\n \t\t\t}\n \t\t}\n \n-\t\tif (meta-\u003ebtf \u0026\u0026 (!is_trusted_reg(env, reg) ||\n-\t\t\t\t bpf_type_has_unsafe_modifiers(reg-\u003etype))) {\n+\t\tif (is_kfunc(meta) \u0026\u0026 (!is_trusted_reg(env, reg) ||\n+\t\t\t\t bpf_type_has_unsafe_modifiers(reg-\u003etype))) {\n \t\t\tif (!(arg_type \u0026 MEM_RCU)) {\n \t\t\t\tconst char *actual_type, *arg_name, *expected_type;\n \n@@ -9668,6 +9684,17 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p\n \t\t\t\t\tbpf_diag_reg_type_plain(env, reg-\u003etype));\n \t\t\treturn err;\n \t\t}\n+\t\t/*\n+\t\t * PTR_TO_PACKET gets passed as PTR_TO_MEM, preventing us from adjusting\n+\t\t * bounds tracking information.\n+\t\t */\n+\t\tif (is_subprog(meta) \u0026\u0026 meta-\u003esubprog_may_change_pkt \u0026\u0026\n+\t\t (reg_is_pkt_pointer_any(reg) || reg_is_dynptr_slice_pkt(reg))) {\n+\t\t\tverbose(env,\n+\t\t\t\t\"cannot pass packet pointer %s to %s(): function may change packet data\\n\",\n+\t\t\t\treg_arg_name(env, argno), meta-\u003efunc_name);\n+\t\t\treturn -EINVAL;\n+\t\t}\n \t\tif (arg_type \u0026 MEM_ALIGNED)\n \t\t\terr = check_ptr_alignment(env, reg, 0, arg_size, true);\n \t\tbreak;\n@@ -9758,7 +9785,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p\n \t\t\tverbose(env, \"css_task_iter is only allowed in bpf_lsm, bpf_iter and sleepable progs\\n\");\n \t\t\treturn -EINVAL;\n \t\t}\n-\t\terr = process_iter_arg(env, reg, argno, insn_idx, meta);\n+\t\terr = process_iter_arg(env, reg, arg, argno, insn_idx, meta);\n \t\tif (err \u003c 0)\n \t\t\treturn err;\n \t\tbreak;\n@@ -9930,20 +9957,20 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p\n * func model recorded, or the verifier would check an argument at a slot\n * the JIT does not place it at.\n */\n-static u32 kfunc_arg_slots(const struct btf_type *t)\n+static u32 btf_arg_slots(const struct btf_type *t)\n {\n \tif (btf_type_is_int(t) || btf_type_is_struct(t))\n \t\treturn (t-\u003esize + BPF_REG_SIZE - 1) / BPF_REG_SIZE;\n \treturn 1;\n }\n \n-static u32 kfunc_proto_slots(const struct btf *btf, const struct btf_type *func_proto)\n+static u32 btf_proto_slots(const struct btf *btf, const struct btf_type *func_proto)\n {\n \tconst struct btf_param *args = btf_params(func_proto);\n \tu32 i, nargs = btf_type_vlen(func_proto), slots_used = 0;\n \n \tfor (i = 0; i \u003c nargs; i++)\n-\t\tslots_used += kfunc_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));\n+\t\tslots_used += btf_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));\n \n \treturn slots_used;\n }\n@@ -9986,7 +10013,7 @@ static int check_func_args(struct bpf_verifier_env *env, struct bpf_call_arg_met\n \t * count. Only a proto whose parameters take a slot each can name the\n \t * argument a stack slot belongs to.\n \t */\n-\tproto_slots = meta-\u003ebtf ? kfunc_proto_slots(meta-\u003ebtf, meta-\u003efunc_proto) : nargs;\n+\tproto_slots = meta-\u003ebtf ? btf_proto_slots(meta-\u003ebtf, meta-\u003efunc_proto) : nargs;\n \n \tif (proto_slots \u003e MAX_BPF_FUNC_REG_ARGS) {\n \t\terr = check_outgoing_stack_args(env, caller, proto_slots, meta-\u003efunc_name,\n@@ -10002,7 +10029,7 @@ static int check_func_args(struct bpf_verifier_env *env, struct bpf_call_arg_met\n \t\tnslots = 1;\n \t\tif (args) {\n \t\t\tt = btf_type_skip_modifiers(meta-\u003ebtf, args[arg].type, NULL);\n-\t\t\tnslots = kfunc_arg_slots(t);\n+\t\t\tnslots = btf_arg_slots(t);\n \t\t}\n \n \t\tif (meta-\u003efn-\u003earg_type[arg] == ARG_UNUSED)\n@@ -10787,21 +10814,50 @@ static int setup_func_entry(struct bpf_verifier_env *env, int subprog, int calls\n \treturn err;\n }\n \n-static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,\n-\t\t\t\t const struct btf *btf,\n-\t\t\t\t struct bpf_reg_state *regs)\n+static void gen_subprog_arg_proto(const struct bpf_subprog_info *sub, const struct btf *btf,\n+\t\t\t\t const struct btf_type *func_proto, struct bpf_func_proto *proto)\n+{\n+\tconst struct btf_param *args = btf_params(func_proto);\n+\tu32 arg, slot = 0;\n+\n+\tmemset(proto, 0, sizeof(*proto));\n+\tfor (arg = 0; arg \u003c btf_type_vlen(func_proto); arg++) {\n+\t\tenum bpf_arg_type arg_type = sub-\u003eargs[slot].arg_type;\n+\t\tconst struct btf_type *t;\n+\n+\t\tif (arg_type \u0026 PTR_UNTRUSTED) {\n+\t\t\t/*\n+\t\t\t * An __arg_untrusted argument accepts any caller value. The\n+\t\t\t * callee treats it as read-only and uses probe-read instructions\n+\t\t\t * to protect against invalid memory access.\n+\t\t\t */\n+\t\t\targ_type = ARG_IGNORE;\n+\t\t} else if (base_type(arg_type) == ARG_PTR_TO_ARENA) {\n+\t\t\targ_type |= PTR_MAYBE_NULL;\n+\t\t} else if (base_type(arg_type) == ARG_PTR_TO_MEM) {\n+\t\t\tproto-\u003earg_size[arg] = sub-\u003eargs[slot].mem_size;\n+\t\t\targ_type |= MEM_FIXED_SIZE | MEM_WRITE;\n+\t\t} else if (base_type(arg_type) == ARG_PTR_TO_BTF_ID) {\n+\t\t\tproto-\u003earg_btf_id[arg] = \u0026sub-\u003eargs[slot].btf_id;\n+\t\t}\n+\t\tproto-\u003earg_type[arg] = arg_type;\n+\t\tt = btf_type_skip_modifiers(btf, args[arg].type, NULL);\n+\t\tslot += btf_arg_slots(t);\n+\t}\n+}\n+\n+static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog, struct btf *btf)\n {\n \tstruct bpf_subprog_info *sub = subprog_info(env, subprog);\n \tstruct bpf_func_state *caller = cur_func(env);\n-\tstruct bpf_verifier_log *log = \u0026env-\u003elog;\n-\tconst struct btf_param *args;\n \tconst struct btf_type *func, *func_proto;\n \tstruct bpf_call_arg_meta meta;\n-\tu32 i;\n+\tstruct bpf_func_proto *fn;\n \tint ret, err;\n \n-\t/* Leave btf and func_id zero: this is neither a helper nor a kfunc. */\n \tmemset(\u0026meta, 0, sizeof(meta));\n+\tmeta.btf = btf;\n+\tmeta.subprog_may_change_pkt = sub-\u003echanges_pkt_data;\n \tmeta.func_name = bpf_subprog_name(env, subprog);\n \n \tret = btf_prepare_func_args(env, subprog);\n@@ -10818,127 +10874,24 @@ static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,\n \n \tfunc = btf_type_by_id(btf, env-\u003eprog-\u003eaux-\u003efunc_info[subprog].type_id);\n \tfunc_proto = btf_type_by_id(btf, func-\u003etype);\n-\targs = btf_params(func_proto);\n-\tif (sub-\u003earg_slot_cnt != btf_type_vlen(func_proto))\n-\t\targs = NULL;\n-\tret = check_outgoing_stack_args(env, caller, sub-\u003earg_slot_cnt,\n-\t\t\t\t\tbpf_subprog_name(env, subprog), btf, args);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\t/* check that BTF function arguments match actual types that the\n-\t * verifier sees.\n-\t */\n-\tfor (i = 0; i \u003c sub-\u003earg_slot_cnt; i++) {\n-\t\targno_t argno = argno_from_arg(i + 1);\n-\t\tstruct bpf_reg_state *reg = get_func_arg_reg(caller, regs, i);\n-\t\tstruct bpf_subprog_arg_info *arg = \u0026sub-\u003eargs[i];\n-\n-\t\tif (arg-\u003earg_type == ARG_SCALAR) {\n-\t\t\tif (reg-\u003etype != SCALAR_VALUE) {\n-\t\t\t\tbpf_log(log, \"%s is not a scalar\\n\", reg_arg_name(env, argno));\n-\t\t\t\treturn -EINVAL;\n-\t\t\t}\n-\t\t} else if (arg-\u003earg_type \u0026 PTR_UNTRUSTED) {\n-\t\t\t/*\n-\t\t\t * Anything is allowed for untrusted arguments, as these are\n-\t\t\t * read-only and probe read instructions would protect against\n-\t\t\t * invalid memory access.\n-\t\t\t */\n-\t\t} else if (arg-\u003earg_type == ARG_PTR_TO_CTX) {\n-\t\t\tret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_CTX);\n-\t\t\tif (ret \u003c 0)\n-\t\t\t\treturn ret;\n-\t\t\t/* If function expects ctx type in BTF check that caller\n-\t\t\t * is passing PTR_TO_CTX.\n-\t\t\t */\n-\t\t\tif (reg-\u003etype != PTR_TO_CTX) {\n-\t\t\t\tbpf_log(log, \"%s expects pointer to ctx\\n\",\n-\t\t\t\t\treg_arg_name(env, argno));\n-\t\t\t\treturn -EINVAL;\n-\t\t\t}\n-\t\t} else if (base_type(arg-\u003earg_type) == ARG_PTR_TO_MEM) {\n-\t\t\tret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_MEM);\n-\t\t\tif (ret \u003c 0)\n-\t\t\t\treturn ret;\n-\t\t\tif (check_mem_reg(env, reg, argno, arg-\u003emem_size, BPF_READ | BPF_WRITE, NULL,\n-\t\t\t\t\t NULL))\n-\t\t\t\treturn -EINVAL;\n-\t\t\t/*\n-\t\t\t * PTR_TO_PACKET get passed as PTR_TO_MEM, preventing\n-\t\t\t * us from adjusting bounds tracking info.\n-\t\t\t */\n-\t\t\tif ((reg_is_pkt_pointer_any(reg) || reg_is_dynptr_slice_pkt(reg)) \u0026\u0026\n-\t\t\t sub-\u003echanges_pkt_data) {\n-\t\t\t\tbpf_log(log, \"%s is a packet pointer, but func#%d may change packet data\\n\",\n-\t\t\t\t\t\treg_arg_name(env, argno), subprog);\n-\t\t\t\treturn -EINVAL;\n-\t\t\t}\n-\t\t\tif (!(arg-\u003earg_type \u0026 PTR_MAYBE_NULL) \u0026\u0026\n-\t\t\t (type_may_be_null(reg-\u003etype) || bpf_register_is_null(reg))) {\n-\t\t\t\tbpf_log(log, \"%s is expected to be non-NULL\\n\",\n-\t\t\t\t\treg_arg_name(env, argno));\n-\t\t\t\treturn -EINVAL;\n-\t\t\t}\n-\t\t} else if (base_type(arg-\u003earg_type) == ARG_PTR_TO_ARENA) {\n-\t\t\t/*\n-\t\t\t * Can pass any value and the kernel won't crash, but\n-\t\t\t * only PTR_TO_ARENA or SCALAR make sense. Everything\n-\t\t\t * else is a bug in the bpf program. Point it out to\n-\t\t\t * the user at the verification time instead of\n-\t\t\t * run-time debug nightmare.\n-\t\t\t */\n-\t\t\tif (reg-\u003etype != PTR_TO_ARENA \u0026\u0026 reg-\u003etype != SCALAR_VALUE) {\n-\t\t\t\tbpf_log(log, \"%s is not a pointer to arena or scalar.\\n\",\n-\t\t\t\t\treg_arg_name(env, argno));\n-\t\t\t\treturn -EINVAL;\n-\t\t\t}\n-\t\t} else if (arg-\u003earg_type == ARG_PTR_TO_DYNPTR) {\n-\t\t\tret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_DYNPTR);\n-\t\t\tif (ret)\n-\t\t\t\treturn ret;\n-\n-\t\t\tret = process_dynptr_func(env, reg, argno, env-\u003einsn_idx,\n-\t\t\t\t\t\t arg-\u003earg_type, \u0026meta);\n-\t\t\tif (ret)\n-\t\t\t\treturn ret;\n-\t\t} else if (base_type(arg-\u003earg_type) == ARG_PTR_TO_BTF_ID) {\n-\t\t\tint err;\n-\n-\t\t\tif (bpf_register_is_null(reg) \u0026\u0026 type_may_be_null(arg-\u003earg_type)) {\n-\t\t\t\terr = mark_arg_precision(env, argno);\n-\t\t\t\tif (err)\n-\t\t\t\t\treturn err;\n-\t\t\t\tcontinue;\n-\t\t\t}\n \n-\t\t\terr = check_reg_type(env, reg, argno, arg-\u003earg_type, \u0026meta);\n-\t\t\terr = err ?: check_func_arg_reg_off(env, reg, argno, arg-\u003earg_type);\n-\t\t\tif (!err \u0026\u0026 base_type(reg-\u003etype) == PTR_TO_BTF_ID)\n-\t\t\t\terr = process_arg_ptr_to_btf_id(env, reg, argno, arg-\u003earg_type,\n-\t\t\t\t\t\t\t\tbtf_vmlinux, arg-\u003ebtf_id,\n-\t\t\t\t\t\t\t\t\u0026meta, env-\u003einsn_idx);\n-\t\t\tif (err)\n-\t\t\t\treturn err;\n-\t\t} else {\n-\t\t\tverifier_bug(env, \"unrecognized %s type %d\",\n-\t\t\t\t reg_arg_name(env, argno), arg-\u003earg_type);\n-\t\t\treturn -EFAULT;\n-\t\t}\n-\t}\n+\tfn = \u0026env-\u003ebpf_subprog_scratch;\n+\tgen_subprog_arg_proto(sub, btf, func_proto, fn);\n+\tmeta.fn = fn;\n+\tmeta.func_proto = func_proto;\n \n-\treturn 0;\n+\treturn check_func_args(env, \u0026meta, env-\u003einsn_idx);\n }\n \n-/* Compare BTF of a function call with given bpf_reg_state.\n+/*\n+ * Check that call-site argument states match a subprog's BTF signature.\n+ *\n * Returns:\n * EFAULT - there is a verifier bug. Abort verification.\n- * EINVAL - there is a type mismatch or BTF is not available.\n+ * Other errors - there is a type mismatch or BTF is not available.\n * 0 - BTF matches with what bpf_reg_state expects.\n- * Only PTR_TO_CTX and SCALAR_VALUE states are recognized.\n */\n-static int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog,\n-\t\t\t\t struct bpf_reg_state *regs)\n+static int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog)\n {\n \tstruct bpf_prog *prog = env-\u003eprog;\n \tstruct btf *btf = prog-\u003eaux-\u003ebtf;\n@@ -10955,7 +10908,7 @@ static int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog,\n \tif (prog-\u003eaux-\u003efunc_info_aux[subprog].unreliable)\n \t\treturn -EINVAL;\n \n-\terr = btf_check_func_arg_match(env, subprog, btf, regs);\n+\terr = btf_check_func_arg_match(env, subprog, btf);\n \t/* Compiler optimizations can remove arguments from static functions\n \t * or mismatched type can be passed into a global function.\n \t * In such cases mark the function as unreliable from BTF point of view.\n@@ -10974,7 +10927,7 @@ static int push_callback_call(struct bpf_verifier_env *env, struct bpf_insn *ins\n \tint err;\n \n \tcaller = state-\u003eframe[state-\u003ecurframe];\n-\terr = btf_check_subprog_call(env, subprog, caller-\u003eregs);\n+\terr = btf_check_subprog_call(env, subprog);\n \tif (err == -EFAULT)\n \t\treturn err;\n \n@@ -11111,7 +11064,7 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,\n \t\treturn -EFAULT;\n \n \tcaller = state-\u003eframe[state-\u003ecurframe];\n-\terr = btf_check_subprog_call(env, subprog, caller-\u003eregs);\n+\terr = btf_check_subprog_call(env, subprog);\n \tif (err == -EFAULT)\n \t\treturn err;\n \tif (bpf_subprog_is_global(env, subprog)) {\n@@ -11247,7 +11200,7 @@ static int check_func_callx(struct bpf_verifier_env *env, struct bpf_insn *insn,\n \n \t/* PTR_TO_FUNC is a pointer to a static subprog */\n \tsubprog = reg-\u003esubprogno;\n-\terr = btf_check_subprog_call(env, subprog, caller-\u003eregs);\n+\terr = btf_check_subprog_call(env, subprog);\n \tif (err == -EFAULT)\n \t\treturn err;\n \n@@ -13058,7 +13011,7 @@ static int resolve_func_arg_type(struct bpf_verifier_env *env,\n \tif (base_type(*arg_type) != ARG_PTR_TO_BTF_ID)\n \t\treturn 0;\n \n-\tif (!meta-\u003ebtf || arg_type_is_release(*arg_type) ||\n+\tif (!is_kfunc(meta) || arg_type_is_release(*arg_type) ||\n \t base_type(reg-\u003etype) == PTR_TO_BTF_ID ||\n \t reg2btf_ids[base_type(reg-\u003etype)])\n \t\treturn 0;\n@@ -13781,7 +13734,7 @@ static int process_arg_ptr_to_btf_id(struct bpf_verifier_env *env, struct bpf_re\n \t * resolve types.\n \t */\n \tif ((arg_type_is_release(arg_type) \u0026\u0026 !is_helper_call(meta, BPF_FUNC_sk_release)) ||\n-\t (meta-\u003ebtf \u0026\u0026 btf_type_ids_nocast_alias(\u0026env-\u003elog, reg_btf, reg_btf_id,\n+\t (is_kfunc(meta) \u0026\u0026 btf_type_ids_nocast_alias(\u0026env-\u003elog, reg_btf, reg_btf_id,\n \t\t\t\t\t\t arg_btf, arg_btf_id)))\n \t\tstrict_type_match = true;\n \n@@ -13798,7 +13751,7 @@ static int process_arg_ptr_to_btf_id(struct bpf_verifier_env *env, struct bpf_re\n \t * actually use it -- it must cast to the underlying type. So we allow\n \t * caller to pass in the underlying type.\n \t */\n-\ttaking_projection = meta-\u003ebtf \u0026\u0026 btf_is_projection_of(arg_tname, reg_tname);\n+\ttaking_projection = is_kfunc(meta) \u0026\u0026 btf_is_projection_of(arg_tname, reg_tname);\n \tif (!taking_projection \u0026\u0026 !struct_same) {\n \t\tverbose(env, \"%s %s expected pointer to %s %s but %s has a pointer to %s %s\\n\",\n \t\t\tmeta-\u003efunc_name, reg_arg_name(env, argno),\n@@ -14499,7 +14452,7 @@ s64 bpf_kfunc_stack_access_bytes(struct bpf_verifier_env *env, struct bpf_insn *\n \t * pointer, and neither does a slot past the last parameter.\n \t */\n \tfor (i = 0, slot = 0; i \u003c nargs \u0026\u0026 slot \u003c arg; i++)\n-\t\tslot += kfunc_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));\n+\t\tslot += btf_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));\n \tif (i \u003e= nargs || slot != arg)\n \t\treturn 0;\n \n@@ -18782,7 +18735,7 @@ bool bpf_get_call_summary(struct bpf_verifier_env *env, struct bpf_insn *call,\n \t\tif (err \u003c 0)\n \t\t\t/* error would be reported later */\n \t\t\treturn false;\n-\t\tcs-\u003earg_slot_cnt = kfunc_proto_slots(meta.btf, meta.func_proto);\n+\t\tcs-\u003earg_slot_cnt = btf_proto_slots(meta.btf, meta.func_proto);\n \t\tcs-\u003efastcall = meta.kfunc_flags \u0026 KF_FASTCALL;\n \t\tcs-\u003eis_void = btf_type_is_void(btf_type_by_id(meta.btf, meta.func_proto-\u003etype));\n \t\treturn true;\ndiff --git a/tools/testing/selftests/bpf/progs/aggregate_arg_func.c b/tools/testing/selftests/bpf/progs/aggregate_arg_func.c\nindex d0a4f84a6fbfa..2132b926a8f08 100644\n--- a/tools/testing/selftests/bpf/progs/aggregate_arg_func.c\n+++ b/tools/testing/selftests/bpf/progs/aggregate_arg_func.c\n@@ -43,7 +43,7 @@ __naked int aggregate_arg_pair_asm(void)\n }\n \n SEC(\"tc\")\n-__failure __msg(\"R2 is not a scalar\")\n+__failure __msg(\"R2 type=fp expected=scalar\")\n __naked int aggregate_arg_pair_ptr_fail(void)\n {\n \tasm volatile (\ndiff --git a/tools/testing/selftests/bpf/progs/dynptr_fail.c b/tools/testing/selftests/bpf/progs/dynptr_fail.c\nindex 9418dfe4d7b7f..148cf44173221 100644\n--- a/tools/testing/selftests/bpf/progs/dynptr_fail.c\n+++ b/tools/testing/selftests/bpf/progs/dynptr_fail.c\n@@ -2053,19 +2053,18 @@ __noinline long global_call_bpf_dynptr(const struct bpf_dynptr *dynptr)\n \t/* Avoid leaving this global function empty to avoid having the compiler\n \t * optimize away the call to this global function.\n \t */\n+\t__sink(dynptr);\n \t__sink(ret);\n \treturn ret;\n }\n \n SEC(\"?raw_tp\")\n-__failure __msg(\"R1 expected pointer to stack or const struct bpf_dynptr\")\n+__failure __msg(\"R1 type=trusted_ptr_ expected=fp, dynptr_ptr\")\n int test_dynptr_reg_type(void *ctx)\n {\n-\tstruct task_struct *current = NULL;\n-\t/* R1 should be holding a PTR_TO_BTF_ID, so this shouldn't be a\n-\t * reg-\u003etype that can be passed to a function accepting a\n-\t * ARG_PTR_TO_DYNPTR | MEM_RDONLY. process_dynptr_func() should catch\n-\t * this.\n+\tstruct task_struct *current = bpf_get_current_task_btf();\n+\t/* R1 holds a PTR_TO_BTF_ID, which cannot be passed to a function\n+\t * accepting ARG_PTR_TO_DYNPTR | MEM_RDONLY.\n \t */\n \tglobal_call_bpf_dynptr((const struct bpf_dynptr *)current);\n \treturn 0;\ndiff --git a/tools/testing/selftests/bpf/progs/test_global_func5.c b/tools/testing/selftests/bpf/progs/test_global_func5.c\nindex 257c0569ff98f..4573ecd96aa0b 100644\n--- a/tools/testing/selftests/bpf/progs/test_global_func5.c\n+++ b/tools/testing/selftests/bpf/progs/test_global_func5.c\n@@ -26,7 +26,7 @@ int f3(int val, struct __sk_buff *skb)\n }\n \n SEC(\"tc\")\n-__failure __msg(\"expects pointer to ctx\")\n+__failure __msg(\"R2 type=fp expected=ctx\")\n int global_func5(struct __sk_buff *skb)\n {\n \treturn f1(skb) + f2(2, skb) + f3(3, skb);\ndiff --git a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c\nindex 10019af5eb747..03507eeae3cb3 100644\n--- a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c\n+++ b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c\n@@ -87,7 +87,7 @@ __weak int subprog_trusted_task_nonnull(struct task_struct *task __arg_trusted)\n \n SEC(\"?kprobe\")\n __failure __log_level(2)\n-__msg(\"R1 type=scalar expected=ptr_, trusted_ptr_, rcu_ptr_\")\n+__msg(\"Possibly NULL pointer passed to trusted R1\")\n __msg(\"Caller passes invalid args into func#1 ('subprog_trusted_task_nonnull')\")\n int trusted_task_arg_nonnull_fail1(void *ctx)\n {\n@@ -96,7 +96,7 @@ int trusted_task_arg_nonnull_fail1(void *ctx)\n \n SEC(\"?tp_btf/task_newtask\")\n __failure __log_level(2)\n-__msg(\"R1 type=trusted_ptr_or_null_ expected=ptr_, trusted_ptr_, rcu_ptr_\")\n+__msg(\"Possibly NULL pointer passed to trusted R1\")\n __msg(\"Caller passes invalid args into func#1 ('subprog_trusted_task_nonnull')\")\n int trusted_task_arg_nonnull_fail2(void *ctx)\n {\n@@ -389,7 +389,8 @@ __weak int subprog_pkt_ptr_changes_data(struct __sk_buff *skb __arg_ctx,\n \n SEC(\"?tc\")\n __failure __log_level(2)\n-__msg(\"R2 is a packet pointer, but func#{{[0-9]+}} may change packet data\")\n+__msg(\"cannot pass packet pointer R2\")\n+__msg(\"function may change packet data\")\n __msg(\"Caller passes invalid args into func#{{[0-9]+}} ('subprog_pkt_ptr_changes_data')\")\n int pkt_ptr_to_global_mem_arg_changes_data(struct __sk_buff *skb)\n {\ndiff --git a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c\nindex 27fbe54e8795a..574b26b5a7dfb 100644\n--- a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c\n+++ b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c\n@@ -195,7 +195,7 @@ int arg_tag_nonnull_ptr_good(void *ctx)\n \n SEC(\"?raw_tp\")\n __failure __log_level(2)\n-__msg(\"R1 is expected to be non-NULL\")\n+__msg(\"Possibly NULL pointer passed to trusted R1\")\n int arg_tag_nonnull_ptr_null_bad(void *ctx)\n {\n \tint y = 74;\n"
} |
| 2/1 | 2026/09/29 21:20 | agent | patch-evaluator |
1mModel:core Args: null Results: {
"EnableConfigs": [
"BPF_SYSCALL",
"DEBUG_INFO_BTF"
],
"FocusSymbols": [
"btf_check_func_arg_match",
"gen_subprog_arg_proto",
"check_func_args",
"check_func_arg",
"btf_check_subprog_call",
"check_func_call"
],
"Reasoning": "The patch refactors the BPF verifier's argument validation logic for subprogram calls to reuse the unified helper/kfunc argument checking infrastructure (check_func_args and check_func_arg) via a synthetic bpf_func_proto generated in gen_subprog_arg_proto. This directly touches core verifier logic in kernel/bpf/verifier.c reachable via the bpf(BPF_PROG_LOAD) syscall when loading eBPF programs containing subprograms with BTF type information. Fuzzing is warranted to detect regressions, type confusion, or verifier invariant violations.",
"WorthFuzzing": true
}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 fe5e0d8bef154f9d665413ae1df92e68032ce883
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Sep 29 21:20:42 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 646e447cebd84..385a63edc0952 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -972,6 +972,7 @@ struct bpf_verifier_env {
const struct bpf_line_info *prev_linfo;
struct bpf_verifier_log log;
struct bpf_diag *diag;
+ struct bpf_func_proto bpf_subprog_scratch;
struct bpf_subprog_info subprog_info[BPF_MAX_SUBPROGS + 2]; /* max + 2 for the fake and exception subprogs */
/* subprog indices sorted in topological order: leaves first, callers last */
int subprog_topo_order[BPF_MAX_SUBPROGS + 2];
@@ -1638,6 +1639,7 @@ struct bpf_call_arg_meta {
struct btf *btf;
u32 func_id;
const struct bpf_func_proto *fn;
+ const struct btf_type *func_proto;
u8 release_regno;
u32 ret_btf_id;
u32 subprogno;
@@ -1647,10 +1649,12 @@ struct bpf_call_arg_meta {
struct ret_mem_desc ret_mem;
struct arg_raw_mem_desc arg_raw_mem;
+ /* Only set by subprog */
+ bool subprog_may_change_pkt;
+
/* Only set by kfunc */
bool r0_rdonly;
u32 kfunc_flags;
- const struct btf_type *func_proto;
const char *func_name;
struct arg_constant_desc arg_constant;
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 5c8626215ee6c..1a0a11a4894fd 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7702,6 +7702,11 @@ static int check_mem_size_reg(struct bpf_verifier_env *env,
return err;
}
+static bool is_subprog(const struct bpf_call_arg_meta *meta)
+{
+ return meta->btf && !meta->func_id;
+}
+
static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,
argno_t argno, u32 mem_size, enum bpf_access_type access_type,
struct bpf_call_arg_meta *meta, bool *known_memory)
@@ -7720,10 +7725,11 @@ static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg
}
/*
- * Only a global subprog (meta == NULL) may read poisoned stack slots:
+ * Only a global subprog may read poisoned stack slots:
* its static stack liveness proved the callee body skips them.
*/
- size = (!meta && base_type(reg->type) == PTR_TO_STACK) ? -(int)mem_size : mem_size;
+ size = (is_subprog(meta) &&
+ base_type(reg->type) == PTR_TO_STACK) ? -(int)mem_size : mem_size;
if (access_type & BPF_READ)
err = check_helper_mem_access(env, reg, argno, size, BPF_READ, true, meta,
@@ -8263,12 +8269,12 @@ static bool is_kfunc_arg_iter(struct bpf_call_arg_meta *meta, int arg_idx,
return btf_param_match_suffix(meta->btf, arg, "__iter");
}
-static int process_iter_arg(struct bpf_verifier_env *env, struct bpf_reg_state *reg, argno_t argno, int insn_idx,
+static int process_iter_arg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,
+ u32 arg, argno_t argno, int insn_idx,
struct bpf_call_arg_meta *meta)
{
struct bpf_func_state *state = bpf_func(env, reg);
const struct btf_type *t;
- u32 arg_idx = arg_idx_from_argno(argno);
int spi, err, i, nr_slots, btf_id;
if (reg->type != PTR_TO_STACK) {
@@ -8288,7 +8294,7 @@ static int process_iter_arg(struct bpf_verifier_env *env, struct bpf_reg_state *
* to any kfunc, if arg has "__iter" suffix, we need to be a bit more
* conservative here.
*/
- btf_id = btf_check_iter_arg(meta->btf, meta->func_proto, arg_idx);
+ btf_id = btf_check_iter_arg(meta->btf, meta->func_proto, arg);
if (btf_id < 0) {
verbose(env, "expected valid iter pointer as %s\n",
reg_arg_name(env, argno));
@@ -8638,18 +8644,27 @@ static bool arg_type_is_scalar(enum bpf_arg_type type)
}
/*
- * A kfunc is named by a BTF ID, which can take the same numeric value as an
- * enum bpf_func_id. Only test meta->func_id against a BPF_FUNC_* once the call
- * is known to be to a helper; meta->btf is set only for a kfunc.
+ * A helper has no BTF and a nonzero function ID. A kfunc has both, while a
+ * BPF subprogram has BTF and a zero function ID.
*/
+static bool is_helper(const struct bpf_call_arg_meta *meta)
+{
+ return !meta->btf && meta->func_id;
+}
+
static bool is_helper_call(const struct bpf_call_arg_meta *meta, enum bpf_func_id func_id)
{
- return !meta->btf && meta->func_id == func_id;
+ return is_helper(meta) && meta->func_id == func_id;
+}
+
+static bool is_kfunc(const struct bpf_call_arg_meta *meta)
+{
+ return meta->btf && meta->func_id;
}
static bool is_kfunc_call(const struct bpf_call_arg_meta *meta, u32 btf_id)
{
- return meta->btf && meta->func_id == btf_id;
+ return is_kfunc(meta) && meta->func_id == btf_id;
}
static int resolve_map_arg_type(struct bpf_verifier_env *env,
@@ -8919,7 +8934,7 @@ __printf(6, 7) static void bpf_diag_call_arg_fmt(struct bpf_verifier_env *env, u
}
static int check_func_arg_nullability(struct bpf_verifier_env *env,
- struct bpf_reg_state *reg, argno_t argno,
+ struct bpf_reg_state *reg, u32 arg, argno_t argno,
enum bpf_arg_type arg_type,
struct bpf_call_arg_meta *meta, int insn_idx)
{
@@ -8932,7 +8947,7 @@ static int check_func_arg_nullability(struct bpf_verifier_env *env,
if (meta->btf) {
u32 arg_btf_id;
- arg_btf_id = btf_params(meta->func_proto)[arg_idx_from_argno(argno)].type;
+ arg_btf_id = btf_params(meta->func_proto)[arg].type;
expected_type = bpf_diag_fmt(env, "value of type %s",
bpf_diag_fmt_btf_type(env, meta->btf, arg_btf_id));
}
@@ -8947,7 +8962,7 @@ static int check_func_arg_nullability(struct bpf_verifier_env *env,
}
static int check_func_arg_release(struct bpf_verifier_env *env, struct bpf_reg_state *reg,
- argno_t argno, enum bpf_arg_type arg_type,
+ u32 arg, argno_t argno, enum bpf_arg_type arg_type,
struct bpf_call_arg_meta *meta, int insn_idx)
{
const char *expected_type = "pointer";
@@ -8962,12 +8977,12 @@ static int check_func_arg_release(struct bpf_verifier_env *env, struct bpf_reg_s
verbose(env, "release function %s expects referenced PTR_TO_BTF_ID passed to %s\n",
meta->func_name, reg_arg_name(env, argno));
- if (meta->btf) {
+ if (is_kfunc(meta)) {
const struct btf_param *btf_arg;
const struct btf_type *t;
u32 ref_id;
- btf_arg = &btf_params(meta->func_proto)[arg_idx_from_argno(argno)];
+ btf_arg = &btf_params(meta->func_proto)[arg];
ref_id = btf_arg->type;
t = btf_type_skip_modifiers(meta->btf, btf_arg->type, NULL);
if (btf_type_is_ptr(t))
@@ -9016,7 +9031,7 @@ static int check_reg_type(struct bpf_verifier_env *env, struct bpf_reg_state *re
verifier_bug(env, "unsupported arg type %d", arg_type);
return -EFAULT;
}
- if (meta->btf && base_type(arg_type) == ARG_PTR_TO_BTF_ID &&
+ if (is_kfunc(meta) && base_type(arg_type) == ARG_PTR_TO_BTF_ID &&
(base_type(type) == PTR_TO_BTF_ID || reg2btf_ids[base_type(type)]))
goto found;
@@ -9038,8 +9053,8 @@ static int check_reg_type(struct bpf_verifier_env *env, struct bpf_reg_state *re
type &= ~PTR_MAYBE_NULL;
if (base_type(arg_type) == ARG_PTR_TO_MEM)
type &= ~DYNPTR_TYPE_FLAG_MASK;
- /* Allow allocated memory for kfunc ARG_PTR_TO_MEM but not helper. */
- if (meta->btf && base_type(arg_type) == ARG_PTR_TO_MEM &&
+ /* Allow allocated memory for BTF-defined ARG_PTR_TO_MEM but not helpers. */
+ if (!is_helper(meta) && base_type(arg_type) == ARG_PTR_TO_MEM &&
type_is_ptr_alloc_obj(type))
type = PTR_TO_MEM;
@@ -9362,7 +9377,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
struct bpf_call_arg_meta *meta,
int insn_idx)
{
- const struct btf_param *btf_arg = meta->btf ? &btf_params(meta->func_proto)[arg] : NULL;
+ const struct btf_param *btf_arg = is_kfunc(meta) ?
+ &btf_params(meta->func_proto)[arg] : NULL;
const struct bpf_func_proto *fn = meta->fn;
struct bpf_func_state *caller = cur_func(env);
struct bpf_reg_state *regs = cur_regs(env);
@@ -9412,7 +9428,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
return 0;
}
- err = check_func_arg_nullability(env, reg, argno, arg_type, meta, insn_idx);
+ err = check_func_arg_nullability(env, reg, arg, argno, arg_type, meta, insn_idx);
if (err)
return err;
@@ -9424,7 +9440,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
if (err)
return err;
- err = check_func_arg_release(env, reg, argno, arg_type, meta, insn_idx);
+ err = check_func_arg_release(env, reg, arg, argno, arg_type, meta, insn_idx);
if (err)
return err;
@@ -9502,7 +9518,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
case ARG_PTR_TO_BTF_ID_SOCK_COMMON:
{
const u32 *arg_btf_id = fn->arg_btf_id[arg];
- const struct btf *arg_btf = meta->btf ?: btf_vmlinux;
+ const struct btf *arg_btf = is_kfunc(meta) ? meta->btf : btf_vmlinux;
if (!meta->btf) {
const struct bpf_reg_types *compatible;
@@ -9530,8 +9546,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
}
}
- if (meta->btf && (!is_trusted_reg(env, reg) ||
- bpf_type_has_unsafe_modifiers(reg->type))) {
+ if (is_kfunc(meta) && (!is_trusted_reg(env, reg) ||
+ bpf_type_has_unsafe_modifiers(reg->type))) {
if (!(arg_type & MEM_RCU)) {
const char *actual_type, *arg_name, *expected_type;
@@ -9668,6 +9684,17 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
bpf_diag_reg_type_plain(env, reg->type));
return err;
}
+ /*
+ * PTR_TO_PACKET gets passed as PTR_TO_MEM, preventing us from adjusting
+ * bounds tracking information.
+ */
+ if (is_subprog(meta) && meta->subprog_may_change_pkt &&
+ (reg_is_pkt_pointer_any(reg) || reg_is_dynptr_slice_pkt(reg))) {
+ verbose(env,
+ "cannot pass packet pointer %s to %s(): function may change packet data\n",
+ reg_arg_name(env, argno), meta->func_name);
+ return -EINVAL;
+ }
if (arg_type & MEM_ALIGNED)
err = check_ptr_alignment(env, reg, 0, arg_size, true);
break;
@@ -9758,7 +9785,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
verbose(env, "css_task_iter is only allowed in bpf_lsm, bpf_iter and sleepable progs\n");
return -EINVAL;
}
- err = process_iter_arg(env, reg, argno, insn_idx, meta);
+ err = process_iter_arg(env, reg, arg, argno, insn_idx, meta);
if (err < 0)
return err;
break;
@@ -9930,20 +9957,20 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
* func model recorded, or the verifier would check an argument at a slot
* the JIT does not place it at.
*/
-static u32 kfunc_arg_slots(const struct btf_type *t)
+static u32 btf_arg_slots(const struct btf_type *t)
{
if (btf_type_is_int(t) || btf_type_is_struct(t))
return (t->size + BPF_REG_SIZE - 1) / BPF_REG_SIZE;
return 1;
}
-static u32 kfunc_proto_slots(const struct btf *btf, const struct btf_type *func_proto)
+static u32 btf_proto_slots(const struct btf *btf, const struct btf_type *func_proto)
{
const struct btf_param *args = btf_params(func_proto);
u32 i, nargs = btf_type_vlen(func_proto), slots_used = 0;
for (i = 0; i < nargs; i++)
- slots_used += kfunc_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));
+ slots_used += btf_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));
return slots_used;
}
@@ -9986,7 +10013,7 @@ static int check_func_args(struct bpf_verifier_env *env, struct bpf_call_arg_met
* count. Only a proto whose parameters take a slot each can name the
* argument a stack slot belongs to.
*/
- proto_slots = meta->btf ? kfunc_proto_slots(meta->btf, meta->func_proto) : nargs;
+ proto_slots = meta->btf ? btf_proto_slots(meta->btf, meta->func_proto) : nargs;
if (proto_slots > MAX_BPF_FUNC_REG_ARGS) {
err = check_outgoing_stack_args(env, caller, proto_slots, meta->func_name,
@@ -10002,7 +10029,7 @@ static int check_func_args(struct bpf_verifier_env *env, struct bpf_call_arg_met
nslots = 1;
if (args) {
t = btf_type_skip_modifiers(meta->btf, args[arg].type, NULL);
- nslots = kfunc_arg_slots(t);
+ nslots = btf_arg_slots(t);
}
if (meta->fn->arg_type[arg] == ARG_UNUSED)
@@ -10787,21 +10814,50 @@ static int setup_func_entry(struct bpf_verifier_env *env, int subprog, int calls
return err;
}
-static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
- const struct btf *btf,
- struct bpf_reg_state *regs)
+static void gen_subprog_arg_proto(const struct bpf_subprog_info *sub, const struct btf *btf,
+ const struct btf_type *func_proto, struct bpf_func_proto *proto)
+{
+ const struct btf_param *args = btf_params(func_proto);
+ u32 arg, slot = 0;
+
+ memset(proto, 0, sizeof(*proto));
+ for (arg = 0; arg < btf_type_vlen(func_proto); arg++) {
+ enum bpf_arg_type arg_type = sub->args[slot].arg_type;
+ const struct btf_type *t;
+
+ if (arg_type & PTR_UNTRUSTED) {
+ /*
+ * An __arg_untrusted argument accepts any caller value. The
+ * callee treats it as read-only and uses probe-read instructions
+ * to protect against invalid memory access.
+ */
+ arg_type = ARG_IGNORE;
+ } else if (base_type(arg_type) == ARG_PTR_TO_ARENA) {
+ arg_type |= PTR_MAYBE_NULL;
+ } else if (base_type(arg_type) == ARG_PTR_TO_MEM) {
+ proto->arg_size[arg] = sub->args[slot].mem_size;
+ arg_type |= MEM_FIXED_SIZE | MEM_WRITE;
+ } else if (base_type(arg_type) == ARG_PTR_TO_BTF_ID) {
+ proto->arg_btf_id[arg] = &sub->args[slot].btf_id;
+ }
+ proto->arg_type[arg] = arg_type;
+ t = btf_type_skip_modifiers(btf, args[arg].type, NULL);
+ slot += btf_arg_slots(t);
+ }
+}
+
+static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog, struct btf *btf)
{
struct bpf_subprog_info *sub = subprog_info(env, subprog);
struct bpf_func_state *caller = cur_func(env);
- struct bpf_verifier_log *log = &env->log;
- const struct btf_param *args;
const struct btf_type *func, *func_proto;
struct bpf_call_arg_meta meta;
- u32 i;
+ struct bpf_func_proto *fn;
int ret, err;
- /* Leave btf and func_id zero: this is neither a helper nor a kfunc. */
memset(&meta, 0, sizeof(meta));
+ meta.btf = btf;
+ meta.subprog_may_change_pkt = sub->changes_pkt_data;
meta.func_name = bpf_subprog_name(env, subprog);
ret = btf_prepare_func_args(env, subprog);
@@ -10818,127 +10874,24 @@ static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
func = btf_type_by_id(btf, env->prog->aux->func_info[subprog].type_id);
func_proto = btf_type_by_id(btf, func->type);
- args = btf_params(func_proto);
- if (sub->arg_slot_cnt != btf_type_vlen(func_proto))
- args = NULL;
- ret = check_outgoing_stack_args(env, caller, sub->arg_slot_cnt,
- bpf_subprog_name(env, subprog), btf, args);
- if (ret)
- return ret;
-
- /* check that BTF function arguments match actual types that the
- * verifier sees.
- */
- for (i = 0; i < sub->arg_slot_cnt; i++) {
- argno_t argno = argno_from_arg(i + 1);
- struct bpf_reg_state *reg = get_func_arg_reg(caller, regs, i);
- struct bpf_subprog_arg_info *arg = &sub->args[i];
-
- if (arg->arg_type == ARG_SCALAR) {
- if (reg->type != SCALAR_VALUE) {
- bpf_log(log, "%s is not a scalar\n", reg_arg_name(env, argno));
- return -EINVAL;
- }
- } else if (arg->arg_type & PTR_UNTRUSTED) {
- /*
- * Anything is allowed for untrusted arguments, as these are
- * read-only and probe read instructions would protect against
- * invalid memory access.
- */
- } else if (arg->arg_type == ARG_PTR_TO_CTX) {
- ret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_CTX);
- if (ret < 0)
- return ret;
- /* If function expects ctx type in BTF check that caller
- * is passing PTR_TO_CTX.
- */
- if (reg->type != PTR_TO_CTX) {
- bpf_log(log, "%s expects pointer to ctx\n",
- reg_arg_name(env, argno));
- return -EINVAL;
- }
- } else if (base_type(arg->arg_type) == ARG_PTR_TO_MEM) {
- ret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_MEM);
- if (ret < 0)
- return ret;
- if (check_mem_reg(env, reg, argno, arg->mem_size, BPF_READ | BPF_WRITE, NULL,
- NULL))
- return -EINVAL;
- /*
- * PTR_TO_PACKET get passed as PTR_TO_MEM, preventing
- * us from adjusting bounds tracking info.
- */
- if ((reg_is_pkt_pointer_any(reg) || reg_is_dynptr_slice_pkt(reg)) &&
- sub->changes_pkt_data) {
- bpf_log(log, "%s is a packet pointer, but func#%d may change packet data\n",
- reg_arg_name(env, argno), subprog);
- return -EINVAL;
- }
- if (!(arg->arg_type & PTR_MAYBE_NULL) &&
- (type_may_be_null(reg->type) || bpf_register_is_null(reg))) {
- bpf_log(log, "%s is expected to be non-NULL\n",
- reg_arg_name(env, argno));
- return -EINVAL;
- }
- } else if (base_type(arg->arg_type) == ARG_PTR_TO_ARENA) {
- /*
- * Can pass any value and the kernel won't crash, but
- * only PTR_TO_ARENA or SCALAR make sense. Everything
- * else is a bug in the bpf program. Point it out to
- * the user at the verification time instead of
- * run-time debug nightmare.
- */
- if (reg->type != PTR_TO_ARENA && reg->type != SCALAR_VALUE) {
- bpf_log(log, "%s is not a pointer to arena or scalar.\n",
- reg_arg_name(env, argno));
- return -EINVAL;
- }
- } else if (arg->arg_type == ARG_PTR_TO_DYNPTR) {
- ret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_DYNPTR);
- if (ret)
- return ret;
-
- ret = process_dynptr_func(env, reg, argno, env->insn_idx,
- arg->arg_type, &meta);
- if (ret)
- return ret;
- } else if (base_type(arg->arg_type) == ARG_PTR_TO_BTF_ID) {
- int err;
-
- if (bpf_register_is_null(reg) && type_may_be_null(arg->arg_type)) {
- err = mark_arg_precision(env, argno);
- if (err)
- return err;
- continue;
- }
- err = check_reg_type(env, reg, argno, arg->arg_type, &meta);
- err = err ?: check_func_arg_reg_off(env, reg, argno, arg->arg_type);
- if (!err && base_type(reg->type) == PTR_TO_BTF_ID)
- err = process_arg_ptr_to_btf_id(env, reg, argno, arg->arg_type,
- btf_vmlinux, arg->btf_id,
- &meta, env->insn_idx);
- if (err)
- return err;
- } else {
- verifier_bug(env, "unrecognized %s type %d",
- reg_arg_name(env, argno), arg->arg_type);
- return -EFAULT;
- }
- }
+ fn = &env->bpf_subprog_scratch;
+ gen_subprog_arg_proto(sub, btf, func_proto, fn);
+ meta.fn = fn;
+ meta.func_proto = func_proto;
- return 0;
+ return check_func_args(env, &meta, env->insn_idx);
}
-/* Compare BTF of a function call with given bpf_reg_state.
+/*
+ * Check that call-site argument states match a subprog's BTF signature.
+ *
* Returns:
* EFAULT - there is a verifier bug. Abort verification.
- * EINVAL - there is a type mismatch or BTF is not available.
+ * Other errors - there is a type mismatch or BTF is not available.
* 0 - BTF matches with what bpf_reg_state expects.
- * Only PTR_TO_CTX and SCALAR_VALUE states are recognized.
*/
-static int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog,
- struct bpf_reg_state *regs)
+static int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog)
{
struct bpf_prog *prog = env->prog;
struct btf *btf = prog->aux->btf;
@@ -10955,7 +10908,7 @@ static int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog,
if (prog->aux->func_info_aux[subprog].unreliable)
return -EINVAL;
- err = btf_check_func_arg_match(env, subprog, btf, regs);
+ err = btf_check_func_arg_match(env, subprog, btf);
/* Compiler optimizations can remove arguments from static functions
* or mismatched type can be passed into a global function.
* In such cases mark the function as unreliable from BTF point of view.
@@ -10974,7 +10927,7 @@ static int push_callback_call(struct bpf_verifier_env *env, struct bpf_insn *ins
int err;
caller = state->frame[state->curframe];
- err = btf_check_subprog_call(env, subprog, caller->regs);
+ err = btf_check_subprog_call(env, subprog);
if (err == -EFAULT)
return err;
@@ -11111,7 +11064,7 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
return -EFAULT;
caller = state->frame[state->curframe];
- err = btf_check_subprog_call(env, subprog, caller->regs);
+ err = btf_check_subprog_call(env, subprog);
if (err == -EFAULT)
return err;
if (bpf_subprog_is_global(env, subprog)) {
@@ -11247,7 +11200,7 @@ static int check_func_callx(struct bpf_verifier_env *env, struct bpf_insn *insn,
/* PTR_TO_FUNC is a pointer to a static subprog */
subprog = reg->subprogno;
- err = btf_check_subprog_call(env, subprog, caller->regs);
+ err = btf_check_subprog_call(env, subprog);
if (err == -EFAULT)
return err;
@@ -13058,7 +13011,7 @@ static int resolve_func_arg_type(struct bpf_verifier_env *env,
if (base_type(*arg_type) != ARG_PTR_TO_BTF_ID)
return 0;
- if (!meta->btf || arg_type_is_release(*arg_type) ||
+ if (!is_kfunc(meta) || arg_type_is_release(*arg_type) ||
base_type(reg->type) == PTR_TO_BTF_ID ||
reg2btf_ids[base_type(reg->type)])
return 0;
@@ -13781,7 +13734,7 @@ static int process_arg_ptr_to_btf_id(struct bpf_verifier_env *env, struct bpf_re
* resolve types.
*/
if ((arg_type_is_release(arg_type) && !is_helper_call(meta, BPF_FUNC_sk_release)) ||
- (meta->btf && btf_type_ids_nocast_alias(&env->log, reg_btf, reg_btf_id,
+ (is_kfunc(meta) && btf_type_ids_nocast_alias(&env->log, reg_btf, reg_btf_id,
arg_btf, arg_btf_id)))
strict_type_match = true;
@@ -13798,7 +13751,7 @@ static int process_arg_ptr_to_btf_id(struct bpf_verifier_env *env, struct bpf_re
* actually use it -- it must cast to the underlying type. So we allow
* caller to pass in the underlying type.
*/
- taking_projection = meta->btf && btf_is_projection_of(arg_tname, reg_tname);
+ taking_projection = is_kfunc(meta) && btf_is_projection_of(arg_tname, reg_tname);
if (!taking_projection && !struct_same) {
verbose(env, "%s %s expected pointer to %s %s but %s has a pointer to %s %s\n",
meta->func_name, reg_arg_name(env, argno),
@@ -14499,7 +14452,7 @@ s64 bpf_kfunc_stack_access_bytes(struct bpf_verifier_env *env, struct bpf_insn *
* pointer, and neither does a slot past the last parameter.
*/
for (i = 0, slot = 0; i < nargs && slot < arg; i++)
- slot += kfunc_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));
+ slot += btf_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));
if (i >= nargs || slot != arg)
return 0;
@@ -18782,7 +18735,7 @@ bool bpf_get_call_summary(struct bpf_verifier_env *env, struct bpf_insn *call,
if (err < 0)
/* error would be reported later */
return false;
- cs->arg_slot_cnt = kfunc_proto_slots(meta.btf, meta.func_proto);
+ cs->arg_slot_cnt = btf_proto_slots(meta.btf, meta.func_proto);
cs->fastcall = meta.kfunc_flags & KF_FASTCALL;
cs->is_void = btf_type_is_void(btf_type_by_id(meta.btf, meta.func_proto->type));
return true;
diff --git a/tools/testing/selftests/bpf/progs/aggregate_arg_func.c b/tools/testing/selftests/bpf/progs/aggregate_arg_func.c
index d0a4f84a6fbfa..2132b926a8f08 100644
--- a/tools/testing/selftests/bpf/progs/aggregate_arg_func.c
+++ b/tools/testing/selftests/bpf/progs/aggregate_arg_func.c
@@ -43,7 +43,7 @@ __naked int aggregate_arg_pair_asm(void)
}
SEC("tc")
-__failure __msg("R2 is not a scalar")
+__failure __msg("R2 type=fp expected=scalar")
__naked int aggregate_arg_pair_ptr_fail(void)
{
asm volatile (
diff --git a/tools/testing/selftests/bpf/progs/dynptr_fail.c b/tools/testing/selftests/bpf/progs/dynptr_fail.c
index 9418dfe4d7b7f..148cf44173221 100644
--- a/tools/testing/selftests/bpf/progs/dynptr_fail.c
+++ b/tools/testing/selftests/bpf/progs/dynptr_fail.c
@@ -2053,19 +2053,18 @@ __noinline long global_call_bpf_dynptr(const struct bpf_dynptr *dynptr)
/* Avoid leaving this global function empty to avoid having the compiler
* optimize away the call to this global function.
*/
+ __sink(dynptr);
__sink(ret);
return ret;
}
SEC("?raw_tp")
-__failure __msg("R1 expected pointer to stack or const struct bpf_dynptr")
+__failure __msg("R1 type=trusted_ptr_ expected=fp, dynptr_ptr")
int test_dynptr_reg_type(void *ctx)
{
- struct task_struct *current = NULL;
- /* R1 should be holding a PTR_TO_BTF_ID, so this shouldn't be a
- * reg->type that can be passed to a function accepting a
- * ARG_PTR_TO_DYNPTR | MEM_RDONLY. process_dynptr_func() should catch
- * this.
+ struct task_struct *current = bpf_get_current_task_btf();
+ /* R1 holds a PTR_TO_BTF_ID, which cannot be passed to a function
+ * accepting ARG_PTR_TO_DYNPTR | MEM_RDONLY.
*/
global_call_bpf_dynptr((const struct bpf_dynptr *)current);
return 0;
diff --git a/tools/testing/selftests/bpf/progs/test_global_func5.c b/tools/testing/selftests/bpf/progs/test_global_func5.c
index 257c0569ff98f..4573ecd96aa0b 100644
--- a/tools/testing/selftests/bpf/progs/test_global_func5.c
+++ b/tools/testing/selftests/bpf/progs/test_global_func5.c
@@ -26,7 +26,7 @@ int f3(int val, struct __sk_buff *skb)
}
SEC("tc")
-__failure __msg("expects pointer to ctx")
+__failure __msg("R2 type=fp expected=ctx")
int global_func5(struct __sk_buff *skb)
{
return f1(skb) + f2(2, skb) + f3(3, skb);
diff --git a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
index 10019af5eb747..03507eeae3cb3 100644
--- a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
+++ b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
@@ -87,7 +87,7 @@ __weak int subprog_trusted_task_nonnull(struct task_struct *task __arg_trusted)
SEC("?kprobe")
__failure __log_level(2)
-__msg("R1 type=scalar expected=ptr_, trusted_ptr_, rcu_ptr_")
+__msg("Possibly NULL pointer passed to trusted R1")
__msg("Caller passes invalid args into func#1 ('subprog_trusted_task_nonnull')")
int trusted_task_arg_nonnull_fail1(void *ctx)
{
@@ -96,7 +96,7 @@ int trusted_task_arg_nonnull_fail1(void *ctx)
SEC("?tp_btf/task_newtask")
__failure __log_level(2)
-__msg("R1 type=trusted_ptr_or_null_ expected=ptr_, trusted_ptr_, rcu_ptr_")
+__msg("Possibly NULL pointer passed to trusted R1")
__msg("Caller passes invalid args into func#1 ('subprog_trusted_task_nonnull')")
int trusted_task_arg_nonnull_fail2(void *ctx)
{
@@ -389,7 +389,8 @@ __weak int subprog_pkt_ptr_changes_data(struct __sk_buff *skb __arg_ctx,
SEC("?tc")
__failure __log_level(2)
-__msg("R2 is a packet pointer, but func#{{[0-9]+}} may change packet data")
+__msg("cannot pass packet pointer R2")
+__msg("function may change packet data")
__msg("Caller passes invalid args into func#{{[0-9]+}} ('subprog_pkt_ptr_changes_data')")
int pkt_ptr_to_global_mem_arg_changes_data(struct __sk_buff *skb)
{
diff --git a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
index 27fbe54e8795a..574b26b5a7dfb 100644
--- a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
+++ b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
@@ -195,7 +195,7 @@ int arg_tag_nonnull_ptr_good(void *ctx)
SEC("?raw_tp")
__failure __log_level(2)
-__msg("R1 is expected to be non-NULL")
+__msg("Possibly NULL pointer passed to trusted R1")
int arg_tag_nonnull_ptr_null_bad(void *ctx)
{
int y = 74;
|
| 3/2 | 2026/09/29 21:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 14039 output: 30 thoughts: 656 Thoughts: **BPF Verifier Argument Verification Refactor** Okay, so this patch is all about tightening up how the BPF verifier handles argument checking for BPF subprogram calls, and unifying it with helper and kfunc argument validation. They're leveraging the `check_func_args` mechanism, which sounds like a sensible move for consistency. I see they've modified `kernel/bpf/verifier.c` and `include/linux/bpf_verifier.h`. Specifically, the header now includes a `bpf_subprog_scratch` field in the `bpf_verifier_env` and adds `func_proto` and `subprog_may_change_pkt` to `struct bpf_call_arg_meta`. That suggests they're adding specific state for subprogram verification which is interesting, likely related to the scratch space needed for subprogram calls. The meta structure additions look significant as well. The `kernel/bpf/verifier.c` changes are more extensive. It appears they're defining several functions to check the type of call made, with `is_subprog`, `is_helper`, and `is_kfunc`. And then they're updating the stack slot check to specifically look for stack pointers in subprograms. They're clearly reorganizing some of the argument checks, including changes to nullability, release, register types, and packet pointer validation. The renaming of `kfunc_arg_slots` to `btf_arg_slots` and `kfunc_proto_slots` to `btf_proto_slots` is a nice cleanup, and indicates a shift to BTF (BPF Type Format) as the primary mechanism for function prototypes. The core of the change seems to be around `btf_check_func_arg_match`. They're generating a `bpf_func_proto` (with `gen_subprog_arg_proto`) and calling `check_func_args`. This is likely where the unification happens. They've also cleaned up caller argument handling in several functions (`btf_check_subprog_call`, `check_func_call`, etc.), so that all look like nice improvements. And of course, the selftests are updated, which is essential. Now, from a security perspective, this is *definitely* worth a closer look, especially for fuzzing. The BPF verifier is directly reachable through the `bpf(BPF_PROG_LOAD, ...)` syscall, making it a prime target for fuzzing. Given the nature of the changes (memory management touchpoints, refactoring of reachable code), and the fact that it is a core subsystem with its history of vulnerabilities, fuzzing is a requirement. It modifies reachable executable code and refactors the data structure, all major trigger for the "WorthFuzzing = True" condition. I need to quickly check the Kconfig dependencies to understand what configurations enable the verifier and BTF, either with `grepper` or by looking in kernel/bpf/Makefile. Then I should examine it more closely and start planning some fuzzing targets, as this seems like a solid candidate for finding new vulnerabilities. |
| 4/2 | 2026/09/29 21:20 | tool | grepper |
0mArgs:{
"Expression": "CONFIG_BPF",
"PathPrefix": "kernel/bpf/Makefile"
}Results: {
"Output": "kernel/bpf/Makefile=2=obj-y := core.o\nkernel/bpf/Makefile:3:ifneq ($(CONFIG_BPF_JIT_ALWAYS_ON),y)\nkernel/bpf/Makefile-4-# ___bpf_prog_run() needs GCSE disabled on x86; see 3193c0836f203 for details\n--\nkernel/bpf/Makefile=7=CFLAGS_core.o += -Wno-override-init $(cflags-nogcse-yy)\nkernel/bpf/Makefile-8-\nkernel/bpf/Makefile:9:obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o inode.o helpers.o tnum.o cnum.o log.o token.o liveness.o const_fold.o diagnostics.o\nkernel/bpf/Makefile:10:obj-$(CONFIG_BPF_SYSCALL) += bpf_iter.o map_iter.o task_iter.o prog_iter.o link_iter.o\nkernel/bpf/Makefile:11:obj-$(CONFIG_BPF_SYSCALL) += hashtab.o arraymap.o percpu_freelist.o bpf_lru_list.o lpm_trie.o map_in_map.o bloom_filter.o\nkernel/bpf/Makefile:12:obj-$(CONFIG_BPF_SYSCALL) += local_storage.o queue_stack_maps.o ringbuf.o bpf_insn_array.o\nkernel/bpf/Makefile:13:obj-$(CONFIG_BPF_SYSCALL) += bpf_local_storage.o bpf_task_storage.o\nkernel/bpf/Makefile:14:obj-$(CONFIG_BPF_SYSCALL) += fixups.o cfg.o states.o backtrack.o check_btf.o\nkernel/bpf/Makefile:15:obj-${CONFIG_BPF_LSM}\t += bpf_inode_storage.o\nkernel/bpf/Makefile:16:obj-$(CONFIG_BPF_SYSCALL) += disasm.o mprog.o\nkernel/bpf/Makefile:17:obj-$(CONFIG_BPF_JIT) += trampoline.o\nkernel/bpf/Makefile:18:obj-$(CONFIG_BPF_SYSCALL) += btf.o memalloc.o rqspinlock.o stream.o\nkernel/bpf/Makefile-19-ifeq ($(CONFIG_MMU)$(CONFIG_64BIT),yy)\nkernel/bpf/Makefile:20:obj-$(CONFIG_BPF_SYSCALL) += arena.o range_tree.o\nkernel/bpf/Makefile-21-endif\nkernel/bpf/Makefile:22:obj-$(CONFIG_BPF_JIT) += dispatcher.o\nkernel/bpf/Makefile-23-ifeq ($(CONFIG_NET),y)\nkernel/bpf/Makefile:24:obj-$(CONFIG_BPF_SYSCALL) += devmap.o\nkernel/bpf/Makefile:25:obj-$(CONFIG_BPF_SYSCALL) += cpumap.o\nkernel/bpf/Makefile:26:obj-$(CONFIG_BPF_SYSCALL) += offload.o\nkernel/bpf/Makefile:27:obj-$(CONFIG_BPF_SYSCALL) += net_namespace.o\nkernel/bpf/Makefile:28:obj-$(CONFIG_BPF_SYSCALL) += tcx.o\nkernel/bpf/Makefile-29-endif\nkernel/bpf/Makefile=30=ifeq ($(CONFIG_KEYS),y)\nkernel/bpf/Makefile:31:obj-$(CONFIG_BPF_SYSCALL) += keys.o\nkernel/bpf/Makefile-32-endif\nkernel/bpf/Makefile=33=ifeq ($(CONFIG_PERF_EVENTS),y)\nkernel/bpf/Makefile:34:obj-$(CONFIG_BPF_SYSCALL) += stackmap.o\nkernel/bpf/Makefile-35-endif\nkernel/bpf/Makefile=36=ifeq ($(CONFIG_CGROUPS),y)\nkernel/bpf/Makefile:37:obj-$(CONFIG_BPF_SYSCALL) += cgroup_iter.o bpf_cgrp_storage.o\nkernel/bpf/Makefile-38-endif\n--\nkernel/bpf/Makefile=40=ifeq ($(CONFIG_INET),y)\nkernel/bpf/Makefile:41:obj-$(CONFIG_BPF_SYSCALL) += reuseport_array.o\nkernel/bpf/Makefile-42-endif\n--\nkernel/bpf/Makefile=45=endif\nkernel/bpf/Makefile:46:ifeq ($(CONFIG_BPF_JIT),y)\nkernel/bpf/Makefile:47:obj-$(CONFIG_BPF_SYSCALL) += bpf_struct_ops.o\nkernel/bpf/Makefile:48:obj-$(CONFIG_BPF_SYSCALL) += cpumask.o\nkernel/bpf/Makefile-49-# bpf_lsm_proto.o must precede bpf_lsm.o. The current pahole logic\n--\nkernel/bpf/Makefile-58-# semantics within pahole are revisited accordingly.\nkernel/bpf/Makefile:59:obj-${CONFIG_BPF_LSM} += bpf_lsm_proto.o bpf_lsm.o\nkernel/bpf/Makefile-60-endif\nkernel/bpf/Makefile:61:obj-$(CONFIG_BPF_CRYPTO) += crypto.o\nkernel/bpf/Makefile:62:obj-$(CONFIG_BPF_PRELOAD) += preload/\nkernel/bpf/Makefile-63-\nkernel/bpf/Makefile:64:obj-$(CONFIG_BPF_SYSCALL) += relo_core.o\nkernel/bpf/Makefile:65:obj-$(CONFIG_BPF_SYSCALL) += btf_iter.o\nkernel/bpf/Makefile:66:obj-$(CONFIG_BPF_SYSCALL) += btf_relocate.o\nkernel/bpf/Makefile:67:obj-$(CONFIG_BPF_SYSCALL) += kmem_cache_iter.o\nkernel/bpf/Makefile-68-ifeq ($(CONFIG_DMA_SHARED_BUFFER),y)\nkernel/bpf/Makefile:69:obj-$(CONFIG_BPF_SYSCALL) += dmabuf_iter.o\nkernel/bpf/Makefile-70-endif\n"
} |
| 5/2 | 2026/09/29 21:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 16965 output: 31 thoughts: 58 Thoughts: Here's my summary, as though I'm thinking through this process: **Investigating the Build Dependencies of verifier.o** Okay, so `verifier.o` is built, and it seems the build condition is tied to `CONFIG_BPF_SYSCALL`. That's the baseline. But I'm also seeing a connection to BTF here. Hmm, the pieces are falling into place but I need to be more precise about the dependency chain. I suspect that there might be a dependency on some BTF-related configuration option as well. My initial guess would be `CONFIG_DEBUG_INFO_BTF`, or perhaps something similar that enables BTF generation or usage. The verifier uses BTF to help understand the program. To be sure, I need to check the authoritative source: `kernel/bpf/Kconfig`. That's where all the relevant Kconfig options for BPF, and likely BTF, will be defined. I'll pore over that file to confirm which specific configurations are implicated and understand the exact relationships. This will clarify the *why* behind this compilation. |
| 6/2 | 2026/09/29 21:21 | tool | grepper |
0mError:no matches Args: {
"Expression": "config BPF_SYSCALL",
"PathPrefix": "init/Kconfig"
}Results: {
"error": "no matches"
} |
| 7/2 | 2026/09/29 21:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17303 output: 34 thoughts: 14 Thoughts: Okay, here's my attempt at summarizing that thought process, tailored for an expert audience: **Hunting Down BPF_SYSCALL** Alright, so I need to understand how `BPF_SYSCALL` is working in this context. My immediate instinct is to figure out exactly where it's defined. I'm going to start by tracing the definition. The key here is to determine what include files are necessary and where that macro lands. My aim is to quickly understand the mechanics of it to determine how the compiler is interpreting it, its purpose, and what I can expect as its output. I'm thinking I'll start with the standard BPF headers, maybe poke around in the kernel source if it's not immediately obvious. Knowing the precise definition is the foundational step. |
| 8/2 | 2026/09/29 21:21 | tool | grepper |
0mArgs:{
"Expression": "config BPF_SYSCALL",
"PathPrefix": "kernel/bpf/Kconfig"
}Results: {
"Output": "kernel/bpf/Kconfig=29=menu \"BPF subsystem\"\nkernel/bpf/Kconfig-30-\nkernel/bpf/Kconfig:31:config BPF_SYSCALL\nkernel/bpf/Kconfig-32-\tbool \"Enable bpf() system call\"\n"
} |
| 9/2 | 2026/09/29 21:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17600 output: 34 thoughts: 19 Thoughts: Okay, let's dive into this. I'm going to take a look at the `kernel/bpf/Kconfig` file. Specifically, I need to focus around line 31. This should give me a good starting point for whatever it is I'm trying to figure out or understand in relation to BPF configuration. Line 31, in the context of a Kconfig, likely contains a crucial configuration option or a dependency that I need to analyze. My expert intuition tells me that this is probably a core setting, perhaps the introduction of a new feature or a critical dependency for a feature that's recently become available, or a crucial check. Let's see what we've got. |
| 10/2 | 2026/09/29 21:21 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/Kconfig",
"FirstLine": 29,
"LineCount": 40
}Results: {
"Contents": " 29:\tmenu \"BPF subsystem\"\n 30:\t\n 31:\tconfig BPF_SYSCALL\n 32:\t\tbool \"Enable bpf() system call\"\n 33:\t\tselect BPF\n 34:\t\tselect IRQ_WORK\n 35:\t\tselect NEED_TASKS_RCU\n 36:\t\tselect TASKS_TRACE_RCU\n 37:\t\tselect BINARY_PRINTF\n 38:\t\tselect NET_SOCK_MSG if NET\n 39:\t\tselect NET_XGRESS if NET\n 40:\t\tselect PAGE_POOL if NET\n 41:\t\tdefault n\n 42:\t\thelp\n 43:\t\t Enable the bpf() system call that allows to manipulate BPF programs\n 44:\t\t and maps via file descriptors.\n 45:\t\n 46:\tconfig BPF_JIT\n 47:\t\tbool \"Enable BPF Just In Time compiler\"\n 48:\t\tdepends on BPF\n 49:\t\tdepends on HAVE_CBPF_JIT || HAVE_EBPF_JIT\n 50:\t\tselect EXECMEM\n 51:\t\thelp\n 52:\t\t BPF programs are normally handled by a BPF interpreter. This option\n 53:\t\t allows the kernel to generate native code when a program is loaded\n 54:\t\t into the kernel. This will significantly speed-up processing of BPF\n 55:\t\t programs.\n 56:\t\n 57:\t\t Note, an admin should enable this feature changing:\n 58:\t\t /proc/sys/net/core/bpf_jit_enable\n 59:\t\t /proc/sys/net/core/bpf_jit_harden (optional)\n 60:\t\t /proc/sys/net/core/bpf_jit_kallsyms (optional)\n 61:\t\n 62:\tconfig BPF_JIT_ALWAYS_ON\n 63:\t\tbool \"Permanently enable BPF JIT and remove BPF interpreter\"\n 64:\t\tdepends on BPF_SYSCALL \u0026\u0026 HAVE_EBPF_JIT \u0026\u0026 BPF_JIT\n 65:\t\thelp\n 66:\t\t Enables BPF JIT and removes BPF interpreter to avoid speculative\n 67:\t\t execution of BPF instructions by the interpreter.\n 68:\t\n"
} |
| 11/2 | 2026/09/29 21:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18385 output: 31 thoughts: 162 Thoughts: **My Investigation into BTF Configuration for Subprograms and KFuncs** Okay, I need to clarify something crucial here regarding BTF within subprograms and kfuncs. The immediate question is: do we need `DEBUG_INFO_BTF` or any similar BTF configurations to manage BTF information within these contexts? Hold on, wait a second...subprogram BTF data isn't sourced directly from the kernel! It's actually passed up from user space through `BPF_BTF_LOAD` and `BPF_PROG_LOAD`. That's a key distinction I need to remember. Now, `btf_vmlinux` *could* still be relevant in some specific scenarios, I should check, I'm thinking of examples like its use in something like `check_func_arg`. But, in the case of user-defined subprograms, their BTF comes from the program's own BTF data, specifically `prog->aux->btf`. So, I really need to ascertain if `DEBUG_INFO_BTF` is actually linked to `btf_vmlinux`. My next step is to examine `btf_vmlinux` directly within the `kernel/bpf/` directory. |
| 12/2 | 2026/09/29 21:21 | tool | grepper |
0mArgs:{
"Expression": "btf_vmlinux",
"PathPrefix": "kernel/bpf/"
}Results: {
"Output": "kernel/bpf/bpf_struct_ops.c=83=enum {\n--\nkernel/bpf/bpf_struct_ops.c-87-\nkernel/bpf/bpf_struct_ops.c:88:extern struct btf *btf_vmlinux;\nkernel/bpf/bpf_struct_ops.c-89-\nkernel/bpf/bpf_struct_ops.c=90=static bool is_valid_value_type(struct btf *btf, s32 value_id,\n--\nkernel/bpf/bpf_struct_ops.c-105-\tmt = btf_type_by_id(btf, member-\u003etype);\nkernel/bpf/bpf_struct_ops.c:106:\tcommon_value_type = btf_type_by_id(btf_vmlinux,\nkernel/bpf/bpf_struct_ops.c-107-\t\t\t\t\t st_ops_ids[IDX_ST_OPS_COMMON_VALUE_ID]);\n--\nkernel/bpf/bpf_struct_ops.c=727=static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,\n--\nkernel/bpf/bpf_struct_ops.c-785-\ttname = btf_name_by_offset(st_map-\u003ebtf, t-\u003ename_off);\nkernel/bpf/bpf_struct_ops.c:786:\tmodule_type = btf_type_by_id(btf_vmlinux, st_ops_ids[IDX_MODULE_ID]);\nkernel/bpf/bpf_struct_ops.c-787-\tfor_each_member(i, t, member) {\n--\nkernel/bpf/bpf_struct_ops.c=991=static void bpf_struct_ops_map_seq_show_elem(struct bpf_map *map, void *key,\n--\nkernel/bpf/bpf_struct_ops.c-1004-\t\tbtf_type_seq_show(st_map-\u003ebtf,\nkernel/bpf/bpf_struct_ops.c:1005:\t\t\t\t map-\u003ebtf_vmlinux_value_type_id,\nkernel/bpf/bpf_struct_ops.c-1006-\t\t\t\t value, m);\n--\nkernel/bpf/bpf_struct_ops.c=1056=static int bpf_struct_ops_map_alloc_check(union bpf_attr *attr)\n--\nkernel/bpf/bpf_struct_ops.c-1059-\t (attr-\u003emap_flags \u0026 ~(BPF_F_LINK | BPF_F_VTYPE_BTF_OBJ_FD)) ||\nkernel/bpf/bpf_struct_ops.c:1060:\t !attr-\u003ebtf_vmlinux_value_type_id)\nkernel/bpf/bpf_struct_ops.c-1061-\t\treturn -EINVAL;\n--\nkernel/bpf/bpf_struct_ops.c=1078=static struct bpf_map *bpf_struct_ops_map_alloc(union bpf_attr *attr)\n--\nkernel/bpf/bpf_struct_ops.c-1106-\t} else {\nkernel/bpf/bpf_struct_ops.c:1107:\t\tbtf = bpf_get_btf_vmlinux();\nkernel/bpf/bpf_struct_ops.c-1108-\t\tif (IS_ERR(btf))\n--\nkernel/bpf/bpf_struct_ops.c-1113-\nkernel/bpf/bpf_struct_ops.c:1114:\tst_ops_desc = bpf_struct_ops_find_value(btf, attr-\u003ebtf_vmlinux_value_type_id);\nkernel/bpf/bpf_struct_ops.c-1115-\tif (!st_ops_desc) {\n--\nkernel/bpf/bpf_struct_ops.c=1612=void bpf_map_struct_ops_info_fill(struct bpf_map_info *info, struct bpf_map *map)\n--\nkernel/bpf/bpf_struct_ops.c-1615-\nkernel/bpf/bpf_struct_ops.c:1616:\tinfo-\u003ebtf_vmlinux_id = btf_obj_id(st_map-\u003ebtf);\nkernel/bpf/bpf_struct_ops.c-1617-}\n--\nkernel/bpf/btf.c=699=s32 bpf_find_btf_id(const char *name, u32 kind, struct btf **btf_p)\n--\nkernel/bpf/btf.c-704-\nkernel/bpf/btf.c:705:\tbtf = bpf_get_btf_vmlinux();\nkernel/bpf/btf.c-706-\tif (IS_ERR(btf))\n--\nkernel/bpf/btf.c=6448=extern char __stop_BTF[];\nkernel/bpf/btf.c:6449:extern struct btf *btf_vmlinux;\nkernel/bpf/btf.c-6450-\n--\nkernel/bpf/btf.c=6481=static const struct btf_type *find_canonical_prog_ctx_type(enum bpf_prog_type prog_type)\n--\nkernel/bpf/btf.c-6493-\t */\nkernel/bpf/btf.c:6494:\treturn btf_type_by_id(btf_vmlinux, ctx_type-\u003etype);\nkernel/bpf/btf.c-6495-}\n--\nkernel/bpf/btf.c=6522=bool btf_is_prog_ctx_type(struct bpf_verifier_log *log, const struct btf *btf,\n--\nkernel/bpf/btf.c-6562-\tif (!ctx_type) {\nkernel/bpf/btf.c:6563:\t\tbpf_log(log, \"btf_vmlinux is malformed\\n\");\nkernel/bpf/btf.c-6564-\t\t/* should not happen */\n--\nkernel/bpf/btf.c-6567-again:\nkernel/bpf/btf.c:6568:\tctx_tname = btf_name_by_offset(btf_vmlinux, ctx_type-\u003ename_off);\nkernel/bpf/btf.c-6569-\tif (!ctx_tname) {\n--\nkernel/bpf/btf.c-6592-\t\twhile (btf_type_is_modifier(ctx_type))\nkernel/bpf/btf.c:6593:\t\t\tctx_type = btf_type_by_id(btf_vmlinux, ctx_type-\u003etype);\nkernel/bpf/btf.c-6594-\t\tgoto again;\n--\nkernel/bpf/btf.c=6608=static int btf_validate_prog_ctx_type(struct bpf_verifier_log *log, const struct btf *btf,\n--\nkernel/bpf/btf.c-6716-\t\t/* should not happen */\nkernel/bpf/btf.c:6717:\t\tbpf_log(log, \"btf_vmlinux is malformed\\n\");\nkernel/bpf/btf.c-6718-\t\treturn -EINVAL;\n--\nkernel/bpf/btf.c-6722-\twhile (btf_type_is_modifier(ctx_type))\nkernel/bpf/btf.c:6723:\t\tctx_type = btf_type_by_id(btf_vmlinux, ctx_type-\u003etype);\nkernel/bpf/btf.c-6724-\n--\nkernel/bpf/btf.c-6733-\nkernel/bpf/btf.c:6734:\tctx_tname = btf_name_by_offset(btf_vmlinux, ctx_type-\u003ename_off);\nkernel/bpf/btf.c-6735-\tif (!__btf_type_is_struct(t) || strcmp(ctx_tname, tname) != 0) {\n--\nkernel/bpf/btf.c=6754=int get_kern_ctx_btf_id(struct bpf_verifier_log *log, enum bpf_prog_type prog_type)\n--\nkernel/bpf/btf.c-6764-\tkctx_type_id = kctx_member-\u003etype;\nkernel/bpf/btf.c:6765:\tkctx_type = btf_type_by_id(btf_vmlinux, kctx_type_id);\nkernel/bpf/btf.c-6766-\tif (!btf_type_is_struct(kctx_type)) {\n--\nkernel/bpf/btf.c=6829=struct btf *btf_parse_vmlinux(void)\n--\nkernel/bpf/btf.c-6845-\nkernel/bpf/btf.c:6846:\t/* btf_parse_vmlinux() runs under btf_vmlinux_lock */\nkernel/bpf/btf.c-6847-\tbpf_ctx_convert.t = btf_type_by_id(btf, bpf_ctx_convert_btf_id[0]);\n--\nkernel/bpf/btf.c=6871=static struct btf *btf_parse_module(const char *module_name, const void *data,\n--\nkernel/bpf/btf.c-6879-\nkernel/bpf/btf.c:6880:\tvmlinux_btf = bpf_get_btf_vmlinux();\nkernel/bpf/btf.c-6881-\tif (IS_ERR(vmlinux_btf))\n--\nkernel/bpf/btf.c=7240=bool btf_ctx_access(int off, int size, enum bpf_access_type type,\n--\nkernel/bpf/btf.c-7398-\t\t\tinfo-\u003ereg_type = ctx_arg_info-\u003ereg_type;\nkernel/bpf/btf.c:7399:\t\t\tinfo-\u003ebtf = ctx_arg_info-\u003ebtf ? : btf_vmlinux;\nkernel/bpf/btf.c-7400-\t\t\tinfo-\u003ebtf_id = ctx_arg_info-\u003ebtf_id;\n--\nkernel/bpf/btf.c-7455-\t\tif (ret \u003e 0) {\nkernel/bpf/btf.c:7456:\t\t\tinfo-\u003ebtf = btf_vmlinux;\nkernel/bpf/btf.c-7457-\t\t\tinfo-\u003ebtf_id = ret;\n--\nkernel/bpf/btf.c=8418=int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog)\n--\nkernel/bpf/btf.c-8581-\nkernel/bpf/btf.c:8582:\t\t\tvmlinux_btf = bpf_get_btf_vmlinux();\nkernel/bpf/btf.c-8583-\t\t\tref_t = btf_type_by_id(vmlinux_btf, kern_type_id);\n--\nkernel/bpf/btf.c=9122=struct btf *btf_get_module_btf(const struct module *module)\n--\nkernel/bpf/btf.c-9129-\tif (!module) {\nkernel/bpf/btf.c:9130:\t\tbtf = bpf_get_btf_vmlinux();\nkernel/bpf/btf.c-9131-\t\tif (!IS_ERR_OR_NULL(btf))\n--\nkernel/bpf/btf.c=9300=static int btf_check_kfunc_name(struct btf *btf, const char *func_name, u32 kind)\n--\nkernel/bpf/btf.c-9309-\nkernel/bpf/btf.c:9310:\tid = btf_find_by_name_kind(bpf_get_btf_vmlinux(), func_name, kind);\nkernel/bpf/btf.c-9311-\tif (id \u003e= 0) {\n--\nkernel/bpf/btf.c=10084=bpf_core_find_cands(struct bpf_core_ctx *ctx, u32 local_type_id)\n--\nkernel/bpf/btf.c-10094-\nkernel/bpf/btf.c:10095:\tmain_btf = bpf_get_btf_vmlinux();\nkernel/bpf/btf.c-10096-\tif (IS_ERR(main_btf))\n--\nkernel/bpf/inode.c=661=static int find_bpffs_btf_enums(struct bpffs_btf_enums *info)\n--\nkernel/bpf/inode.c-676-\nkernel/bpf/inode.c:677:\tbtf = bpf_get_btf_vmlinux();\nkernel/bpf/inode.c-678-\tif (IS_ERR(btf))\n--\nkernel/bpf/syscall.c=1394=static int map_create_alloc(union bpf_attr *attr, bpfptr_t uattr, struct bpf_verifier_log *log,\n--\nkernel/bpf/syscall.c-1416-\nkernel/bpf/syscall.c:1417:\tif (attr-\u003ebtf_vmlinux_value_type_id) {\nkernel/bpf/syscall.c-1418-\t\tif (attr-\u003emap_type != BPF_MAP_TYPE_STRUCT_OPS) {\nkernel/bpf/syscall.c:1419:\t\t\tbpf_log(log, \"btf_vmlinux_value_type_id can only be used with struct_ops maps.\\n\");\nkernel/bpf/syscall.c-1420-\t\t\treturn -EINVAL;\n--\nkernel/bpf/syscall.c-1422-\t\tif (attr-\u003ebtf_key_type_id || attr-\u003ebtf_value_type_id) {\nkernel/bpf/syscall.c:1423:\t\t\tbpf_log(log, \"btf_vmlinux_value_type_id is mutually exclusive with btf_key_type_id and btf_value_type_id.\\n\");\nkernel/bpf/syscall.c-1424-\t\t\treturn -EINVAL;\n--\nkernel/bpf/syscall.c-1576-\t */\nkernel/bpf/syscall.c:1577:\t attr-\u003ebtf_vmlinux_value_type_id) {\nkernel/bpf/syscall.c-1578-\t\tstruct btf *btf;\n--\nkernel/bpf/syscall.c-1601-\t\tmap-\u003ebtf_value_type_id = attr-\u003ebtf_value_type_id;\nkernel/bpf/syscall.c:1602:\t\tmap-\u003ebtf_vmlinux_value_type_id =\nkernel/bpf/syscall.c:1603:\t\t\tattr-\u003ebtf_vmlinux_value_type_id;\nkernel/bpf/syscall.c-1604-\t}\n--\nkernel/bpf/syscall.c=2929=static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, struct bpf_log_attr *attr_log)\n--\nkernel/bpf/syscall.c-3029-\t\t/* fall back to vmlinux BTF, if BTF type ID is specified */\nkernel/bpf/syscall.c:3030:\t\tattach_btf = bpf_get_btf_vmlinux();\nkernel/bpf/syscall.c-3031-\t\tif (IS_ERR(attach_btf)) {\n--\nkernel/bpf/syscall.c=5402=static int bpf_map_get_info_by_fd(struct file *file,\n--\nkernel/bpf/syscall.c-5435-\t}\nkernel/bpf/syscall.c:5436:\tinfo.btf_vmlinux_value_type_id = map-\u003ebtf_vmlinux_value_type_id;\nkernel/bpf/syscall.c-5437-\tif (map-\u003emap_type == BPF_MAP_TYPE_STRUCT_OPS)\n--\nkernel/bpf/sysfs_btf.c=18=static int btf_sysfs_vmlinux_mmap(struct file *filp, struct kobject *kobj,\n--\nkernel/bpf/sysfs_btf.c-45-\nkernel/bpf/sysfs_btf.c:46:static struct bin_attribute bin_attr_btf_vmlinux __ro_after_init = {\nkernel/bpf/sysfs_btf.c-47-\t.attr = { .name = \"vmlinux\", .mode = 0444, },\n--\nkernel/bpf/sysfs_btf.c=52=struct kobject *btf_kobj;\nkernel/bpf/sysfs_btf.c-53-\nkernel/bpf/sysfs_btf.c:54:static int __init btf_vmlinux_init(void)\nkernel/bpf/sysfs_btf.c-55-{\nkernel/bpf/sysfs_btf.c:56:\tbin_attr_btf_vmlinux.private = __start_BTF;\nkernel/bpf/sysfs_btf.c:57:\tbin_attr_btf_vmlinux.size = __stop_BTF - __start_BTF;\nkernel/bpf/sysfs_btf.c-58-\nkernel/bpf/sysfs_btf.c:59:\tif (bin_attr_btf_vmlinux.size == 0)\nkernel/bpf/sysfs_btf.c-60-\t\treturn 0;\n--\nkernel/bpf/sysfs_btf.c-65-\nkernel/bpf/sysfs_btf.c:66:\treturn sysfs_create_bin_file(btf_kobj, \u0026bin_attr_btf_vmlinux);\nkernel/bpf/sysfs_btf.c-67-}\nkernel/bpf/sysfs_btf.c-68-\nkernel/bpf/sysfs_btf.c:69:subsys_initcall(btf_vmlinux_init);\n--\nkernel/bpf/trampoline.c=20=const struct bpf_prog_ops bpf_extension_prog_ops = {\n--\nkernel/bpf/trampoline.c-22-\nkernel/bpf/trampoline.c:23:/* btf_vmlinux has ~22k attachable functions. 1k htab is enough. */\nkernel/bpf/trampoline.c-24-#define TRAMPOLINE_HASH_BITS 10\n--\nkernel/bpf/verifier.c=260=struct bpf_kfunc_meta {\n--\nkernel/bpf/verifier.c-267-\nkernel/bpf/verifier.c:268:struct btf *btf_vmlinux;\nkernel/bpf/verifier.c-269-\n--\nkernel/bpf/verifier.c=316=static DEFINE_MUTEX(bpf_verifier_lock);\nkernel/bpf/verifier.c:317:static DEFINE_MUTEX(btf_vmlinux_lock);\nkernel/bpf/verifier.c-318-static DEFINE_MUTEX(bpf_percpu_ma_lock);\n--\nkernel/bpf/verifier.c=2737=static struct btf *find_kfunc_desc_btf(struct bpf_verifier_env *env, s16 offset)\n--\nkernel/bpf/verifier.c-2749-\t}\nkernel/bpf/verifier.c:2750:\treturn btf_vmlinux ?: ERR_PTR(-ENOENT);\nkernel/bpf/verifier.c-2751-}\n--\nkernel/bpf/verifier.c=2753=static struct btf *find_kfunc_desc_btf_cached(struct bpf_verifier_env *env, s16 offset)\n--\nkernel/bpf/verifier.c-2759-\tif (!offset)\nkernel/bpf/verifier.c:2760:\t\treturn btf_vmlinux ?: ERR_PTR(-ENOENT);\nkernel/bpf/verifier.c-2761-\tif (offset \u003c 0)\n--\nkernel/bpf/verifier.c=2868=int bpf_add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, u16 offset)\n--\nkernel/bpf/verifier.c-2883-\tif (!tab) {\nkernel/bpf/verifier.c:2884:\t\tif (!btf_vmlinux) {\nkernel/bpf/verifier.c-2885-\t\t\tverbose(env, \"calling kernel function is not supported without CONFIG_DEBUG_INFO_BTF\\n\");\n--\nkernel/bpf/verifier.c=6500=static int check_ptr_to_map_access(struct bpf_verifier_env *env,\n--\nkernel/bpf/verifier.c-6513-\nkernel/bpf/verifier.c:6514:\tif (!btf_vmlinux) {\nkernel/bpf/verifier.c-6515-\t\tverbose(env, \"map_ptr access not supported without CONFIG_DEBUG_INFO_BTF\\n\");\n--\nkernel/bpf/verifier.c-6524-\nkernel/bpf/verifier.c:6525:\tt = btf_type_by_id(btf_vmlinux, *map-\u003eops-\u003emap_btf_id);\nkernel/bpf/verifier.c:6526:\ttname = btf_name_by_offset(btf_vmlinux, t-\u003ename_off);\nkernel/bpf/verifier.c-6527-\n--\nkernel/bpf/verifier.c-6548-\tret = mark_btf_ld_reg(env, \u0026map_reg, 0, PTR_TO_BTF_ID,\nkernel/bpf/verifier.c:6549:\t\t\t btf_vmlinux, *map-\u003eops-\u003emap_btf_id, 0);\nkernel/bpf/verifier.c-6550-\tif (ret \u003c 0)\n--\nkernel/bpf/verifier.c-6556-\tif (value_regno \u003e= 0) {\nkernel/bpf/verifier.c:6557:\t\tret = mark_btf_ld_reg(env, regs, value_regno, ret, btf_vmlinux, btf_id, flag);\nkernel/bpf/verifier.c-6558-\t\tif (ret \u003c 0)\n--\nkernel/bpf/verifier.c=9376=static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 prev_slot,\n--\nkernel/bpf/verifier.c-9520-\t\tconst u32 *arg_btf_id = fn-\u003earg_btf_id[arg];\nkernel/bpf/verifier.c:9521:\t\tconst struct btf *arg_btf = is_kfunc(meta) ? meta-\u003ebtf : btf_vmlinux;\nkernel/bpf/verifier.c-9522-\n--\nkernel/bpf/verifier.c-9649-\t\t}\nkernel/bpf/verifier.c:9650:\t\tif (meta-\u003ebtf == btf_vmlinux) {\nkernel/bpf/verifier.c-9651-\t\t\tmeta-\u003earg_btf = reg-\u003ebtf;\n--\nkernel/bpf/verifier.c=11341=static int set_find_vma_callback_state(struct bpf_verifier_env *env,\n--\nkernel/bpf/verifier.c-11354-\t__mark_reg_known_zero(\u0026callee-\u003eregs[BPF_REG_2]);\nkernel/bpf/verifier.c:11355:\tcallee-\u003eregs[BPF_REG_2].btf = btf_vmlinux;\nkernel/bpf/verifier.c-11356-\tcallee-\u003eregs[BPF_REG_2].btf_id = btf_tracing_ids[BTF_TRACING_TYPE_VMA];\n--\nkernel/bpf/verifier.c=12055=static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn,\n--\nkernel/bpf/verifier.c-12443-\t\t\t}\nkernel/bpf/verifier.c:12444:\t\t\tret_btf = btf_vmlinux;\nkernel/bpf/verifier.c-12445-\t\t\tret_btf_id = *fn-\u003eret_btf_id;\n--\nkernel/bpf/verifier.c=12780=static bool __is_kfunc_ptr_arg_type(const struct btf *btf,\n--\nkernel/bpf/verifier.c-12793-\t\treturn false;\nkernel/bpf/verifier.c:12794:\treturn btf_types_are_same(btf, res_id, btf_vmlinux, kf_arg_btf_ids[type]);\nkernel/bpf/verifier.c-12795-}\n--\nkernel/bpf/verifier.c=12847=static bool is_rbtree_node_type(const struct btf_type *t)\nkernel/bpf/verifier.c-12848-{\nkernel/bpf/verifier.c:12849:\treturn t == btf_type_by_id(btf_vmlinux, kf_arg_btf_ids[KF_ARG_RB_NODE_ID]);\nkernel/bpf/verifier.c-12850-}\n--\nkernel/bpf/verifier.c=12852=static bool is_list_node_type(const struct btf_type *t)\nkernel/bpf/verifier.c-12853-{\nkernel/bpf/verifier.c:12854:\treturn t == btf_type_by_id(btf_vmlinux, kf_arg_btf_ids[KF_ARG_LIST_NODE_ID]);\nkernel/bpf/verifier.c-12855-}\n--\nkernel/bpf/verifier.c=12997=static int resolve_func_arg_type(struct bpf_verifier_env *env,\n--\nkernel/bpf/verifier.c-13020-\tref_id = *meta-\u003efn-\u003earg_btf_id[arg];\nkernel/bpf/verifier.c:13021:\tbtf = is_kfunc_arg_map(meta-\u003ebtf, \u0026args[arg]) ? btf_vmlinux : meta-\u003ebtf;\nkernel/bpf/verifier.c-13022-\tref_t = btf_type_skip_modifiers(btf, ref_id, \u0026ref_id);\n--\nkernel/bpf/verifier.c=13693=static int process_arg_ptr_to_btf_id(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\n--\nkernel/bpf/verifier.c-13707-\t} else {\nkernel/bpf/verifier.c:13708:\t\treg_btf = btf_vmlinux;\nkernel/bpf/verifier.c-13709-\t\treg_btf_id = *reg2btf_ids[base_type(reg-\u003etype)];\n--\nkernel/bpf/verifier.c=14091=__process_kf_arg_ptr_to_graph_root(struct bpf_verifier_env *env,\n--\nkernel/bpf/verifier.c-14101-\nkernel/bpf/verifier.c:14102:\tif (meta-\u003ebtf != btf_vmlinux) {\nkernel/bpf/verifier.c-14103-\t\tverifier_bug(env, \"unexpected btf mismatch in kfunc call\");\n--\nkernel/bpf/verifier.c=14158=__process_kf_arg_ptr_to_graph_node(struct bpf_verifier_env *env,\n--\nkernel/bpf/verifier.c-14169-\nkernel/bpf/verifier.c:14170:\tif (meta-\u003ebtf != btf_vmlinux) {\nkernel/bpf/verifier.c-14171-\t\tverifier_bug(env, \"unexpected btf mismatch in kfunc call\");\n--\nkernel/bpf/verifier.c=14507=static int check_special_kfunc(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,\n--\nkernel/bpf/verifier.c-14513-\nkernel/bpf/verifier.c:14514:\tif (meta-\u003ebtf != btf_vmlinux)\nkernel/bpf/verifier.c-14515-\t\treturn 0;\n--\nkernel/bpf/verifier.c=14678=static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,\n--\nkernel/bpf/verifier.c-14956-\tif (is_kfunc_acquire(\u0026meta) \u0026\u0026 !btf_type_is_struct_ptr(meta.btf, t)) {\nkernel/bpf/verifier.c:14957:\t\tif (meta.btf != btf_vmlinux ||\nkernel/bpf/verifier.c-14958-\t\t (!is_bpf_obj_new_kfunc(meta.func_id) \u0026\u0026\n--\nkernel/bpf/verifier.c-14967-\t\tret_nregs = mark_kfunc_ret_regs(env, regs, t-\u003esize);\nkernel/bpf/verifier.c:14968:\t\tif (meta.btf == btf_vmlinux \u0026\u0026 (meta.func_id == special_kfunc_list[KF_bpf_res_spin_lock] ||\nkernel/bpf/verifier.c-14969-\t\t meta.func_id == special_kfunc_list[KF_bpf_res_spin_lock_irqsave]))\n--\nkernel/bpf/verifier.c-15125-\t} else if (btf_type_is_void(t)) {\nkernel/bpf/verifier.c:15126:\t\tif (meta.btf == btf_vmlinux) {\nkernel/bpf/verifier.c-15127-\t\t\tif (is_bpf_obj_drop_kfunc(meta.func_id) ||\n--\nkernel/bpf/verifier.c=19758=static int check_pseudo_btf_id(struct bpf_verifier_env *env,\n--\nkernel/bpf/verifier.c-19773-\t} else {\nkernel/bpf/verifier.c:19774:\t\tif (!btf_vmlinux) {\nkernel/bpf/verifier.c-19775-\t\t\tverbose(env, \"kernel is missing BTF, make sure CONFIG_DEBUG_INFO_BTF=y is specified in Kconfig.\\n\");\n--\nkernel/bpf/verifier.c-19777-\t\t}\nkernel/bpf/verifier.c:19778:\t\tbtf_get(btf_vmlinux);\nkernel/bpf/verifier.c:19779:\t\tbtf = btf_vmlinux;\nkernel/bpf/verifier.c-19780-\t}\n--\nkernel/bpf/verifier.c=20199=static int check_insn_fields(struct bpf_verifier_env *env, struct bpf_insn *insn)\n--\nkernel/bpf/verifier.c-20256- *\nkernel/bpf/verifier.c:20257: * NOTE: btf_vmlinux is required for converting pseudo btf_id.\nkernel/bpf/verifier.c-20258- */\n--\nkernel/bpf/verifier.c=20607=static int do_check_common(struct bpf_verifier_env *env, int subprog, bool is_sleepable)\n--\nkernel/bpf/verifier.c-20703-\t\t\t\tmark_reg_known_zero(env, regs, i);\nkernel/bpf/verifier.c:20704:\t\t\t\treg-\u003ebtf = bpf_get_btf_vmlinux(); /* can't fail at this point */\nkernel/bpf/verifier.c-20705-\t\t\t\treg-\u003ebtf_id = arg-\u003ebtf_id;\n--\nkernel/bpf/verifier.c=21753=int bpf_check_attach_btf_id_multi(struct btf *btf, struct bpf_prog *prog, u32 btf_id,\n--\nkernel/bpf/verifier.c-21809-\nkernel/bpf/verifier.c:21810:struct btf *bpf_get_btf_vmlinux(void)\nkernel/bpf/verifier.c-21811-{\nkernel/bpf/verifier.c-21812-\t/* Pairs with the smp_store_release() on the parse path below. */\nkernel/bpf/verifier.c:21813:\tstruct btf *btf = smp_load_acquire(\u0026btf_vmlinux);\nkernel/bpf/verifier.c-21814-\nkernel/bpf/verifier.c-21815-\tif (!btf \u0026\u0026 IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) {\nkernel/bpf/verifier.c:21816:\t\tmutex_lock(\u0026btf_vmlinux_lock);\nkernel/bpf/verifier.c:21817:\t\tbtf = btf_vmlinux;\nkernel/bpf/verifier.c-21818-\t\tif (!btf) {\n--\nkernel/bpf/verifier.c-21825-\t\t\t */\nkernel/bpf/verifier.c:21826:\t\t\tsmp_store_release(\u0026btf_vmlinux, btf);\nkernel/bpf/verifier.c-21827-\t\t}\nkernel/bpf/verifier.c:21828:\t\tmutex_unlock(\u0026btf_vmlinux_lock);\nkernel/bpf/verifier.c-21829-\t}\n--\nkernel/bpf/verifier.c=22362=int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr,\n--\nkernel/bpf/verifier.c-22431-\nkernel/bpf/verifier.c:22432:\tbpf_get_btf_vmlinux();\nkernel/bpf/verifier.c-22433-\n--\nkernel/bpf/verifier.c-22452-\nkernel/bpf/verifier.c:22453:\tif (IS_ERR(btf_vmlinux)) {\nkernel/bpf/verifier.c-22454-\t\t/* Either gcc or pahole or kernel are broken. */\nkernel/bpf/verifier.c-22455-\t\tverbose(env, \"in-kernel BTF is malformed\\n\");\nkernel/bpf/verifier.c:22456:\t\tret = PTR_ERR(btf_vmlinux);\nkernel/bpf/verifier.c-22457-\t\tgoto skip_full_check;\n"
} |
| 13/2 | 2026/09/29 21:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27966 output: 36 thoughts: 592 Thoughts: **Analyzing BPF Verifier Changes** Okay, so I'm looking at this patch and immediately, `CONFIG_BPF_SYSCALL` and `CONFIG_DEBUG_INFO_BTF` jump out at me as the key configuration options. My instinct tells me that `CONFIG_BPF_SYSCALL` is the critical one, but `CONFIG_DEBUG_INFO_BTF` is also very important. Subprogram verification, BTF arguments, and kfuncs all heavily rely on BTF, so I need to understand its relationship to the core functionality. Now, I need to get into the details, specifically what functions are being added or modified. Scanning the changes in `kernel/bpf/verifier.c`, I've identified quite a few: 1. `is_subprog` 2. `check_mem_reg` 3. `process_iter_arg` 4. `is_helper` 5. `is_kfunc` 6. `is_helper_call` 7. `is_kfunc_call` 8. `check_func_arg_nullability` 9. `check_func_arg_release` 10. `check_reg_type` 11. `check_func_arg` 12. `btf_arg_slots` (renamed from kfunc_arg_slots) 13. `btf_proto_slots` (renamed from kfunc_proto_slots) 14. `check_func_args` 15. `gen_subprog_arg_proto` (new function!) 16. `btf_check_func_arg_match` (heavily modified) 17. `btf_check_subprog_call` (modified) 18. `push_callback_call` 19. `check_func_call` 20. `check_func_callx` 21. `resolve_func_arg_type` 22. `process_arg_ptr_to_btf_id` 23. `bpf_kfunc_stack_access_bytes` 24. `bpf_get_call_summary` My next thought: what's static and what's not? In the BPF verifier, many functions are static within `kernel/bpf/verifier.c`, and I believe `bpf_check` is the main entry point called from `bpf_prog_load`. I need to figure out which of the *modified* functions are non-static because that has important implications. Okay, let me check. `bpf_kfunc_stack_access_bytes` stands out as a potential candidate, so I need to confirm its visibility. I need to grep its definition and usage to be absolutely sure. |
| 14/2 | 2026/09/29 21:21 | tool | grepper |
0mArgs:{
"Expression": "bpf_kfunc_stack_access_bytes",
"PathPrefix": "kernel/bpf/"
}Results: {
"Output": "kernel/bpf/liveness.c=1580=static int record_arg_access(struct bpf_verifier_env *env,\n--\nkernel/bpf/liveness.c-1596-\t} else if (bpf_pseudo_kfunc_call(insn)) {\nkernel/bpf/liveness.c:1597:\t\tbytes = bpf_kfunc_stack_access_bytes(env, insn, arg_idx, insn_idx);\nkernel/bpf/liveness.c-1598-\t} else {\n--\nkernel/bpf/verifier.c=14304=s64 bpf_helper_stack_access_bytes(struct bpf_verifier_env *env, struct bpf_insn *insn,\n--\nkernel/bpf/verifier.c-14429- */\nkernel/bpf/verifier.c:14430:s64 bpf_kfunc_stack_access_bytes(struct bpf_verifier_env *env, struct bpf_insn *insn,\nkernel/bpf/verifier.c-14431-\t\t\t\t int arg, int insn_idx)\n"
} |
| 15/2 | 2026/09/29 21:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29517 output: 33 thoughts: 14 Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind the user is an expert: **Investigating `bpf_get_call_summary`** Alright, let's dive in. I need to take a look at `bpf_get_call_summary`. I'm immediately thinking, "Okay, what's the context here?" Am I looking at this for performance profiling? Debugging? Security auditing? That'll influence how I approach it. The name suggests this might be related to analyzing function call graphs or potentially call stacks, maybe even aggregating call counts or durations. My initial questions are: what's the expected input format? What kind of output does it generate? Is this a kernel helper function, a user-space utility, or something else entirely? Does it handle recursion gracefully? Does it deal with different calling conventions or ABIs? Does it support dynamic linking? Does it offer any filtering capabilities? I'll need to know the source of the data it's consuming - is it grabbing this from perf events, tracepoints, or some other BPF program? Ultimately, my goal is to understand its purpose and capabilities. I need to figure out if it can provide the information I'm specifically looking for, and if so, how. Is it a good building block for my current project, or is it likely to be a dead end? Time to dig in and see. |
| 16/2 | 2026/09/29 21:21 | tool | grepper |
0mArgs:{
"Expression": "bpf_get_call_summary",
"PathPrefix": "kernel/bpf/"
}Results: {
"Output": "kernel/bpf/liveness.c=1617=static int record_call_access(struct bpf_verifier_env *env,\n--\nkernel/bpf/liveness.c-1636-\t\targ_slot_cnt = MAX_BPF_FUNC_REG_ARGS + MAX_STACK_ARG_SLOTS;\nkernel/bpf/liveness.c:1637:\telse if (bpf_get_call_summary(env, insn, \u0026cs))\nkernel/bpf/liveness.c-1638-\t\targ_slot_cnt = cs.arg_slot_cnt;\n--\nkernel/bpf/liveness.c=2283=static void compute_insn_live_regs(struct bpf_verifier_env *env,\n--\nkernel/bpf/liveness.c-2422-\t\t\tuse = def \u0026 ~BIT(BPF_REG_0);\nkernel/bpf/liveness.c:2423:\t\t\tif (bpf_get_call_summary(env, insn, \u0026cs))\nkernel/bpf/liveness.c-2424-\t\t\t\tuse = GENMASK(min_t(u8, cs.arg_slot_cnt, MAX_BPF_FUNC_REG_ARGS), 1);\n--\nkernel/bpf/verifier.c=18688=bool bpf_verifier_inlines_helper_call(struct bpf_verifier_env *env, s32 imm)\n--\nkernel/bpf/verifier.c-18706- */\nkernel/bpf/verifier.c:18707:bool bpf_get_call_summary(struct bpf_verifier_env *env, struct bpf_insn *call,\nkernel/bpf/verifier.c-18708-\t\t\t struct bpf_call_summary *cs)\n--\nkernel/bpf/verifier.c=18825=static void mark_fastcall_pattern_for_call(struct bpf_verifier_env *env,\n--\nkernel/bpf/verifier.c-18836-\nkernel/bpf/verifier.c:18837:\tif (!bpf_get_call_summary(env, call, \u0026cs))\nkernel/bpf/verifier.c-18838-\t\treturn;\n"
} |
| 17/2 | 2026/09/29 21:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30431 output: 23 thoughts: 1705 Thoughts: **Analyzing BPF Subprogram Argument Verification for Syzkaller Targeting**
Okay, so I need to figure out how to best target this patch with syzkaller. The core question is: Can I effectively use syzkaller's symbol coverage with functions like the ones in this patch? From my understanding, syzkaller's kcov and symbol coverage work by targeting compiler symbols, and static functions in `.c` files *should* have these symbols, unless the compiler inlines them. The instructions I have say that static *inline* functions in headers are the problem because they lack distinct addresses. That's not the case here, as we're talking about static functions defined in `.c` files, like `check_func_arg`, `check_func_args`, `btf_check_func_arg_match`, `btf_check_subprog_call`, and `check_func_call`. They should be addressable.
Now, which functions are *really* the key entry points or hold the main logic? Let's see: `btf_check_func_arg_match`, `check_func_args`, `check_func_arg`, `check_func_call`, and `bpf_check`. I have to be careful here and avoid ubiquitous functions. The instructions explicitly warn against listing "generic, ubiquitous functions," and `bpf_check` is called during `bpf(BPF_PROG_LOAD, ...)`. That's a red flag. Is `bpf_check` too broad? Is it being called everywhere? "Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused", which severely dilutes fuzzing effort away from the actual changes." Let's look closer.
Ah, yes. The patch itself is about a refactoring; `btf_check_func_arg_match` specifically checks arguments for subprog calls with BTF args. `check_func_args` is handling *all* helper, kfunc, *and now* subprog arguments. `check_func_call` handles the BPF subprog calls during verification. `check_func_arg` deals with the *individual* argument type checking. Also, `bpf_kfunc_stack_access_bytes` and `bpf_get_call_summary`. Much more focused.
Alright, so `gen_subprog_arg_proto`. Is it static, static noinline, or potentially inlined? Let me see... It's static void and is only called from `btf_check_func_arg_match`. `btf_check_func_arg_match` is static int, called from `btf_check_subprog_call`, which itself is called from `push_callback_call`, `check_func_call`, and `check_func_callx`. `check_func_args` is called from `check_helper_call`, `check_kfunc_call`, and `btf_check_func_arg_match`. `check_func_arg` is called from `check_func_args`. Finally, `check_mem_reg` is called from `check_func_arg` and `check_helper_mem_access`, etc.
Now, let's dive into the patch's purpose: I'll carefully review `btf_check_func_arg_match`, `gen_subprog_arg_proto`, and `check_func_args` to see what's changed and what the main function really is. Previously, subprograms had their *own* argument checking logic in `btf_check_func_arg_match`:
```c
for (i = 0; i < sub->arg_slot_cnt; i++) {
argno_t argno = argno_from_arg(i + 1);
struct bpf_reg_state *reg = get_func_arg_reg(caller, regs, i);
struct bpf_subprog_arg_info *arg = &sub->args[i];
...
```
The patch *replaces* this custom logic. Instead, `btf_check_func_arg_match` now creates a temporary `bpf_func_proto` (`gen_subprog_arg_proto`) from the subprog BTF info and then calls the *unified* `check_func_args(env, &meta, env->insn_idx)`. So, the primary change is the unification of argument checking. To make this work, the patch is distinguishing `is_helper(meta)`, `is_kfunc(meta)`, and `is_subprog(meta)`. It also adapts `check_func_arg`, `check_func_arg_null
|
| 18/2 | 2026/09/29 21:21 | tool | grepper |
0mArgs:{
"Expression": "config DEBUG_INFO_BTF\\b"
}Results: {
"Output": "lib/Kconfig.debug=378=config DEBUG_INFO_SPLIT\n--\nlib/Kconfig.debug-397-\nlib/Kconfig.debug:398:config DEBUG_INFO_BTF\nlib/Kconfig.debug-399-\tbool \"Generate BTF type information\"\n"
} |
| 19/2 | 2026/09/29 21:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33269 output: 34 thoughts: 19 Thoughts: Here's my take on the thought process: **Diving into Debug Configuration** Okay, time to dig in. I need to get to the bottom of this, and my gut tells me it's related to the debug configuration. Let's see... the `lib/Kconfig.debug` file usually holds a lot of the low-level debug options, and the line numbers are often pretty good indicators of related items. So, I'm going to start by checking around line 398 in `lib/Kconfig.debug`. That area likely holds some relevant definitions or dependencies that might shed light on the issue I'm chasing down. Hopefully, this gets me closer to understanding the root cause! |
| 20/2 | 2026/09/29 21:21 | tool | read-file |
0mArgs:{
"File": "lib/Kconfig.debug",
"FirstLine": 395,
"LineCount": 20
}Results: {
"Contents": " 395:\t\t to know about the .dwo files and include them.\n 396:\t\t Incompatible with older versions of ccache.\n 397:\t\n 398:\tconfig DEBUG_INFO_BTF\n 399:\t\tbool \"Generate BTF type information\"\n 400:\t\tdepends on !DEBUG_INFO_SPLIT \u0026\u0026 !DEBUG_INFO_REDUCED\n 401:\t\tdepends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST\n 402:\t\tdepends on BPF_SYSCALL\n 403:\t\tdepends on PAHOLE_VERSION \u003e= 122\n 404:\t\t# pahole uses elfutils, which does not have support for Hexagon relocations\n 405:\t\tdepends on !HEXAGON\n 406:\t\thelp\n 407:\t\t Generate deduplicated BTF type information from DWARF debug info.\n 408:\t\t Turning this on requires pahole v1.22 or later, which will convert\n 409:\t\t DWARF type info into equivalent deduplicated BTF type info.\n 410:\t\n 411:\tconfig PAHOLE_HAS_BTF_TAG\n 412:\t\tdef_bool PAHOLE_VERSION \u003e= 123\n 413:\t\tdepends on CC_IS_CLANG\n 414:\t\thelp\n"
} |
| 21/2 | 2026/09/29 21:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33815 output: 233 thoughts: 838 Thoughts: **Analysis of BPF BTF Verification for Fuzzing Focus** Okay, so I'm thinking about how to best focus fuzzing efforts for this BPF BTF verification feature. It's clear that `DEBUG_INFO_BTF` depends on `BPF_SYSCALL`, which is standard BPF. No other obvious config dependencies jump out, so let's start by digging into `verifier.c` and zeroing in on the modified code. Specifically, from lines 7700 to 14000. I need to make sure there aren't any sneaky `#ifdef` blocks surrounding the changes. Hmm, it seems the entire `verifier.c` is compiled under `CONFIG_BPF_SYSCALL`, and `DEBUG_INFO_BTF` is fundamental for full BTF support, especially `btf_vmlinux`. Now, let's carefully pick some focus symbols. I want specific kernel functions, not ubiquitous hot paths, that directly implement the altered logic. Here's the list of modified functions in `verifier.c` I need to check: `btf_check_func_arg_match`, `check_func_args`, `check_func_arg`, `gen_subprog_arg_proto`, `btf_check_subprog_call`, `check_func_call`, `process_iter_arg`, `check_mem_reg`, `bpf_kfunc_stack_access_bytes`, and `bpf_get_call_summary`. Alright, a quick check confirms that all those symbols exist as standalone functions in `verifier.c`, except for `gen_subprog_arg_proto`, which is a new static function, and `bpf_kfunc_stack_access_bytes` and `bpf_get_call_summary` which are exported to liveness.c. Now, let's solidify the focus: `btf_check_func_arg_match` is definitely a core choice; it's the function that's been rewritten. `check_func_args` is a unified argument checker where subprog arguments are now directed. `check_func_arg` validates argument types with subprog checks (packet pointers, nullability, etc.). `btf_check_subprog_call` calls `btf_check_func_arg_match`. `check_func_call` handles subprog calls during verification. And then we have `gen_subprog_arg_proto` which creates the synthetic proto for subprog args. These all seem highly specific to the feature logic changes, which is precisely what I want to achieve to avoid ubiquitous hot paths. So, the `set-results` format should be: * `EnableConfigs`: `["BPF_SYSCALL", "DEBUG_INFO_BTF"]` * `FocusSymbols`: `["btf_check_func_arg_match", "gen_subprog_arg_proto", "check_func_args", "check_func_arg", "btf_check_subprog_call", "check_func_call"]` * `Reasoning`: Concise explanation of the function's specificity to the feature logic. * `WorthFuzzing`: `true` Looks good, this directly aligns with the guidelines. Let's invoke `set-results`! |
| 22/2 | 2026/09/29 21:21 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"BPF_SYSCALL",
"DEBUG_INFO_BTF"
],
"FocusSymbols": [
"btf_check_func_arg_match",
"gen_subprog_arg_proto",
"check_func_args",
"check_func_arg",
"btf_check_subprog_call",
"check_func_call"
],
"Reasoning": "The patch refactors the BPF verifier's argument validation logic for subprogram calls to reuse the unified helper/kfunc argument checking infrastructure (check_func_args and check_func_arg) via a synthetic bpf_func_proto generated in gen_subprog_arg_proto. This directly touches core verifier logic in kernel/bpf/verifier.c reachable via the bpf(BPF_PROG_LOAD) syscall when loading eBPF programs containing subprograms with BTF type information. Fuzzing is warranted to detect regressions, type confusion, or verifier invariant violations.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"BPF_SYSCALL",
"DEBUG_INFO_BTF"
],
"FocusSymbols": [
"btf_check_func_arg_match",
"gen_subprog_arg_proto",
"check_func_args",
"check_func_arg",
"btf_check_subprog_call",
"check_func_call"
],
"Reasoning": "The patch refactors the BPF verifier's argument validation logic for subprogram calls to reuse the unified helper/kfunc argument checking infrastructure (check_func_args and check_func_arg) via a synthetic bpf_func_proto generated in gen_subprog_arg_proto. This directly touches core verifier logic in kernel/bpf/verifier.c reachable via the bpf(BPF_PROG_LOAD) syscall when loading eBPF programs containing subprograms with BTF type information. Fuzzing is warranted to detect regressions, type confusion, or verifier invariant violations.",
"WorthFuzzing": true
} |
| 23/1 | 2026/09/29 21:21 | action | If |
3mArgs:{
"WorthFuzzing": true
}Results: null |
| 24/2 | 2026/09/29 21:21 | agent | kmsan-evaluator |
3mModel:core Args: null Results: {
"KMSANReasoning": "The patch refactors BPF subprogram argument verification in `kernel/bpf/verifier.c` to unify it with the helper/kfunc argument checking path (`check_func_args()`), avoiding duplicated logic in `btf_check_func_arg_match()`.\n\nAll newly introduced or modified structures, such as `env-\u003ebpf_subprog_scratch` and the stack-allocated `struct bpf_call_arg_meta meta`, are explicitly cleared with `memset` before use, leaving no uninitialized fields. Furthermore, the patch does not introduce or modify any copy operations to userspace, does not alter buffer initialization, and does not introduce conditional branches based on uninitialized memory. Any potential regressions or bugs in verifier type-checking or register tracking would manifest as logical errors, out-of-bounds access, or invalid pointer dereferences, which are already covered by KASAN and standard verifier assertions. Consequently, there is no risk of uninitialized memory usage or info-leaks that would require a dedicated KMSAN fuzzing session.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
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 fe5e0d8bef154f9d665413ae1df92e68032ce883
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Sep 29 21:20:42 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 646e447cebd84..385a63edc0952 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -972,6 +972,7 @@ struct bpf_verifier_env {
const struct bpf_line_info *prev_linfo;
struct bpf_verifier_log log;
struct bpf_diag *diag;
+ struct bpf_func_proto bpf_subprog_scratch;
struct bpf_subprog_info subprog_info[BPF_MAX_SUBPROGS + 2]; /* max + 2 for the fake and exception subprogs */
/* subprog indices sorted in topological order: leaves first, callers last */
int subprog_topo_order[BPF_MAX_SUBPROGS + 2];
@@ -1638,6 +1639,7 @@ struct bpf_call_arg_meta {
struct btf *btf;
u32 func_id;
const struct bpf_func_proto *fn;
+ const struct btf_type *func_proto;
u8 release_regno;
u32 ret_btf_id;
u32 subprogno;
@@ -1647,10 +1649,12 @@ struct bpf_call_arg_meta {
struct ret_mem_desc ret_mem;
struct arg_raw_mem_desc arg_raw_mem;
+ /* Only set by subprog */
+ bool subprog_may_change_pkt;
+
/* Only set by kfunc */
bool r0_rdonly;
u32 kfunc_flags;
- const struct btf_type *func_proto;
const char *func_name;
struct arg_constant_desc arg_constant;
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 5c8626215ee6c..1a0a11a4894fd 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7702,6 +7702,11 @@ static int check_mem_size_reg(struct bpf_verifier_env *env,
return err;
}
+static bool is_subprog(const struct bpf_call_arg_meta *meta)
+{
+ return meta->btf && !meta->func_id;
+}
+
static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,
argno_t argno, u32 mem_size, enum bpf_access_type access_type,
struct bpf_call_arg_meta *meta, bool *known_memory)
@@ -7720,10 +7725,11 @@ static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg
}
/*
- * Only a global subprog (meta == NULL) may read poisoned stack slots:
+ * Only a global subprog may read poisoned stack slots:
* its static stack liveness proved the callee body skips them.
*/
- size = (!meta && base_type(reg->type) == PTR_TO_STACK) ? -(int)mem_size : mem_size;
+ size = (is_subprog(meta) &&
+ base_type(reg->type) == PTR_TO_STACK) ? -(int)mem_size : mem_size;
if (access_type & BPF_READ)
err = check_helper_mem_access(env, reg, argno, size, BPF_READ, true, meta,
@@ -8263,12 +8269,12 @@ static bool is_kfunc_arg_iter(struct bpf_call_arg_meta *meta, int arg_idx,
return btf_param_match_suffix(meta->btf, arg, "__iter");
}
-static int process_iter_arg(struct bpf_verifier_env *env, struct bpf_reg_state *reg, argno_t argno, int insn_idx,
+static int process_iter_arg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,
+ u32 arg, argno_t argno, int insn_idx,
struct bpf_call_arg_meta *meta)
{
struct bpf_func_state *state = bpf_func(env, reg);
const struct btf_type *t;
- u32 arg_idx = arg_idx_from_argno(argno);
int spi, err, i, nr_slots, btf_id;
if (reg->type != PTR_TO_STACK) {
@@ -8288,7 +8294,7 @@ static int process_iter_arg(struct bpf_verifier_env *env, struct bpf_reg_state *
* to any kfunc, if arg has "__iter" suffix, we need to be a bit more
* conservative here.
*/
- btf_id = btf_check_iter_arg(meta->btf, meta->func_proto, arg_idx);
+ btf_id = btf_check_iter_arg(meta->btf, meta->func_proto, arg);
if (btf_id < 0) {
verbose(env, "expected valid iter pointer as %s\n",
reg_arg_name(env, argno));
@@ -8638,18 +8644,27 @@ static bool arg_type_is_scalar(enum bpf_arg_type type)
}
/*
- * A kfunc is named by a BTF ID, which can take the same numeric value as an
- * enum bpf_func_id. Only test meta->func_id against a BPF_FUNC_* once the call
- * is known to be to a helper; meta->btf is set only for a kfunc.
+ * A helper has no BTF and a nonzero function ID. A kfunc has both, while a
+ * BPF subprogram has BTF and a zero function ID.
*/
+static bool is_helper(const struct bpf_call_arg_meta *meta)
+{
+ return !meta->btf && meta->func_id;
+}
+
static bool is_helper_call(const struct bpf_call_arg_meta *meta, enum bpf_func_id func_id)
{
- return !meta->btf && meta->func_id == func_id;
+ return is_helper(meta) && meta->func_id == func_id;
+}
+
+static bool is_kfunc(const struct bpf_call_arg_meta *meta)
+{
+ return meta->btf && meta->func_id;
}
static bool is_kfunc_call(const struct bpf_call_arg_meta *meta, u32 btf_id)
{
- return meta->btf && meta->func_id == btf_id;
+ return is_kfunc(meta) && meta->func_id == btf_id;
}
static int resolve_map_arg_type(struct bpf_verifier_env *env,
@@ -8919,7 +8934,7 @@ __printf(6, 7) static void bpf_diag_call_arg_fmt(struct bpf_verifier_env *env, u
}
static int check_func_arg_nullability(struct bpf_verifier_env *env,
- struct bpf_reg_state *reg, argno_t argno,
+ struct bpf_reg_state *reg, u32 arg, argno_t argno,
enum bpf_arg_type arg_type,
struct bpf_call_arg_meta *meta, int insn_idx)
{
@@ -8932,7 +8947,7 @@ static int check_func_arg_nullability(struct bpf_verifier_env *env,
if (meta->btf) {
u32 arg_btf_id;
- arg_btf_id = btf_params(meta->func_proto)[arg_idx_from_argno(argno)].type;
+ arg_btf_id = btf_params(meta->func_proto)[arg].type;
expected_type = bpf_diag_fmt(env, "value of type %s",
bpf_diag_fmt_btf_type(env, meta->btf, arg_btf_id));
}
@@ -8947,7 +8962,7 @@ static int check_func_arg_nullability(struct bpf_verifier_env *env,
}
static int check_func_arg_release(struct bpf_verifier_env *env, struct bpf_reg_state *reg,
- argno_t argno, enum bpf_arg_type arg_type,
+ u32 arg, argno_t argno, enum bpf_arg_type arg_type,
struct bpf_call_arg_meta *meta, int insn_idx)
{
const char *expected_type = "pointer";
@@ -8962,12 +8977,12 @@ static int check_func_arg_release(struct bpf_verifier_env *env, struct bpf_reg_s
verbose(env, "release function %s expects referenced PTR_TO_BTF_ID passed to %s\n",
meta->func_name, reg_arg_name(env, argno));
- if (meta->btf) {
+ if (is_kfunc(meta)) {
const struct btf_param *btf_arg;
const struct btf_type *t;
u32 ref_id;
- btf_arg = &btf_params(meta->func_proto)[arg_idx_from_argno(argno)];
+ btf_arg = &btf_params(meta->func_proto)[arg];
ref_id = btf_arg->type;
t = btf_type_skip_modifiers(meta->btf, btf_arg->type, NULL);
if (btf_type_is_ptr(t))
@@ -9016,7 +9031,7 @@ static int check_reg_type(struct bpf_verifier_env *env, struct bpf_reg_state *re
verifier_bug(env, "unsupported arg type %d", arg_type);
return -EFAULT;
}
- if (meta->btf && base_type(arg_type) == ARG_PTR_TO_BTF_ID &&
+ if (is_kfunc(meta) && base_type(arg_type) == ARG_PTR_TO_BTF_ID &&
(base_type(type) == PTR_TO_BTF_ID || reg2btf_ids[base_type(type)]))
goto found;
@@ -9038,8 +9053,8 @@ static int check_reg_type(struct bpf_verifier_env *env, struct bpf_reg_state *re
type &= ~PTR_MAYBE_NULL;
if (base_type(arg_type) == ARG_PTR_TO_MEM)
type &= ~DYNPTR_TYPE_FLAG_MASK;
- /* Allow allocated memory for kfunc ARG_PTR_TO_MEM but not helper. */
- if (meta->btf && base_type(arg_type) == ARG_PTR_TO_MEM &&
+ /* Allow allocated memory for BTF-defined ARG_PTR_TO_MEM but not helpers. */
+ if (!is_helper(meta) && base_type(arg_type) == ARG_PTR_TO_MEM &&
type_is_ptr_alloc_obj(type))
type = PTR_TO_MEM;
@@ -9362,7 +9377,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
struct bpf_call_arg_meta *meta,
int insn_idx)
{
- const struct btf_param *btf_arg = meta->btf ? &btf_params(meta->func_proto)[arg] : NULL;
+ const struct btf_param *btf_arg = is_kfunc(meta) ?
+ &btf_params(meta->func_proto)[arg] : NULL;
const struct bpf_func_proto *fn = meta->fn;
struct bpf_func_state *caller = cur_func(env);
struct bpf_reg_state *regs = cur_regs(env);
@@ -9412,7 +9428,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
return 0;
}
- err = check_func_arg_nullability(env, reg, argno, arg_type, meta, insn_idx);
+ err = check_func_arg_nullability(env, reg, arg, argno, arg_type, meta, insn_idx);
if (err)
return err;
@@ -9424,7 +9440,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
if (err)
return err;
- err = check_func_arg_release(env, reg, argno, arg_type, meta, insn_idx);
+ err = check_func_arg_release(env, reg, arg, argno, arg_type, meta, insn_idx);
if (err)
return err;
@@ -9502,7 +9518,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
case ARG_PTR_TO_BTF_ID_SOCK_COMMON:
{
const u32 *arg_btf_id = fn->arg_btf_id[arg];
- const struct btf *arg_btf = meta->btf ?: btf_vmlinux;
+ const struct btf *arg_btf = is_kfunc(meta) ? meta->btf : btf_vmlinux;
if (!meta->btf) {
const struct bpf_reg_types *compatible;
@@ -9530,8 +9546,8 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
}
}
- if (meta->btf && (!is_trusted_reg(env, reg) ||
- bpf_type_has_unsafe_modifiers(reg->type))) {
+ if (is_kfunc(meta) && (!is_trusted_reg(env, reg) ||
+ bpf_type_has_unsafe_modifiers(reg->type))) {
if (!(arg_type & MEM_RCU)) {
const char *actual_type, *arg_name, *expected_type;
@@ -9668,6 +9684,17 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
bpf_diag_reg_type_plain(env, reg->type));
return err;
}
+ /*
+ * PTR_TO_PACKET gets passed as PTR_TO_MEM, preventing us from adjusting
+ * bounds tracking information.
+ */
+ if (is_subprog(meta) && meta->subprog_may_change_pkt &&
+ (reg_is_pkt_pointer_any(reg) || reg_is_dynptr_slice_pkt(reg))) {
+ verbose(env,
+ "cannot pass packet pointer %s to %s(): function may change packet data\n",
+ reg_arg_name(env, argno), meta->func_name);
+ return -EINVAL;
+ }
if (arg_type & MEM_ALIGNED)
err = check_ptr_alignment(env, reg, 0, arg_size, true);
break;
@@ -9758,7 +9785,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
verbose(env, "css_task_iter is only allowed in bpf_lsm, bpf_iter and sleepable progs\n");
return -EINVAL;
}
- err = process_iter_arg(env, reg, argno, insn_idx, meta);
+ err = process_iter_arg(env, reg, arg, argno, insn_idx, meta);
if (err < 0)
return err;
break;
@@ -9930,20 +9957,20 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
* func model recorded, or the verifier would check an argument at a slot
* the JIT does not place it at.
*/
-static u32 kfunc_arg_slots(const struct btf_type *t)
+static u32 btf_arg_slots(const struct btf_type *t)
{
if (btf_type_is_int(t) || btf_type_is_struct(t))
return (t->size + BPF_REG_SIZE - 1) / BPF_REG_SIZE;
return 1;
}
-static u32 kfunc_proto_slots(const struct btf *btf, const struct btf_type *func_proto)
+static u32 btf_proto_slots(const struct btf *btf, const struct btf_type *func_proto)
{
const struct btf_param *args = btf_params(func_proto);
u32 i, nargs = btf_type_vlen(func_proto), slots_used = 0;
for (i = 0; i < nargs; i++)
- slots_used += kfunc_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));
+ slots_used += btf_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));
return slots_used;
}
@@ -9986,7 +10013,7 @@ static int check_func_args(struct bpf_verifier_env *env, struct bpf_call_arg_met
* count. Only a proto whose parameters take a slot each can name the
* argument a stack slot belongs to.
*/
- proto_slots = meta->btf ? kfunc_proto_slots(meta->btf, meta->func_proto) : nargs;
+ proto_slots = meta->btf ? btf_proto_slots(meta->btf, meta->func_proto) : nargs;
if (proto_slots > MAX_BPF_FUNC_REG_ARGS) {
err = check_outgoing_stack_args(env, caller, proto_slots, meta->func_name,
@@ -10002,7 +10029,7 @@ static int check_func_args(struct bpf_verifier_env *env, struct bpf_call_arg_met
nslots = 1;
if (args) {
t = btf_type_skip_modifiers(meta->btf, args[arg].type, NULL);
- nslots = kfunc_arg_slots(t);
+ nslots = btf_arg_slots(t);
}
if (meta->fn->arg_type[arg] == ARG_UNUSED)
@@ -10787,21 +10814,50 @@ static int setup_func_entry(struct bpf_verifier_env *env, int subprog, int calls
return err;
}
-static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
- const struct btf *btf,
- struct bpf_reg_state *regs)
+static void gen_subprog_arg_proto(const struct bpf_subprog_info *sub, const struct btf *btf,
+ const struct btf_type *func_proto, struct bpf_func_proto *proto)
+{
+ const struct btf_param *args = btf_params(func_proto);
+ u32 arg, slot = 0;
+
+ memset(proto, 0, sizeof(*proto));
+ for (arg = 0; arg < btf_type_vlen(func_proto); arg++) {
+ enum bpf_arg_type arg_type = sub->args[slot].arg_type;
+ const struct btf_type *t;
+
+ if (arg_type & PTR_UNTRUSTED) {
+ /*
+ * An __arg_untrusted argument accepts any caller value. The
+ * callee treats it as read-only and uses probe-read instructions
+ * to protect against invalid memory access.
+ */
+ arg_type = ARG_IGNORE;
+ } else if (base_type(arg_type) == ARG_PTR_TO_ARENA) {
+ arg_type |= PTR_MAYBE_NULL;
+ } else if (base_type(arg_type) == ARG_PTR_TO_MEM) {
+ proto->arg_size[arg] = sub->args[slot].mem_size;
+ arg_type |= MEM_FIXED_SIZE | MEM_WRITE;
+ } else if (base_type(arg_type) == ARG_PTR_TO_BTF_ID) {
+ proto->arg_btf_id[arg] = &sub->args[slot].btf_id;
+ }
+ proto->arg_type[arg] = arg_type;
+ t = btf_type_skip_modifiers(btf, args[arg].type, NULL);
+ slot += btf_arg_slots(t);
+ }
+}
+
+static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog, struct btf *btf)
{
struct bpf_subprog_info *sub = subprog_info(env, subprog);
struct bpf_func_state *caller = cur_func(env);
- struct bpf_verifier_log *log = &env->log;
- const struct btf_param *args;
const struct btf_type *func, *func_proto;
struct bpf_call_arg_meta meta;
- u32 i;
+ struct bpf_func_proto *fn;
int ret, err;
- /* Leave btf and func_id zero: this is neither a helper nor a kfunc. */
memset(&meta, 0, sizeof(meta));
+ meta.btf = btf;
+ meta.subprog_may_change_pkt = sub->changes_pkt_data;
meta.func_name = bpf_subprog_name(env, subprog);
ret = btf_prepare_func_args(env, subprog);
@@ -10818,127 +10874,24 @@ static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
func = btf_type_by_id(btf, env->prog->aux->func_info[subprog].type_id);
func_proto = btf_type_by_id(btf, func->type);
- args = btf_params(func_proto);
- if (sub->arg_slot_cnt != btf_type_vlen(func_proto))
- args = NULL;
- ret = check_outgoing_stack_args(env, caller, sub->arg_slot_cnt,
- bpf_subprog_name(env, subprog), btf, args);
- if (ret)
- return ret;
-
- /* check that BTF function arguments match actual types that the
- * verifier sees.
- */
- for (i = 0; i < sub->arg_slot_cnt; i++) {
- argno_t argno = argno_from_arg(i + 1);
- struct bpf_reg_state *reg = get_func_arg_reg(caller, regs, i);
- struct bpf_subprog_arg_info *arg = &sub->args[i];
-
- if (arg->arg_type == ARG_SCALAR) {
- if (reg->type != SCALAR_VALUE) {
- bpf_log(log, "%s is not a scalar\n", reg_arg_name(env, argno));
- return -EINVAL;
- }
- } else if (arg->arg_type & PTR_UNTRUSTED) {
- /*
- * Anything is allowed for untrusted arguments, as these are
- * read-only and probe read instructions would protect against
- * invalid memory access.
- */
- } else if (arg->arg_type == ARG_PTR_TO_CTX) {
- ret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_CTX);
- if (ret < 0)
- return ret;
- /* If function expects ctx type in BTF check that caller
- * is passing PTR_TO_CTX.
- */
- if (reg->type != PTR_TO_CTX) {
- bpf_log(log, "%s expects pointer to ctx\n",
- reg_arg_name(env, argno));
- return -EINVAL;
- }
- } else if (base_type(arg->arg_type) == ARG_PTR_TO_MEM) {
- ret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_MEM);
- if (ret < 0)
- return ret;
- if (check_mem_reg(env, reg, argno, arg->mem_size, BPF_READ | BPF_WRITE, NULL,
- NULL))
- return -EINVAL;
- /*
- * PTR_TO_PACKET get passed as PTR_TO_MEM, preventing
- * us from adjusting bounds tracking info.
- */
- if ((reg_is_pkt_pointer_any(reg) || reg_is_dynptr_slice_pkt(reg)) &&
- sub->changes_pkt_data) {
- bpf_log(log, "%s is a packet pointer, but func#%d may change packet data\n",
- reg_arg_name(env, argno), subprog);
- return -EINVAL;
- }
- if (!(arg->arg_type & PTR_MAYBE_NULL) &&
- (type_may_be_null(reg->type) || bpf_register_is_null(reg))) {
- bpf_log(log, "%s is expected to be non-NULL\n",
- reg_arg_name(env, argno));
- return -EINVAL;
- }
- } else if (base_type(arg->arg_type) == ARG_PTR_TO_ARENA) {
- /*
- * Can pass any value and the kernel won't crash, but
- * only PTR_TO_ARENA or SCALAR make sense. Everything
- * else is a bug in the bpf program. Point it out to
- * the user at the verification time instead of
- * run-time debug nightmare.
- */
- if (reg->type != PTR_TO_ARENA && reg->type != SCALAR_VALUE) {
- bpf_log(log, "%s is not a pointer to arena or scalar.\n",
- reg_arg_name(env, argno));
- return -EINVAL;
- }
- } else if (arg->arg_type == ARG_PTR_TO_DYNPTR) {
- ret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_DYNPTR);
- if (ret)
- return ret;
-
- ret = process_dynptr_func(env, reg, argno, env->insn_idx,
- arg->arg_type, &meta);
- if (ret)
- return ret;
- } else if (base_type(arg->arg_type) == ARG_PTR_TO_BTF_ID) {
- int err;
-
- if (bpf_register_is_null(reg) && type_may_be_null(arg->arg_type)) {
- err = mark_arg_precision(env, argno);
- if (err)
- return err;
- continue;
- }
- err = check_reg_type(env, reg, argno, arg->arg_type, &meta);
- err = err ?: check_func_arg_reg_off(env, reg, argno, arg->arg_type);
- if (!err && base_type(reg->type) == PTR_TO_BTF_ID)
- err = process_arg_ptr_to_btf_id(env, reg, argno, arg->arg_type,
- btf_vmlinux, arg->btf_id,
- &meta, env->insn_idx);
- if (err)
- return err;
- } else {
- verifier_bug(env, "unrecognized %s type %d",
- reg_arg_name(env, argno), arg->arg_type);
- return -EFAULT;
- }
- }
+ fn = &env->bpf_subprog_scratch;
+ gen_subprog_arg_proto(sub, btf, func_proto, fn);
+ meta.fn = fn;
+ meta.func_proto = func_proto;
- return 0;
+ return check_func_args(env, &meta, env->insn_idx);
}
-/* Compare BTF of a function call with given bpf_reg_state.
+/*
+ * Check that call-site argument states match a subprog's BTF signature.
+ *
* Returns:
* EFAULT - there is a verifier bug. Abort verification.
- * EINVAL - there is a type mismatch or BTF is not available.
+ * Other errors - there is a type mismatch or BTF is not available.
* 0 - BTF matches with what bpf_reg_state expects.
- * Only PTR_TO_CTX and SCALAR_VALUE states are recognized.
*/
-static int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog,
- struct bpf_reg_state *regs)
+static int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog)
{
struct bpf_prog *prog = env->prog;
struct btf *btf = prog->aux->btf;
@@ -10955,7 +10908,7 @@ static int btf_check_subprog_call(struct bpf_verifier_env *env, int subprog,
if (prog->aux->func_info_aux[subprog].unreliable)
return -EINVAL;
- err = btf_check_func_arg_match(env, subprog, btf, regs);
+ err = btf_check_func_arg_match(env, subprog, btf);
/* Compiler optimizations can remove arguments from static functions
* or mismatched type can be passed into a global function.
* In such cases mark the function as unreliable from BTF point of view.
@@ -10974,7 +10927,7 @@ static int push_callback_call(struct bpf_verifier_env *env, struct bpf_insn *ins
int err;
caller = state->frame[state->curframe];
- err = btf_check_subprog_call(env, subprog, caller->regs);
+ err = btf_check_subprog_call(env, subprog);
if (err == -EFAULT)
return err;
@@ -11111,7 +11064,7 @@ static int check_func_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
return -EFAULT;
caller = state->frame[state->curframe];
- err = btf_check_subprog_call(env, subprog, caller->regs);
+ err = btf_check_subprog_call(env, subprog);
if (err == -EFAULT)
return err;
if (bpf_subprog_is_global(env, subprog)) {
@@ -11247,7 +11200,7 @@ static int check_func_callx(struct bpf_verifier_env *env, struct bpf_insn *insn,
/* PTR_TO_FUNC is a pointer to a static subprog */
subprog = reg->subprogno;
- err = btf_check_subprog_call(env, subprog, caller->regs);
+ err = btf_check_subprog_call(env, subprog);
if (err == -EFAULT)
return err;
@@ -13058,7 +13011,7 @@ static int resolve_func_arg_type(struct bpf_verifier_env *env,
if (base_type(*arg_type) != ARG_PTR_TO_BTF_ID)
return 0;
- if (!meta->btf || arg_type_is_release(*arg_type) ||
+ if (!is_kfunc(meta) || arg_type_is_release(*arg_type) ||
base_type(reg->type) == PTR_TO_BTF_ID ||
reg2btf_ids[base_type(reg->type)])
return 0;
@@ -13781,7 +13734,7 @@ static int process_arg_ptr_to_btf_id(struct bpf_verifier_env *env, struct bpf_re
* resolve types.
*/
if ((arg_type_is_release(arg_type) && !is_helper_call(meta, BPF_FUNC_sk_release)) ||
- (meta->btf && btf_type_ids_nocast_alias(&env->log, reg_btf, reg_btf_id,
+ (is_kfunc(meta) && btf_type_ids_nocast_alias(&env->log, reg_btf, reg_btf_id,
arg_btf, arg_btf_id)))
strict_type_match = true;
@@ -13798,7 +13751,7 @@ static int process_arg_ptr_to_btf_id(struct bpf_verifier_env *env, struct bpf_re
* actually use it -- it must cast to the underlying type. So we allow
* caller to pass in the underlying type.
*/
- taking_projection = meta->btf && btf_is_projection_of(arg_tname, reg_tname);
+ taking_projection = is_kfunc(meta) && btf_is_projection_of(arg_tname, reg_tname);
if (!taking_projection && !struct_same) {
verbose(env, "%s %s expected pointer to %s %s but %s has a pointer to %s %s\n",
meta->func_name, reg_arg_name(env, argno),
@@ -14499,7 +14452,7 @@ s64 bpf_kfunc_stack_access_bytes(struct bpf_verifier_env *env, struct bpf_insn *
* pointer, and neither does a slot past the last parameter.
*/
for (i = 0, slot = 0; i < nargs && slot < arg; i++)
- slot += kfunc_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));
+ slot += btf_arg_slots(btf_type_skip_modifiers(btf, args[i].type, NULL));
if (i >= nargs || slot != arg)
return 0;
@@ -18782,7 +18735,7 @@ bool bpf_get_call_summary(struct bpf_verifier_env *env, struct bpf_insn *call,
if (err < 0)
/* error would be reported later */
return false;
- cs->arg_slot_cnt = kfunc_proto_slots(meta.btf, meta.func_proto);
+ cs->arg_slot_cnt = btf_proto_slots(meta.btf, meta.func_proto);
cs->fastcall = meta.kfunc_flags & KF_FASTCALL;
cs->is_void = btf_type_is_void(btf_type_by_id(meta.btf, meta.func_proto->type));
return true;
diff --git a/tools/testing/selftests/bpf/progs/aggregate_arg_func.c b/tools/testing/selftests/bpf/progs/aggregate_arg_func.c
index d0a4f84a6fbfa..2132b926a8f08 100644
--- a/tools/testing/selftests/bpf/progs/aggregate_arg_func.c
+++ b/tools/testing/selftests/bpf/progs/aggregate_arg_func.c
@@ -43,7 +43,7 @@ __naked int aggregate_arg_pair_asm(void)
}
SEC("tc")
-__failure __msg("R2 is not a scalar")
+__failure __msg("R2 type=fp expected=scalar")
__naked int aggregate_arg_pair_ptr_fail(void)
{
asm volatile (
diff --git a/tools/testing/selftests/bpf/progs/dynptr_fail.c b/tools/testing/selftests/bpf/progs/dynptr_fail.c
index 9418dfe4d7b7f..148cf44173221 100644
--- a/tools/testing/selftests/bpf/progs/dynptr_fail.c
+++ b/tools/testing/selftests/bpf/progs/dynptr_fail.c
@@ -2053,19 +2053,18 @@ __noinline long global_call_bpf_dynptr(const struct bpf_dynptr *dynptr)
/* Avoid leaving this global function empty to avoid having the compiler
* optimize away the call to this global function.
*/
+ __sink(dynptr);
__sink(ret);
return ret;
}
SEC("?raw_tp")
-__failure __msg("R1 expected pointer to stack or const struct bpf_dynptr")
+__failure __msg("R1 type=trusted_ptr_ expected=fp, dynptr_ptr")
int test_dynptr_reg_type(void *ctx)
{
- struct task_struct *current = NULL;
- /* R1 should be holding a PTR_TO_BTF_ID, so this shouldn't be a
- * reg->type that can be passed to a function accepting a
- * ARG_PTR_TO_DYNPTR | MEM_RDONLY. process_dynptr_func() should catch
- * this.
+ struct task_struct *current = bpf_get_current_task_btf();
+ /* R1 holds a PTR_TO_BTF_ID, which cannot be passed to a function
+ * accepting ARG_PTR_TO_DYNPTR | MEM_RDONLY.
*/
global_call_bpf_dynptr((const struct bpf_dynptr *)current);
return 0;
diff --git a/tools/testing/selftests/bpf/progs/test_global_func5.c b/tools/testing/selftests/bpf/progs/test_global_func5.c
index 257c0569ff98f..4573ecd96aa0b 100644
--- a/tools/testing/selftests/bpf/progs/test_global_func5.c
+++ b/tools/testing/selftests/bpf/progs/test_global_func5.c
@@ -26,7 +26,7 @@ int f3(int val, struct __sk_buff *skb)
}
SEC("tc")
-__failure __msg("expects pointer to ctx")
+__failure __msg("R2 type=fp expected=ctx")
int global_func5(struct __sk_buff *skb)
{
return f1(skb) + f2(2, skb) + f3(3, skb);
diff --git a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
index 10019af5eb747..03507eeae3cb3 100644
--- a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
+++ b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
@@ -87,7 +87,7 @@ __weak int subprog_trusted_task_nonnull(struct task_struct *task __arg_trusted)
SEC("?kprobe")
__failure __log_level(2)
-__msg("R1 type=scalar expected=ptr_, trusted_ptr_, rcu_ptr_")
+__msg("Possibly NULL pointer passed to trusted R1")
__msg("Caller passes invalid args into func#1 ('subprog_trusted_task_nonnull')")
int trusted_task_arg_nonnull_fail1(void *ctx)
{
@@ -96,7 +96,7 @@ int trusted_task_arg_nonnull_fail1(void *ctx)
SEC("?tp_btf/task_newtask")
__failure __log_level(2)
-__msg("R1 type=trusted_ptr_or_null_ expected=ptr_, trusted_ptr_, rcu_ptr_")
+__msg("Possibly NULL pointer passed to trusted R1")
__msg("Caller passes invalid args into func#1 ('subprog_trusted_task_nonnull')")
int trusted_task_arg_nonnull_fail2(void *ctx)
{
@@ -389,7 +389,8 @@ __weak int subprog_pkt_ptr_changes_data(struct __sk_buff *skb __arg_ctx,
SEC("?tc")
__failure __log_level(2)
-__msg("R2 is a packet pointer, but func#{{[0-9]+}} may change packet data")
+__msg("cannot pass packet pointer R2")
+__msg("function may change packet data")
__msg("Caller passes invalid args into func#{{[0-9]+}} ('subprog_pkt_ptr_changes_data')")
int pkt_ptr_to_global_mem_arg_changes_data(struct __sk_buff *skb)
{
diff --git a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
index 27fbe54e8795a..574b26b5a7dfb 100644
--- a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
+++ b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
@@ -195,7 +195,7 @@ int arg_tag_nonnull_ptr_good(void *ctx)
SEC("?raw_tp")
__failure __log_level(2)
-__msg("R1 is expected to be non-NULL")
+__msg("Possibly NULL pointer passed to trusted R1")
int arg_tag_nonnull_ptr_null_bad(void *ctx)
{
int y = 74;
|
| 25/3 | 2026/09/29 21:21 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 13251 output: 18 thoughts: 1528 Thoughts: **KMSAN Fuzzing Evaluation for BPF Verifier Patch** Okay, so I need to decide if this patch warrants a KMSAN fuzzing session, targeting the amd64 architecture. Let's dig in. I see changes across `include/linux/bpf_verifier.h`, `kernel/bpf/verifier.c`, and some selftests. First, the header file modifications. In `struct bpf_verifier_env`, a `struct bpf_func_proto bpf_subprog_scratch` is added. And, crucial for argument handling, `struct bpf_call_arg_meta` now includes `const struct btf_type *func_proto` (shared between kfunc and subprog) and `bool subprog_may_change_pkt`. Moving to `verifier.c`, `is_subprog` is defined by the absence of a `func_id` alongside an existing BTF type. The core of the logic seems to be about how stack slots are handled. The original code's check on stack slot poisoning was: "Only a global subprog (meta == NULL) may read poisoned stack slots: its static stack liveness proved the callee body skips them." This has been changed to "Only a global subprog may read poisoned stack slots: its static stack liveness proved the callee body skips them." The key here is the introduction of `is_subprog(meta)`. Previously, `check_mem_reg` had different behavior based on a `NULL` meta, but the code flow seems to be refactored, now that `meta` is no longer NULL. Okay, let's step back and understand the high-level change. The patch aims to unify the argument checking for subprograms, helpers, and kfuncs. Previously, subprograms had a custom loop. Now, the patch synthesizes a `bpf_func_proto` into `env->bpf_subprog_scratch`, populates a `meta` structure, and then calls the shared `check_func_args`. This means a unified approach based on BTF function prototypes. So, `is_helper`, `is_kfunc`, and `is_subprog` are used to differentiate. Also, it looks like `process_iter_arg`, `check_func_arg_nullability`, and `check_func_arg_release` now directly take `u32 arg` instead of an index. It looks like slot and arg indices can diverge. The `btf_arg_slots` and `btf_proto_slots` names are now generalized. The critical question now: does this refactoring introduce any uninitialized memory risks? The code heavily uses `memset` to initialize `bpf_subprog_scratch` in `gen_subprog_arg_proto` and `meta` in `btf_check_func_arg_match`. So, initialization seems to be covered. What about memory reads? The core logic relies on "poisoned stack slots," which now rely on the `is_subprog` check. I need to understand what "poisoned stack slots" means in the context of the verifier, so I'll need to grep for that phrase in the kernel to understand the context of the change. This is critical to determine if a KMSAN fuzzing campaign is needed. It seems like the core check is still in place, so the risk is likely not high, but I need to investigate further. |
| 26/3 | 2026/09/29 21:21 | tool | grepper |
0mArgs:{
"Expression": "poisoned stack slots"
}Results: {
"Output": "kernel/bpf/verifier.c=7710=static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\n--\nkernel/bpf/verifier.c-7727-\t/*\nkernel/bpf/verifier.c:7728:\t * Only a global subprog may read poisoned stack slots:\nkernel/bpf/verifier.c-7729-\t * its static stack liveness proved the callee body skips them.\n"
} |
| 27/3 | 2026/09/29 21:21 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 15677 output: 37 thoughts: 24 Thoughts: Okay, here's my attempt at summarizing the thought process, as requested, targeting an expert audience and speaking in the first person: **Navigating the BPF Verifier: Line 7710 in `kernel/bpf/verifier.c`** Alright, let's dive into this. Line 7710 in `kernel/bpf/verifier.c`... that's deep within the heart of the BPF verifier, isn't it? My first instinct is to immediately recall what surrounds that section. I need the surrounding context to understand what logic is being implemented there. I'm mentally parsing where I anticipate this line will sit within the broader verification process. Is it related to register state tracking? Instruction validation? Loop analysis? Or perhaps it's an aspect of resource usage limits or potential memory access violations? I'm thinking about the control flow graph. I need to quickly recall the surrounding functions and their purpose. What's the call stack leading to this line? Is it from `bpf_check` directly, or is it several levels deep within some auxiliary function? Identifying the path the verifier took to reach that specific line is crucial for deciphering its purpose. Beyond the immediate code, I'm already formulating questions. Is this related to a specific vulnerability class? A potential performance bottleneck? A subtle edge case in the instruction set that needs to be addressed? Is this line part of a recent patch or a long-standing component? Are there any related commit messages or bug reports that might shed light on the design choices made in this section? Time to start drilling down. |
| 28/3 | 2026/09/29 21:22 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/verifier.c",
"FirstLine": 7715,
"LineCount": 40
}Results: {
"Contents": "7715:\t\n7716:\t\tif (bpf_register_is_null(reg))\n7717:\t\t\treturn mark_arg_precision(env, argno);\n7718:\t\tif (known_memory)\n7719:\t\t\t*known_memory = true;\n7720:\t\n7721:\t\tif (mem_size \u003e S32_MAX) {\n7722:\t\t\tverbose(env, \"%s memory size %u is too large\\n\",\n7723:\t\t\t\treg_arg_name(env, argno), mem_size);\n7724:\t\t\treturn -EACCES;\n7725:\t\t}\n7726:\t\n7727:\t\t/*\n7728:\t\t * Only a global subprog may read poisoned stack slots:\n7729:\t\t * its static stack liveness proved the callee body skips them.\n7730:\t\t */\n7731:\t\tsize = (is_subprog(meta) \u0026\u0026\n7732:\t\t\tbase_type(reg-\u003etype) == PTR_TO_STACK) ? -(int)mem_size : mem_size;\n7733:\t\n7734:\t\tif (access_type \u0026 BPF_READ)\n7735:\t\t\terr = check_helper_mem_access(env, reg, argno, size, BPF_READ, true, meta,\n7736:\t\t\t\t\t\t known_memory);\n7737:\t\tif (!err \u0026\u0026 (access_type \u0026 BPF_WRITE))\n7738:\t\t\terr = check_helper_mem_access(env, reg, argno, size, BPF_WRITE, true, meta,\n7739:\t\t\t\t\t\t known_memory);\n7740:\t\n7741:\t\treturn err;\n7742:\t}\n7743:\t\n7744:\tstatic int process_const_alloc_mem_size(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\n7745:\t\t\t\t\t\targno_t argno, struct ret_mem_desc *ret_mem)\n7746:\t{\n7747:\t\tint regno = reg_from_argno(argno);\n7748:\t\tint err;\n7749:\t\n7750:\t\tif (ret_mem-\u003efound) {\n7751:\t\t\tverifier_bug(env, \"only one allocation size argument permitted\");\n7752:\t\t\treturn -EFAULT;\n7753:\t\t}\n7754:\t\n"
} |
| 29/3 | 2026/09/29 21:22 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 16715 output: 37 thoughts: 20 Thoughts: Here's my understanding of the thought process, summarized as you requested: **Deconstructing `check_helper_mem_access` with Negative `size`** Okay, so I'm looking at `check_helper_mem_access` now, and my main question is, what happens when the `size` parameter is negative? I need to understand the implications of this condition within the function's logic. This likely represents an interesting edge case or perhaps an indicator of an error that I need to investigate. I'm going to dig in, focusing specifically on how the function handles or interprets this seemingly invalid input. My initial thought is that a negative size probably signals some kind of memory access violation or an issue with the underlying data structure being accessed. But, I won't jump to conclusions just yet. I need a clear mental model to reason about it, and determine what the code intends. |
| 30/3 | 2026/09/29 21:22 | tool | grepper |
0mArgs:{
"Expression": "check_helper_mem_access.*size",
"PathPrefix": "kernel/bpf/verifier.c"
}Results: {
"Output": "kernel/bpf/verifier.c=7633=static int check_mem_size_reg(struct bpf_verifier_env *env,\n--\nkernel/bpf/verifier.c-7685-\tif (access_type \u0026 BPF_READ)\nkernel/bpf/verifier.c:7686:\t\terr = check_helper_mem_access(env, mem_reg, mem_argno, reg_umax(size_reg),\nkernel/bpf/verifier.c-7687-\t\t\t\t\t BPF_READ, zero_size_allowed, meta, NULL);\nkernel/bpf/verifier.c-7688-\tif (!err \u0026\u0026 access_type \u0026 BPF_WRITE)\nkernel/bpf/verifier.c:7689:\t\terr = check_helper_mem_access(env, mem_reg, mem_argno, reg_umax(size_reg),\nkernel/bpf/verifier.c-7690-\t\t\t\t\t BPF_WRITE, zero_size_allowed, meta, NULL);\n--\nkernel/bpf/verifier.c=7710=static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\n--\nkernel/bpf/verifier.c-7734-\tif (access_type \u0026 BPF_READ)\nkernel/bpf/verifier.c:7735:\t\terr = check_helper_mem_access(env, reg, argno, size, BPF_READ, true, meta,\nkernel/bpf/verifier.c-7736-\t\t\t\t\t known_memory);\nkernel/bpf/verifier.c-7737-\tif (!err \u0026\u0026 (access_type \u0026 BPF_WRITE))\nkernel/bpf/verifier.c:7738:\t\terr = check_helper_mem_access(env, reg, argno, size, BPF_WRITE, true, meta,\nkernel/bpf/verifier.c-7739-\t\t\t\t\t known_memory);\n--\nkernel/bpf/verifier.c=9376=static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 prev_slot,\n--\nkernel/bpf/verifier.c-9484-\t\tkey_size = meta-\u003emap.ptr-\u003ekey_size;\nkernel/bpf/verifier.c:9485:\t\terr = check_helper_mem_access(env, reg, argno, key_size, BPF_READ, false, meta,\nkernel/bpf/verifier.c-9486-\t\t\t\t\t NULL);\n--\nkernel/bpf/verifier.c-9512-\nkernel/bpf/verifier.c:9513:\t\terr = check_helper_mem_access(env, reg, argno, meta-\u003emap.ptr-\u003evalue_size,\nkernel/bpf/verifier.c-9514-\t\t\t\t\t arg_type \u0026 MEM_WRITE ? BPF_WRITE : BPF_READ,\n"
} |
| 31/3 | 2026/09/29 21:22 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17698 output: 36 thoughts: 26 Thoughts: Okay, let's dive into this. Here's my take on understanding the `check_helper_mem_access` implementation, focusing on the negative size and poisoned stack slot handling: **Analyzing `check_helper_mem_access` for Negative Sizes and Poisoned Slots** Right, so I need to get a clear picture of how this function, `check_helper_mem_access`, handles potentially dangerous memory access requests. My primary concern here is safety, particularly when dealing with negative sizes or when stack slots have been marked as poisoned, which suggests a prior memory corruption or use-after-free scenario. The first thing I'll want to trace is exactly how a negative size would propagate through the system. I need to understand what assumptions are being made about the size parameter; are these assumptions valid in all contexts? Is it a signed or unsigned integer type, and how does this affect the comparisons? I need to know at which point it's caught, and what specific action is triggered. Is it a graceful exit, a trap, an error code, or something else? Then, the poisoned stack slot logic. I need to see *how* it's checking for poisoned slots. Is it a bit flag, a dedicated metadata structure, or a specific value in the memory location itself? Is the checking performed at the point of the access, or is it done ahead of time? What are the implications if a poisoned slot check fails? Does it always lead to immediate termination, or are there different severity levels for different contexts? I need to understand the granularity of that poisoning; can an entire frame be poisoned, or individual slots? Basically, I want to understand the design. How robust is it? Can a carefully crafted attack bypass the checks? I'll be looking for potential vulnerabilities, edge cases, and areas where this safety mechanism might break down under unusual circumstances. I want to make sure I completely understand how this handles the integrity of the data that might be accessed, and what happens if something goes wrong. |
| 32/3 | 2026/09/29 21:22 | tool | grepper |
0mArgs:{
"Expression": "check_helper_mem_access\\(",
"PathPrefix": "kernel/bpf/verifier.c"
}Results: {
"Output": "kernel/bpf/verifier.c=7396=static int check_stack_range_initialized(\n--\nkernel/bpf/verifier.c-7527-\nkernel/bpf/verifier.c:7528:static int check_helper_mem_access(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\nkernel/bpf/verifier.c-7529-\t\t\t\t argno_t argno, int access_size,\n--\nkernel/bpf/verifier.c=7633=static int check_mem_size_reg(struct bpf_verifier_env *env,\n--\nkernel/bpf/verifier.c-7685-\tif (access_type \u0026 BPF_READ)\nkernel/bpf/verifier.c:7686:\t\terr = check_helper_mem_access(env, mem_reg, mem_argno, reg_umax(size_reg),\nkernel/bpf/verifier.c-7687-\t\t\t\t\t BPF_READ, zero_size_allowed, meta, NULL);\nkernel/bpf/verifier.c-7688-\tif (!err \u0026\u0026 access_type \u0026 BPF_WRITE)\nkernel/bpf/verifier.c:7689:\t\terr = check_helper_mem_access(env, mem_reg, mem_argno, reg_umax(size_reg),\nkernel/bpf/verifier.c-7690-\t\t\t\t\t BPF_WRITE, zero_size_allowed, meta, NULL);\n--\nkernel/bpf/verifier.c=7710=static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\n--\nkernel/bpf/verifier.c-7734-\tif (access_type \u0026 BPF_READ)\nkernel/bpf/verifier.c:7735:\t\terr = check_helper_mem_access(env, reg, argno, size, BPF_READ, true, meta,\nkernel/bpf/verifier.c-7736-\t\t\t\t\t known_memory);\nkernel/bpf/verifier.c-7737-\tif (!err \u0026\u0026 (access_type \u0026 BPF_WRITE))\nkernel/bpf/verifier.c:7738:\t\terr = check_helper_mem_access(env, reg, argno, size, BPF_WRITE, true, meta,\nkernel/bpf/verifier.c-7739-\t\t\t\t\t known_memory);\n--\nkernel/bpf/verifier.c=9376=static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 prev_slot,\n--\nkernel/bpf/verifier.c-9484-\t\tkey_size = meta-\u003emap.ptr-\u003ekey_size;\nkernel/bpf/verifier.c:9485:\t\terr = check_helper_mem_access(env, reg, argno, key_size, BPF_READ, false, meta,\nkernel/bpf/verifier.c-9486-\t\t\t\t\t NULL);\n--\nkernel/bpf/verifier.c-9512-\nkernel/bpf/verifier.c:9513:\t\terr = check_helper_mem_access(env, reg, argno, meta-\u003emap.ptr-\u003evalue_size,\nkernel/bpf/verifier.c-9514-\t\t\t\t\t arg_type \u0026 MEM_WRITE ? BPF_WRITE : BPF_READ,\n--\nkernel/bpf/verifier.c=13391=get_kfunc_arg_type(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,\n--\nkernel/bpf/verifier.c-13567-\t\t * Otherwise this is a fixed-size memory buffer supported by\nkernel/bpf/verifier.c:13568:\t\t * check_helper_mem_access(): a pointer to a scalar or a struct of\nkernel/bpf/verifier.c-13569-\t\t * scalars. The access size is derived from the pointed-to BTF type.\n"
} |
| 33/3 | 2026/09/29 21:22 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19184 output: 37 thoughts: 21 Thoughts: Okay, let's dive into this code. **Analyzing `check_helper_mem_access`** Alright, I'm going to jump straight into `check_helper_mem_access`, focusing around line 7528. I need to understand how this helper function is handling memory access. Given its name, I'm expecting some crucial checks here to ensure memory safety. I want to see if it's protecting against potential buffer overflows, out-of-bounds reads or writes, or any other memory corruption vulnerabilities. Specifically at line 7528, I need to see what's happening at that exact point; is there a crucial check there, or perhaps the start of an important loop or conditional that performs those checks? This is where the core of my analysis will focus. I'm looking for the mechanism that ensures the integrity of memory operations. |
| 34/3 | 2026/09/29 21:22 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/verifier.c",
"FirstLine": 7528,
"LineCount": 50
}Results: {
"Contents": "7528:\tstatic int check_helper_mem_access(struct bpf_verifier_env *env, struct bpf_reg_state *reg,\n7529:\t\t\t\t\t argno_t argno, int access_size,\n7530:\t\t\t\t\t enum bpf_access_type access_type, bool zero_size_allowed,\n7531:\t\t\t\t\t struct bpf_call_arg_meta *meta, bool *known_memory)\n7532:\t{\n7533:\t\tstruct bpf_reg_state *regs = cur_regs(env);\n7534:\t\tu32 *max_access;\n7535:\t\n7536:\t\tif (known_memory)\n7537:\t\t\t*known_memory = true;\n7538:\t\n7539:\t\tswitch (base_type(reg-\u003etype)) {\n7540:\t\tcase PTR_TO_PACKET:\n7541:\t\tcase PTR_TO_PACKET_META:\n7542:\t\t\tif (!may_access_direct_pkt_data(env, meta, access_type)) {\n7543:\t\t\t\tverbose(env, \"function access to the packet is not allowed\\n\");\n7544:\t\t\t\treturn -EACCES;\n7545:\t\t\t}\n7546:\t\t\treturn check_packet_access(env, reg, argno, 0, access_size,\n7547:\t\t\t\t\t\t zero_size_allowed);\n7548:\t\tcase PTR_TO_MAP_KEY:\n7549:\t\t\tif (access_type == BPF_WRITE) {\n7550:\t\t\t\tverbose(env, \"%s cannot write into %s\\n\",\n7551:\t\t\t\t\treg_arg_name(env, argno), reg_type_str(env, reg-\u003etype));\n7552:\t\t\t\treturn -EACCES;\n7553:\t\t\t}\n7554:\t\t\treturn check_mem_region_access(env, reg, argno, 0, access_size,\n7555:\t\t\t\t\t\t reg-\u003emap_ptr-\u003ekey_size, false);\n7556:\t\tcase PTR_TO_MAP_VALUE:\n7557:\t\t\tif (check_map_access_type(env, reg, 0, access_size, access_type))\n7558:\t\t\t\treturn -EACCES;\n7559:\t\t\treturn check_map_access(env, reg, argno, 0, access_size,\n7560:\t\t\t\t\t\tzero_size_allowed, ACCESS_HELPER);\n7561:\t\tcase PTR_TO_MEM:\n7562:\t\t\tif (type_is_rdonly_mem(reg-\u003etype)) {\n7563:\t\t\t\tif (access_type == BPF_WRITE) {\n7564:\t\t\t\t\tverbose(env, \"%s cannot write into %s\\n\",\n7565:\t\t\t\t\t\treg_arg_name(env, argno), reg_type_str(env, reg-\u003etype));\n7566:\t\t\t\t\treturn -EACCES;\n7567:\t\t\t\t}\n7568:\t\t\t}\n7569:\t\t\treturn check_mem_region_access(env, reg, argno, 0,\n7570:\t\t\t\t\t\t access_size, reg-\u003emem_size,\n7571:\t\t\t\t\t\t zero_size_allowed);\n7572:\t\tcase PTR_TO_BUF:\n7573:\t\t\tif (type_is_rdonly_mem(reg-\u003etype)) {\n7574:\t\t\t\tif (access_type == BPF_WRITE) {\n7575:\t\t\t\t\tverbose(env, \"%s cannot write into %s\\n\",\n7576:\t\t\t\t\t\treg_arg_name(env, argno), reg_type_str(env, reg-\u003etype));\n7577:\t\t\t\t\treturn -EACCES;\n"
} |
| 35/3 | 2026/09/29 21:22 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 20376 output: 37 thoughts: 25 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person: **Diving into the Stack Pointer Access** Alright, I'm thinking we need to drill down deeper into the `check_helper_mem_access` function, specifically how it's dealing with `PTR_TO_STACK`. We know memory access checks are critical, and I want to understand exactly how the code is validating accesses related to stack pointers. I'm focusing on that particular flag because stack corruption is a classic exploit vector, so I'm honing in on the details of that handling. Understanding that portion of the function is going to give me a solid grasp of whether the existing protection mechanisms are sufficient or if we have a potential vulnerability. It's time to dig into the logic and see what nuances are present in that part of the code! |
| 36/3 | 2026/09/29 21:22 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/verifier.c",
"FirstLine": 7578,
"LineCount": 50
}Results: {
"Contents": "7578:\t\t\t\t}\n7579:\t\n7580:\t\t\t\tmax_access = \u0026env-\u003eprog-\u003eaux-\u003emax_rdonly_access;\n7581:\t\t\t} else {\n7582:\t\t\t\tmax_access = \u0026env-\u003eprog-\u003eaux-\u003emax_rdwr_access;\n7583:\t\t\t}\n7584:\t\t\treturn check_buffer_access(env, reg, argno, 0,\n7585:\t\t\t\t\t\t access_size, zero_size_allowed,\n7586:\t\t\t\t\t\t max_access);\n7587:\t\tcase PTR_TO_STACK:\n7588:\t\t\treturn check_stack_range_initialized(\n7589:\t\t\t\t\tenv, reg,\n7590:\t\t\t\t\targno, 0, access_size,\n7591:\t\t\t\t\tzero_size_allowed, access_type, meta);\n7592:\t\tcase PTR_TO_BTF_ID:\n7593:\t\t\treturn check_ptr_to_btf_access(env, regs, reg, argno, 0,\n7594:\t\t\t\t\t\t access_size, access_type, -1);\n7595:\t\tcase PTR_TO_CTX:\n7596:\t\t\t/* Only permit reading or writing syscall context using helper calls. */\n7597:\t\t\tif (is_var_ctx_off_allowed(env-\u003eprog)) {\n7598:\t\t\t\tint err = check_mem_region_access(env, reg, argno, 0, access_size, U16_MAX,\n7599:\t\t\t\t\t\t\t\t zero_size_allowed);\n7600:\t\t\t\tif (err)\n7601:\t\t\t\t\treturn err;\n7602:\t\t\t\tif (env-\u003eprog-\u003eaux-\u003emax_ctx_offset \u003c reg_umax(reg) + access_size)\n7603:\t\t\t\t\tenv-\u003eprog-\u003eaux-\u003emax_ctx_offset = reg_umax(reg) + access_size;\n7604:\t\t\t\treturn 0;\n7605:\t\t\t}\n7606:\t\t\tfallthrough;\n7607:\t\tdefault: /* scalar_value or invalid ptr */\n7608:\t\t\t/* Allow zero-byte read from NULL, regardless of pointer type */\n7609:\t\t\tif (zero_size_allowed \u0026\u0026 access_size == 0 \u0026\u0026\n7610:\t\t\t bpf_register_is_null(reg))\n7611:\t\t\t\treturn 0;\n7612:\t\t\tif (known_memory \u0026\u0026 base_type(reg-\u003etype) != PTR_TO_CTX)\n7613:\t\t\t\t*known_memory = false;\n7614:\t\n7615:\t\t\tverbose(env, \"%s type=%s \", reg_arg_name(env, argno),\n7616:\t\t\t\treg_type_str(env, reg-\u003etype));\n7617:\t\t\tverbose(env, \"expected=%s\\n\", reg_type_str(env, PTR_TO_STACK));\n7618:\t\t\treturn -EACCES;\n7619:\t\t}\n7620:\t}\n7621:\t\n7622:\tenum bpf_mem_size_failure {\n7623:\t\tBPF_MEM_SIZE_FAIL_NONE,\n7624:\t\tBPF_MEM_SIZE_FAIL_MEMORY,\n7625:\t\tBPF_MEM_SIZE_FAIL_SIZE,\n7626:\t};\n7627:\t\n"
} |
| 37/3 | 2026/09/29 21:22 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21479 output: 37 thoughts: 13 Thoughts: Okay, here's my summary, tailored for an expert audience, as if I'm thinking these things myself: **Checking Stack Range Initialization** Right, let's dive in. First, I need to verify that `check_stack_range_initialized` is functioning as expected. It's a critical function, potentially a performance bottleneck, and any errors here can lead to a cascade of difficult-to-debug memory issues. I want to make sure the assumptions built into this function are valid and that it's correctly identifying and handling uninitialized stack regions, or, conversely, properly identifying regions that *are* initialized. I'll need to think about the various scenarios it has to handle. I'm wondering if there are any subtle edge cases in stack unwinding, context switching, or interrupt handling that this function might not be covering. Are there any known issues with the underlying memory management or compiler that could impact this? Okay, time to dig in and review the code. Let's see if the logic holds up under scrutiny, considering potential race conditions or concurrency issues if applicable. |
| 38/3 | 2026/09/29 21:22 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/verifier.c",
"FirstLine": 7396,
"LineCount": 60
}Results: {
"Contents": "7396:\tstatic int check_stack_range_initialized(\n7397:\t\t\tstruct bpf_verifier_env *env, struct bpf_reg_state *reg, argno_t argno, int off,\n7398:\t\t\tint access_size, bool zero_size_allowed,\n7399:\t\t\tenum bpf_access_type type, struct bpf_call_arg_meta *meta)\n7400:\t{\n7401:\t\tstruct bpf_func_state *state = bpf_func(env, reg);\n7402:\t\tint err, min_off, max_off, i, j, slot, spi;\n7403:\t\t/* Some accesses can write anything into the stack, others are\n7404:\t\t * read-only.\n7405:\t\t */\n7406:\t\tbool clobber = type == BPF_WRITE;\n7407:\t\t/*\n7408:\t\t * Negative access_size signals global subprog arg check where\n7409:\t\t * STACK_POISON slots are acceptable. static stack liveness\n7410:\t\t * might have determined that subprog doesn't read them,\n7411:\t\t * but BTF based global subprog validation isn't accurate enough.\n7412:\t\t */\n7413:\t\tbool allow_poison = access_size \u003c 0 || clobber;\n7414:\t\tu32 arg_slot = arg_slot_from_argno(argno);\n7415:\t\tbool uninit = clobber \u0026\u0026 meta \u0026\u0026 arg_slot \u003c MAX_BPF_FUNC_ARGS \u0026\u0026\n7416:\t\t\t (meta-\u003earg_raw_mem.mask \u0026 BIT(arg_slot));\n7417:\t\tbool raw_mode = uninit \u0026\u0026 env-\u003eallow_uninit_stack \u0026\u0026\n7418:\t\t\t\t!(meta-\u003earg_raw_mem.var_size_mask \u0026 BIT(arg_slot));\n7419:\t\n7420:\t\taccess_size = abs(access_size);\n7421:\t\n7422:\t\tif (access_size == 0 \u0026\u0026 !zero_size_allowed) {\n7423:\t\t\tverbose(env, \"invalid zero-sized read\\n\");\n7424:\t\t\treturn -EACCES;\n7425:\t\t}\n7426:\t\n7427:\t\terr = check_stack_access_within_bounds(env, reg, argno, off, access_size, type);\n7428:\t\tif (err)\n7429:\t\t\treturn err;\n7430:\t\n7431:\t\tif (tnum_is_const(reg-\u003evar_off)) {\n7432:\t\t\tmin_off = max_off = reg-\u003evar_off.value + off;\n7433:\t\t} else {\n7434:\t\t\t/* Variable offset is prohibited for unprivileged mode for\n7435:\t\t\t * simplicity since it requires corresponding support in\n7436:\t\t\t * Spectre masking for stack ALU.\n7437:\t\t\t * See also retrieve_ptr_limit().\n7438:\t\t\t */\n7439:\t\t\tif (!env-\u003ebypass_spec_v1) {\n7440:\t\t\t\tchar tn_buf[48];\n7441:\t\n7442:\t\t\t\ttnum_strn(tn_buf, sizeof(tn_buf), reg-\u003evar_off);\n7443:\t\t\t\tverbose(env, \"%s variable offset stack access prohibited for !root, var_off=%s\\n\",\n7444:\t\t\t\t\treg_arg_name(env, argno), tn_buf);\n7445:\t\t\t\treturn -EACCES;\n7446:\t\t\t}\n7447:\t\t\t/*\n7448:\t\t\t * The call may touch any byte in the possible range, but does not\n7449:\t\t\t * definitely initialize all of it. Fall back to ordinary stack checks.\n7450:\t\t\t */\n7451:\t\t\traw_mode = false;\n7452:\t\n7453:\t\t\tmin_off = reg_smin(reg) + off;\n7454:\t\t\tmax_off = reg_smax(reg) + off;\n7455:\t\t}\n"
} |
| 39/3 | 2026/09/29 21:22 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 22807 output: 37 thoughts: 472 Thoughts: **Analyzing the BPF Subprog Argument Verification Refactor** Okay, let's break this down. In `check_stack_range_initialized`, I'm seeing a situation where `Negative access_size` indicates a global subprogram argument check. This is where those `STACK_POISON` slots are, and they're acceptable. The old static stack liveness analysis *might* have deemed that the subprogram doesn't read them. But, BTF-based global subprogram validation isn't accurate enough for a thorough check. The older version had a peculiar conditional: `size = (!meta && base_type(reg->type) == PTR_TO_STACK) ? -(int)mem_size : mem_size;`. Why the `!meta` check specifically? Ah, I remember now. Helper calls used to pass `meta != NULL`, kfunc calls also had `meta != NULL`, but `btf_check_func_arg_match` called `check_mem_reg(..., NULL, NULL)`! So `meta` would be NULL only for those pesky subprogram calls. Now, this patch changes `btf_check_func_arg_match` to use `meta`, but `meta->btf && !meta->func_id` is true for subprograms—specifically, `is_subprog(meta)`. It looks like `is_subprog(meta)` is preserving the same logic: subprogram calls will still get `size = -(int)mem_size`, while helpers and kfuncs will receive `size = mem_size`. Clever. Alright, let's look at the patch more comprehensively. Overall, it appears the patch is refactoring BPF subprogram argument verification. It's aiming to reuse the existing `check_func_args` and `check_func_arg` machinery that's used for BPF helper functions and kfuncs. Rather than having a separate, duplicated verification loop in `btf_check_func_arg_match`, we're trying to unify the process. Let me examine each area this patch touches: 1. `include/linux/bpf_verifier.h`: I see they added `struct bpf_func_proto bpf_subprog_scratch;` to `struct bpf_verifier_env`. Why *there*? Hmm, because `struct bpf_verifier_env` is allocated using either `kvzalloc` or `kzalloc` when the verifier runs. I should check where else `struct bpf_verifier_env` is allocated. Let me trace that down. |
| 40/3 | 2026/09/29 21:22 | tool | grepper |
0mError:no matches Args: {
"Expression": "kzalloc.*sizeof\\(.*bpf_verifier_env",
"PathPrefix": "kernel/bpf/"
}Results: {
"error": "no matches"
} |
| 41/3 | 2026/09/29 21:22 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23882 output: 33 thoughts: 17 Thoughts: Here's a summary of my thought process: **Hunting Down That `sizeof(struct bpf_verifier_env)` Allocation** Okay, so I need to track down where the memory for `sizeof(struct bpf_verifier_env)` is being allocated. This is a critical piece of information when dealing with BPF verifier internals, and understanding its allocation strategy is key to efficient debugging and optimization. I'll need to know where this struct is used, which calls allocate the memory that it is stored in, and how its size affects overall memory consumption within the BPF subsystem. I'm going to follow the code and understand how it's used with particular attention to how the allocator is used. This is likely part of understanding memory allocation patterns and potential bottlenecks within the BPF verifier. |
| 42/3 | 2026/09/29 21:23 | tool | grepper |
0mArgs:{
"Expression": "bpf_verifier_env.*=",
"PathPrefix": "kernel/bpf/"
}Results: {
"Output": "kernel/bpf/backtrack.c=124=static inline void bt_reset(struct backtrack_state *bt)\nkernel/bpf/backtrack.c-125-{\nkernel/bpf/backtrack.c:126:\tstruct bpf_verifier_env *env = bt-\u003eenv;\nkernel/bpf/backtrack.c-127-\n--\nkernel/bpf/verifier.c=320=__printf(2, 3) static void verbose(void *private_data, const char *fmt, ...)\nkernel/bpf/verifier.c-321-{\nkernel/bpf/verifier.c:322:\tstruct bpf_verifier_env *env = private_data;\nkernel/bpf/verifier.c-323-\tva_list args;\n"
} |
| 43/3 | 2026/09/29 21:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24303 output: 31 thoughts: 10 Thoughts: Okay, here's my attempt at summarizing that thought process, tailored for an expert audience, and delivered in the first person: **Finding `bpf_check`** Alright, let's get down to brass tacks. I need to find the definition or usage of `bpf_check`. My mental model suggests it's likely a function, likely involved in BPF (Berkeley Packet Filter) operations. Given my experience, I have a few initial avenues to pursue. I'll need to think about my tooling, and the likely contexts in which I'd expect to find this function defined. Is it in kernel source? A specific library like `libbpf`? Or potentially in some custom tooling? I need to think about what I *know* about `bpf_check` - any related function names, common patterns, or even potential error messages related to this function would jump-start my search. I also know that depending on the implementation, the function might be deprecated, renamed, or replaced by another function that provides more options, so I'll need to keep this in mind as I search. This calls for a methodical approach: start with the obvious, then dig deeper if needed. |
| 44/3 | 2026/09/29 21:23 | tool | grepper |
0mArgs:{
"Expression": "int bpf_check\\(",
"PathPrefix": "kernel/bpf/"
}Results: {
"Output": "kernel/bpf/verifier.c=22351=static bool bpf_prog_reenters_datapath(const struct bpf_prog *prog)\n--\nkernel/bpf/verifier.c-22361-\nkernel/bpf/verifier.c:22362:int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr,\nkernel/bpf/verifier.c-22363-\t struct bpf_log_attr *attr_log)\n"
} |
| 45/3 | 2026/09/29 21:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24739 output: 38 thoughts: 13 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary: **Initial Examination of `bpf_check`** Alright, let's dive right in. My first thought is to get a handle on the entry point. I want to understand how we're initiating the BPF verification process. Seeing the beginning of the `bpf_check` function gives me a crucial starting point. What's the initial call path? What inputs are we dealing with right off the bat? Are we validating a program, a map definition, or both? Understanding this will be critical to grasping the overarching flow and identifying potential bottlenecks or areas of interest for deeper analysis. I'll need to pay close attention to the arguments passed in – that's where the real story begins. Let's see what's what. |
| 46/3 | 2026/09/29 21:23 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/verifier.c",
"FirstLine": 22362,
"LineCount": 25
}Results: {
"Contents": "22362:\tint bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr,\n22363:\t\t struct bpf_log_attr *attr_log)\n22364:\t{\n22365:\t\tu64 start_time = ktime_get_ns();\n22366:\t\tstruct bpf_verifier_env *env;\n22367:\t\tint i, len, ret = -EINVAL, err;\n22368:\t\tbool is_priv;\n22369:\t\n22370:\t\tBTF_TYPE_EMIT(enum bpf_features);\n22371:\t\n22372:\t\t/* no program is valid */\n22373:\t\tif (ARRAY_SIZE(bpf_verifier_ops) == 0)\n22374:\t\t\treturn -EINVAL;\n22375:\t\n22376:\t\t/* 'struct bpf_verifier_env' can be global, but since it's not small,\n22377:\t\t * allocate/free it every time bpf_check() is called\n22378:\t\t */\n22379:\t\tenv = kvzalloc_obj(struct bpf_verifier_env, GFP_KERNEL_ACCOUNT);\n22380:\t\tif (!env)\n22381:\t\t\treturn -ENOMEM;\n22382:\t\n22383:\t\tenv-\u003ebt.env = env;\n22384:\t\tenv-\u003eprog = *prog;\n22385:\t\tenv-\u003eops = bpf_verifier_ops[env-\u003eprog-\u003etype];\n22386:\t\tenv-\u003estack_limit = bpf_prog_stack_limit(env-\u003eprog);\n"
} |
| 47/3 | 2026/09/29 21:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25433 output: 37 thoughts: 292 Thoughts: **Analyzing Potential Uninitialized Variable Usage in BPF Verification** Okay, so I'm digging into this BPF verification code. My initial concern is whether there are any potential issues with uninitialized variables. Specifically, I see that the `env` struct is allocated with `kvzalloc_obj`, which, if I understand correctly, should zero-initialize it using `GFP_KERNEL_ACCOUNT`. Excellent. Further down the rabbit hole, in the `gen_subprog_arg_proto` function, I notice `memset(proto, 0, sizeof(*proto))`. So, the `env->bpf_subprog_scratch` field should definitely be cleared before being used, which is good. Now, let's turn our attention to the `meta` struct. Specifically, looking at `btf_check_func_arg_match`, `meta` is initialized with `memset(&meta, 0, sizeof(meta))`. That's standard and good practice; we're initializing `meta` to zero before its use. My main focus now shifts to checking the `check_func_arg` and `check_func_args` functions and their callers. I need to make sure that no other helper functions accessed any uninitialized variables. I'll inspect the callers of `check_func_args` and `check_func_arg`, paying close attention to any place where a new struct or value is created and subsequently used without being properly initialized. Specifically, I'm going to focus on `check_func_args` around line 9986. That should give me a good idea of what's going on, and whether any potential issues may be present. |
| 48/3 | 2026/09/29 21:23 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/verifier.c",
"FirstLine": 9986,
"LineCount": 80
}Results: {
"Contents": "9986:\t\n9987:\t\tif (regno \u003e= 0) {\n9988:\t\t\terr = check_reg_arg(env, regno, SRC_OP);\n9989:\t\t\tif (err)\n9990:\t\t\t\treturn err;\n9991:\t\t}\n9992:\t\n9993:\t\treturn check_reg_type(env, reg, argno, ARG_SCALAR, meta);\n9994:\t}\n9995:\t\n9996:\tstatic int check_func_args(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,\n9997:\t\t\t\t int insn_idx)\n9998:\t{\n9999:\t\tu32 slot = 0, prev_slot = 0, proto_slots, nslots;\n10000:\t\tstruct bpf_func_state *caller = cur_func(env);\n10001:\t\tconst struct btf_param *args = NULL;\n10002:\t\tu32 arg, nargs = MAX_BPF_FUNC_REG_ARGS;\n10003:\t\tint err;\n10004:\t\n10005:\t\tif (meta-\u003ebtf) {\n10006:\t\t\targs = btf_params(meta-\u003efunc_proto);\n10007:\t\t\tnargs = btf_type_vlen(meta-\u003efunc_proto);\n10008:\t\t}\n10009:\t\n10010:\t\t/*\n10011:\t\t * A by-value argument of more than one eightbyte takes a slot per\n10012:\t\t * eightbyte, so the slots a call occupies are no longer its parameter\n10013:\t\t * count. Only a proto whose parameters take a slot each can name the\n10014:\t\t * argument a stack slot belongs to.\n10015:\t\t */\n10016:\t\tproto_slots = meta-\u003ebtf ? btf_proto_slots(meta-\u003ebtf, meta-\u003efunc_proto) : nargs;\n10017:\t\n10018:\t\tif (proto_slots \u003e MAX_BPF_FUNC_REG_ARGS) {\n10019:\t\t\terr = check_outgoing_stack_args(env, caller, proto_slots, meta-\u003efunc_name,\n10020:\t\t\t\t\t\t\tmeta-\u003ebtf, proto_slots == nargs ? args : NULL);\n10021:\t\t\tif (err)\n10022:\t\t\t\treturn err;\n10023:\t\t}\n10024:\t\n10025:\t\tfor (arg = 0; arg \u003c nargs; arg++, prev_slot = slot, slot += nslots) {\n10026:\t\t\tconst struct btf_type *t;\n10027:\t\t\tu32 k;\n10028:\t\n10029:\t\t\tnslots = 1;\n10030:\t\t\tif (args) {\n10031:\t\t\t\tt = btf_type_skip_modifiers(meta-\u003ebtf, args[arg].type, NULL);\n10032:\t\t\t\tnslots = btf_arg_slots(t);\n10033:\t\t\t}\n10034:\t\n10035:\t\t\tif (meta-\u003efn-\u003earg_type[arg] == ARG_UNUSED)\n10036:\t\t\t\tbreak;\n10037:\t\t\terr = check_func_arg(env, arg, slot, prev_slot, meta, insn_idx);\n10038:\t\t\tif (err)\n10039:\t\t\t\treturn err;\n10040:\t\n10041:\t\t\t/*\n10042:\t\t\t * check_func_arg() took the first slot. A parameter of more\n10043:\t\t\t * than one eightbyte is always a scalar, so every slot it\n10044:\t\t\t * takes beyond the first holds one too.\n10045:\t\t\t */\n10046:\t\t\tfor (k = 1; k \u003c nslots; k++) {\n10047:\t\t\t\terr = check_arg_extra_slot(env, caller, slot + k, meta);\n10048:\t\t\t\tif (err)\n10049:\t\t\t\t\treturn err;\n10050:\t\t\t}\n10051:\t\t}\n10052:\t\n10053:\t\treturn 0;\n10054:\t}\n10055:\t\n10056:\tstatic int mark_raw_stack(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,\n10057:\t\t\t\t int insn_idx)\n10058:\t{\n10059:\t\tstruct bpf_func_state *caller = cur_func(env);\n10060:\t\tu32 slot;\n10061:\t\tint i, err;\n10062:\t\n10063:\t\t/*\n10064:\t\t * Validate every argument before initializing outputs: an input argument\n10065:\t\t * may alias an output buffer. Use the normal stack-write checks to discard\n"
} |
| 49/3 | 2026/09/29 21:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27429 output: 37 thoughts: 108 Thoughts: Here's my analysis of that snippet, focusing on the verification process: **Diving into Argument Verification** Okay, so I'm looking at how arguments are being validated within the BPF verifier. Specifically, I'm examining the `check_func_args` function. My initial focus is on this loop structure within `check_func_args`: `for (arg = 0; arg < nargs; arg++, prev_slot = slot, slot += nslots)` I see that it's iterating through the function's arguments. The `arg` variable represents the current argument index. `nargs` is the total count of arguments for this function. Critically, I notice how `slot` and `prev_slot` are being managed. `slot` likely represents the current memory slot being checked for the argument, and `prev_slot` stores the previous slot's state. `slot` is then incremented by `nslots`, which I'll have to investigate further to understand what value `nslots` actually contains. Crucially, in each iteration, we call the `check_func_arg` function. I recognize that as the core of the validation logic for an individual argument. Now, I want to drill down into the specifics of *that* function. I need to understand what that function does to ensure each argument is valid. It's time to inspect the code more closely. I'm now going to turn my attention to lines 9360-9445 of `kernel/bpf/verifier.c`. That's where the real detail lies. This is where I'll see how the arguments are checked. |
| 50/3 | 2026/09/29 21:23 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/verifier.c",
"FirstLine": 9360,
"LineCount": 80
}Results: {
"Contents": "9360:\t\treturn 0;\n9361:\t}\n9362:\t\n9363:\t/*\n9364:\t * MEM_WRITE alone denotes an input/output buffer. MEM_UNINIT marks an output\n9365:\t * whose incoming contents are not read.\n9366:\t */\n9367:\tstatic enum bpf_access_type func_arg_access_type(enum bpf_arg_type arg_type)\n9368:\t{\n9369:\t\tif (!(arg_type \u0026 MEM_WRITE))\n9370:\t\t\treturn BPF_READ;\n9371:\t\tif (arg_type \u0026 MEM_UNINIT)\n9372:\t\t\treturn BPF_WRITE;\n9373:\t\treturn BPF_READ | BPF_WRITE;\n9374:\t}\n9375:\t\n9376:\tstatic int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 prev_slot,\n9377:\t\t\t\t struct bpf_call_arg_meta *meta,\n9378:\t\t\t\t int insn_idx)\n9379:\t{\n9380:\t\tconst struct btf_param *btf_arg = is_kfunc(meta) ?\n9381:\t\t\t\t\t\t \u0026btf_params(meta-\u003efunc_proto)[arg] : NULL;\n9382:\t\tconst struct bpf_func_proto *fn = meta-\u003efn;\n9383:\t\tstruct bpf_func_state *caller = cur_func(env);\n9384:\t\tstruct bpf_reg_state *regs = cur_regs(env);\n9385:\t\targno_t argno = argno_from_arg(slot + 1);\n9386:\t\tstruct bpf_reg_state *reg = get_func_arg_reg(caller, regs, slot);\n9387:\t\tenum bpf_arg_type arg_type = fn-\u003earg_type[arg];\n9388:\t\tint regno = reg_from_argno(argno);\n9389:\t\tu32 arg_size = arg_type \u0026 MEM_FIXED_SIZE ? fn-\u003earg_size[arg] : 0;\n9390:\t\tu32 key_size;\n9391:\t\tint err = 0;\n9392:\t\n9393:\t\tif (arg_type == ARG_PTR_TO_PROG_AUX) {\n9394:\t\t\tcur_aux(env)-\u003earg_prog = regno;\n9395:\t\t\treturn 0;\n9396:\t\t}\n9397:\t\n9398:\t\tif (arg_type == ARG_IGNORE)\n9399:\t\t\treturn 0;\n9400:\t\n9401:\t\tif (regno \u003e= 0) {\n9402:\t\t\terr = check_reg_arg(env, regno, SRC_OP);\n9403:\t\t\tif (err)\n9404:\t\t\t\treturn err;\n9405:\t\t}\n9406:\t\n9407:\t\t/* Preserve the legacy helper behavior for privileged pointer leaks. */\n9408:\t\tif (arg_type == ARG_ANYTHING) {\n9409:\t\t\tif (__is_pointer_value(env-\u003eallow_ptr_leaks, reg)) {\n9410:\t\t\t\tverbose(env, \"%s leaks addr into helper function\\n\",\n9411:\t\t\t\t\treg_arg_name(env, argno));\n9412:\t\t\t\treturn -EACCES;\n9413:\t\t\t}\n9414:\t\t\treturn 0;\n9415:\t\t}\n9416:\t\n9417:\t\terr = resolve_func_arg_type(env, reg, arg, argno, meta, \u0026arg_type, \u0026arg_size);\n9418:\t\tif (err)\n9419:\t\t\treturn err;\n9420:\t\n9421:\t\tif (arg_type_is_raw_mem(arg_type))\n9422:\t\t\tmeta-\u003earg_raw_mem.mask |= BIT(slot);\n9423:\t\n9424:\t\tif (bpf_register_is_null(reg) \u0026\u0026 type_may_be_null(arg_type)) {\n9425:\t\t\terr = mark_arg_precision(env, argno);\n9426:\t\t\tif (err)\n9427:\t\t\t\treturn err;\n9428:\t\t\treturn 0;\n9429:\t\t}\n9430:\t\n9431:\t\terr = check_func_arg_nullability(env, reg, arg, argno, arg_type, meta, insn_idx);\n9432:\t\tif (err)\n9433:\t\t\treturn err;\n9434:\t\n9435:\t\terr = check_reg_type(env, reg, argno, arg_type, meta);\n9436:\t\tif (err)\n9437:\t\t\treturn err;\n9438:\t\n9439:\t\terr = check_func_arg_reg_off(env, reg, argno, arg_type);\n"
} |
| 51/3 | 2026/09/29 21:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29239 output: 34 thoughts: 549 Thoughts: **Analyzing Argument Handling in `gen_subprog_arg_proto`** Okay, let's break this down. I'm focusing on `gen_subprog_arg_proto`. The goal here is clearly to translate information about a BPF subprogram's arguments into a usable `bpf_func_proto` structure. I see the function iterates through the arguments defined in the `func_proto` BTF type. I'm particularly interested in how the argument types are determined and processed. I see a loop iterating through the function prototype arguments using `btf_type_vlen(func_proto)`. Inside the loop, it accesses `sub->args[slot]` where `slot` seems to increment throughout the loop, but it is not immediately clear how it is actually indexed. It seems like it's taking an argument and updating the `arg_type` in the `proto` struct. There's some special handling for `PTR_UNTRUSTED` arguments, which makes sense from a security perspective – marking them as essentially ignored to prevent uncontrolled memory access, and some other special cases for different argument types (e.g., arena pointers, memory pointers, and BTF IDs). I notice that if the argument is a pointer to memory, the `mem_size` member from `sub->args` is being used. And it increments `slot` based on `btf_arg_slots(t)`. Hold on... I need to understand how the `sub->args` array is actually being indexed and populated. The use of `slot` makes me think this is likely how argument structs are parsed, but I don't know this for sure. I need to trace this back to the source where `sub->args` gets filled to understand the exact indexing. I'll need to go to `btf_prepare_func_args` to see where `sub->args` is actually populated. That's where the real logic behind the argument structure is likely to be. I need to see if that relationship is what I think it is. |
| 52/3 | 2026/09/29 21:23 | tool | grepper |
0mArgs:{
"Expression": "btf_prepare_func_args\\(",
"PathPrefix": "kernel/bpf/"
}Results: {
"Output": "kernel/bpf/btf.c=8037=static int btf_check_func_type_match(struct bpf_verifier_log *log,\n--\nkernel/bpf/btf.c-8136-\t\t * Compare names of structs and report an error to the user.\nkernel/bpf/btf.c:8137:\t\t * btf_prepare_func_args() already checked that t2 struct\nkernel/bpf/btf.c:8138:\t\t * is a context type. btf_prepare_func_args() will check\nkernel/bpf/btf.c-8139-\t\t * later that t1 struct is a context type as well.\n--\nkernel/bpf/btf.c=8387=static int btf_check_arg_slots(struct bpf_verifier_log *log, const char *tname,\n--\nkernel/bpf/btf.c-8417- */\nkernel/bpf/btf.c:8418:int btf_prepare_func_args(struct bpf_verifier_env *env, int subprog)\nkernel/bpf/btf.c-8419-{\n--\nkernel/bpf/verifier.c=10849=static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog, struct btf *btf)\n--\nkernel/bpf/verifier.c-10862-\nkernel/bpf/verifier.c:10863:\tret = btf_prepare_func_args(env, subprog);\nkernel/bpf/verifier.c-10864-\tif (ret) {\n--\nkernel/bpf/verifier.c=20607=static int do_check_common(struct bpf_verifier_env *env, int subprog, bool is_sleepable)\n--\nkernel/bpf/verifier.c-20648-\t\t\tverbose(env, \"Validating %s() func#%d...\\n\", sub_name, subprog);\nkernel/bpf/verifier.c:20649:\t\tret = btf_prepare_func_args(env, subprog);\nkernel/bpf/verifier.c-20650-\t\tif (ret)\n--\nkernel/bpf/verifier.c-20729-\t\tif (env-\u003eprog-\u003eaux-\u003efunc_info_aux) {\nkernel/bpf/verifier.c:20730:\t\t\tret = btf_prepare_func_args(env, 0);\nkernel/bpf/verifier.c-20731-\t\t\tif (ret || sub-\u003earg_slot_cnt != 1 ||\n"
} |
| 53/3 | 2026/09/29 21:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30927 output: 38 thoughts: 26 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Diving into `btf_prepare_func_args`** Alright, let's take a closer look at `btf_prepare_func_args`. Specifically, I want to refresh my memory on its implementation within `kernel/bpf/btf.c`. I know this function is critical for how we handle function arguments when dealing with BTF data, and it's a key part of the ABI stability story. I need to understand this function's nuances. I want to make sure I'm fully aware of how we validate and prepare function arguments within the BPF context and how it interacts with the type information in BTF. This is an area where subtle bugs can have serious consequences. I'll focus on how `btf_prepare_func_args` handles various argument types, including pointers, structs, and unions, and how it deals with potential type mismatches or inconsistencies between the BTF metadata and the actual BPF program. I'll want to review its interaction with other BTF-related functions, and make sure I understand the checks done. |
| 54/3 | 2026/09/29 21:23 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/btf.c",
"FirstLine": 8418,
"LineCount": 80
}Results: {
"Contents": "8418:\tint btf_prepare_func_args(struct bpf_verifier_env *env, int subprog)\n8419:\t{\n8420:\t\tbool is_global = subprog_aux(env, subprog)-\u003elinkage == BTF_FUNC_GLOBAL;\n8421:\t\tstruct bpf_subprog_info *sub = subprog_info(env, subprog);\n8422:\t\tstruct bpf_verifier_log *log = \u0026env-\u003elog;\n8423:\t\tstruct bpf_prog *prog = env-\u003eprog;\n8424:\t\tenum bpf_prog_type prog_type = prog-\u003etype;\n8425:\t\tstruct btf *btf = prog-\u003eaux-\u003ebtf;\n8426:\t\tconst struct btf_param *args;\n8427:\t\tconst struct btf_type *t, *ref_t, *fn_t;\n8428:\t\tint err;\n8429:\t\tu32 i, slots_used, nargs, btf_id;\n8430:\t\tconst char *tname;\n8431:\t\n8432:\t\tif (sub-\u003eargs_cached)\n8433:\t\t\treturn 0;\n8434:\t\n8435:\t\tif (!prog-\u003eaux-\u003efunc_info) {\n8436:\t\t\tverifier_bug(env, \"func_info undefined\");\n8437:\t\t\treturn -EFAULT;\n8438:\t\t}\n8439:\t\n8440:\t\tbtf_id = prog-\u003eaux-\u003efunc_info[subprog].type_id;\n8441:\t\tif (!btf_id) {\n8442:\t\t\tif (!is_global) /* not fatal for static funcs */\n8443:\t\t\t\treturn -EINVAL;\n8444:\t\t\tbpf_log(log, \"Global functions need valid BTF\\n\");\n8445:\t\t\treturn -EFAULT;\n8446:\t\t}\n8447:\t\n8448:\t\tfn_t = btf_type_by_id(btf, btf_id);\n8449:\t\tif (!fn_t || !btf_type_is_func(fn_t)) {\n8450:\t\t\t/* These checks were already done by the verifier while loading\n8451:\t\t\t * struct bpf_func_info\n8452:\t\t\t */\n8453:\t\t\tbpf_log(log, \"BTF of func#%d doesn't point to KIND_FUNC\\n\",\n8454:\t\t\t\tsubprog);\n8455:\t\t\treturn -EFAULT;\n8456:\t\t}\n8457:\t\ttname = btf_name_by_offset(btf, fn_t-\u003ename_off);\n8458:\t\n8459:\t\tif (prog-\u003eaux-\u003efunc_info_aux[subprog].unreliable) {\n8460:\t\t\tverifier_bug(env, \"unreliable BTF for function %s()\", tname);\n8461:\t\t\treturn -EFAULT;\n8462:\t\t}\n8463:\t\tif (prog_type == BPF_PROG_TYPE_EXT)\n8464:\t\t\tprog_type = prog-\u003eaux-\u003edst_prog-\u003etype;\n8465:\t\n8466:\t\tt = btf_type_by_id(btf, fn_t-\u003etype);\n8467:\t\tif (!t || !btf_type_is_func_proto(t)) {\n8468:\t\t\tbpf_log(log, \"Invalid type of function %s()\\n\", tname);\n8469:\t\t\treturn -EFAULT;\n8470:\t\t}\n8471:\t\targs = (const struct btf_param *)(t + 1);\n8472:\t\tnargs = btf_type_vlen(t);\n8473:\t\tsub-\u003earg_slot_cnt = nargs;\n8474:\t\tif (nargs \u003e MAX_BPF_FUNC_ARGS) {\n8475:\t\t\tbpf_log(log, \"kernel supports at most %d parameters, function %s has %d\\n\",\n8476:\t\t\t\tMAX_BPF_FUNC_ARGS, tname, nargs);\n8477:\t\t\treturn -EFAULT;\n8478:\t\t}\n8479:\t\terr = btf_check_arg_slots(log, tname, is_global, nargs, sub);\n8480:\t\tif (err)\n8481:\t\t\treturn err;\n8482:\t\n8483:\t\terr = btf_validate_return_type(env, btf, t, subprog, is_global);\n8484:\t\tif (err) {\n8485:\t\t\tif (is_global) {\n8486:\t\t\t\t/* Only a subprogram may return arena pointers. */\n8487:\t\t\t\tconst char *supported = subprog ?\n8488:\t\t\t\t\t\"void, scalar, arena pointer, or a struct/union of \"\n8489:\t\t\t\t\t\"scalars and arena pointers\" :\n8490:\t\t\t\t\t\"void, scalar, or a scalar-only struct/union\";\n8491:\t\n8492:\t\t\t\tbpf_log(log,\n8493:\t\t\t\t\t\"Global function %s() has unsupported return type. \"\n8494:\t\t\t\t\t\"Only %s up to 16 bytes is supported.\\n\",\n8495:\t\t\t\t\ttname, supported);\n8496:\t\t\t}\n8497:\t\t\treturn err;\n"
} |
| 55/3 | 2026/09/29 21:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32624 output: 38 thoughts: 17 Thoughts: Okay, here's my attempt at summarizing the thought process, speaking as if these were my internal thoughts, assuming the user is an expert. **Diving into `btf_prepare_func_args`** Alright, let's get into the nitty-gritty of `btf_prepare_func_args`. I'm familiar with the overall BTF (Binary Type Format) structure, but this specific function is key in setting up the argument handling. I need to dissect exactly how it's preparing the function's argument list within the BTF context. I suspect it's dealing with the complexities of type encoding, potentially packing and unpacking data, and likely handling various argument types, potentially even including those with complex modifiers or nested structures. I'll need to pay close attention to the data structures it's manipulating, how it's traversing the BTF information, and especially how it resolves any type dependencies to ensure correct argument interpretation. Let's see how it handles things like variable-length arrays or function pointers within the argument list. I'm ready to delve into the code. |
| 56/3 | 2026/09/29 21:23 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/btf.c",
"FirstLine": 8498,
"LineCount": 60
}Results: {
"Contents": "8498:\t\t}\n8499:\t\n8500:\t\t/* Convert BTF function arguments into verifier types.\n8501:\t\t * Only PTR_TO_CTX and SCALAR are supported atm.\n8502:\t\t */\n8503:\t\tfor (i = 0, slots_used = 0; i \u003c nargs; i++) {\n8504:\t\t\tu32 tags = 0;\n8505:\t\n8506:\t\t\tif (slots_used \u003e= MAX_BPF_FUNC_ARGS)\n8507:\t\t\t\tgoto too_many_slots;\n8508:\t\n8509:\t\t\terr = btf_scan_decl_tags(env, btf, fn_t, i, is_global, \u0026tags);\n8510:\t\t\tif (err)\n8511:\t\t\t\treturn err;\n8512:\t\n8513:\t\t\tbtf_scan_type_tags(btf, args[i].type, \u0026tags);\n8514:\t\n8515:\t\t\tt = btf_type_by_id(btf, args[i].type);\n8516:\t\t\twhile (btf_type_is_modifier(t))\n8517:\t\t\t\tt = btf_type_by_id(btf, t-\u003etype);\n8518:\t\t\tif (!btf_type_is_ptr(t))\n8519:\t\t\t\tgoto skip_pointer;\n8520:\t\n8521:\t\t\tif ((tags \u0026 ARG_TAG_CTX) || btf_is_prog_ctx_type(log, btf, t, prog_type, i)) {\n8522:\t\t\t\tif (tags \u0026 ~ARG_TAG_CTX) {\n8523:\t\t\t\t\tbpf_log(log, \"arg#%d has invalid combination of tags\\n\", i);\n8524:\t\t\t\t\treturn -EINVAL;\n8525:\t\t\t\t}\n8526:\t\t\t\tif ((tags \u0026 ARG_TAG_CTX) \u0026\u0026\n8527:\t\t\t\t btf_validate_prog_ctx_type(log, btf, t, i, prog_type,\n8528:\t\t\t\t\t\t\t prog-\u003eexpected_attach_type))\n8529:\t\t\t\t\treturn -EINVAL;\n8530:\t\t\t\tsub-\u003eargs[slots_used++].arg_type = ARG_PTR_TO_CTX;\n8531:\t\t\t\tcontinue;\n8532:\t\t\t}\n8533:\t\t\tif (btf_is_dynptr_ptr(btf, t)) {\n8534:\t\t\t\tif (tags) {\n8535:\t\t\t\t\tbpf_log(log, \"arg#%d has invalid combination of tags\\n\", i);\n8536:\t\t\t\t\treturn -EINVAL;\n8537:\t\t\t\t}\n8538:\t\t\t\tsub-\u003eargs[slots_used++].arg_type = ARG_PTR_TO_DYNPTR;\n8539:\t\t\t\tcontinue;\n8540:\t\t\t}\n8541:\t\t\tif (tags \u0026 ARG_TAG_TRUSTED) {\n8542:\t\t\t\tint kern_type_id;\n8543:\t\n8544:\t\t\t\tif (tags \u0026 ARG_TAG_NONNULL) {\n8545:\t\t\t\t\tbpf_log(log, \"arg#%d has invalid combination of tags\\n\", i);\n8546:\t\t\t\t\treturn -EINVAL;\n8547:\t\t\t\t}\n8548:\t\n8549:\t\t\t\tkern_type_id = btf_get_ptr_to_btf_id(log, i, btf, t);\n8550:\t\t\t\tif (kern_type_id \u003c 0)\n8551:\t\t\t\t\treturn kern_type_id;\n8552:\t\n8553:\t\t\t\tsub-\u003eargs[slots_used].arg_type = ARG_PTR_TO_BTF_ID | PTR_TRUSTED;\n8554:\t\t\t\tif (tags \u0026 ARG_TAG_NULLABLE)\n8555:\t\t\t\t\tsub-\u003eargs[slots_used].arg_type |= PTR_MAYBE_NULL;\n8556:\t\t\t\tsub-\u003eargs[slots_used].btf_id = kern_type_id;\n8557:\t\t\t\tslots_used++;\n"
} |
| 57/3 | 2026/09/29 21:23 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33961 output: 38 thoughts: 355 Thoughts: **Analyzing Argument Handling in BPF Subprograms** Okay, let's break down this argument handling logic. The key observation here is the use of `sub->args[slots_used++]`. I'm immediately noticing that `sub->args` is indexed by *slot*, not the more intuitive *arg* index. This is a crucial distinction. We are talking about BTF data, and the arrangement is obviously influenced by the structure of the data it represents. Now, looking at `gen_subprog_arg_proto`, I see the loop iterating through function arguments, but within it, `slot` is used as an index into `sub->args`. Specifically, it increments `slot` by `btf_arg_slots(t)`. This suggests that a single argument declaration (in the BTF) might span *multiple* slots in `sub->args`. The code then uses this `slot` index to get the arg type, which is then copied into the `proto`. The logic accounts for the fact the the types of arguments themselves may be compound. The key to understanding this arrangement lies in figuring out the mechanism used to determine how many slots a particular argument occupies. This requires investigating how aggregate types are handled, and how `btf_prepare_func_args` interacts with this `slots_used` count. I need to go deeper into `btf_prepare_func_args` and understand how it accounts for pointer arguments, and any aggregate types, as the count advances by 1 for pointers, or for aggregate types. |
| 58/3 | 2026/09/29 21:24 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/btf.c",
"FirstLine": 8558,
"LineCount": 60
}Results: {
"Contents": "8558:\t\t\t\tcontinue;\n8559:\t\t\t}\n8560:\t\t\tif (tags \u0026 ARG_TAG_UNTRUSTED) {\n8561:\t\t\t\tstruct btf *vmlinux_btf;\n8562:\t\t\t\tint kern_type_id;\n8563:\t\n8564:\t\t\t\tif (tags \u0026 ~ARG_TAG_UNTRUSTED) {\n8565:\t\t\t\t\tbpf_log(log, \"arg#%d untrusted cannot be combined with any other tags\\n\", i);\n8566:\t\t\t\t\treturn -EINVAL;\n8567:\t\t\t\t}\n8568:\t\n8569:\t\t\t\tref_t = btf_type_skip_modifiers(btf, t-\u003etype, NULL);\n8570:\t\t\t\tif (btf_type_is_void(ref_t) || btf_type_is_primitive(ref_t)) {\n8571:\t\t\t\t\tsub-\u003eargs[slots_used].arg_type = ARG_PTR_TO_MEM | MEM_RDONLY |\n8572:\t\t\t\t\t\t\t\t\t PTR_UNTRUSTED;\n8573:\t\t\t\t\tsub-\u003eargs[slots_used].mem_size = 0;\n8574:\t\t\t\t\tslots_used++;\n8575:\t\t\t\t\tcontinue;\n8576:\t\t\t\t}\n8577:\t\n8578:\t\t\t\tkern_type_id = btf_get_ptr_to_btf_id(log, i, btf, t);\n8579:\t\t\t\tif (kern_type_id \u003c 0)\n8580:\t\t\t\t\treturn kern_type_id;\n8581:\t\n8582:\t\t\t\tvmlinux_btf = bpf_get_btf_vmlinux();\n8583:\t\t\t\tref_t = btf_type_by_id(vmlinux_btf, kern_type_id);\n8584:\t\t\t\tif (!btf_type_is_struct(ref_t)) {\n8585:\t\t\t\t\ttname = __btf_name_by_offset(vmlinux_btf, t-\u003ename_off);\n8586:\t\t\t\t\tbpf_log(log, \"arg#%d has type %s '%s', but only struct or primitive types are allowed\\n\",\n8587:\t\t\t\t\t\ti, btf_type_str(ref_t), tname);\n8588:\t\t\t\t\treturn -EINVAL;\n8589:\t\t\t\t}\n8590:\t\t\t\tsub-\u003eargs[slots_used].arg_type = ARG_PTR_TO_BTF_ID | PTR_UNTRUSTED;\n8591:\t\t\t\tsub-\u003eargs[slots_used].btf_id = kern_type_id;\n8592:\t\t\t\tslots_used++;\n8593:\t\t\t\tcontinue;\n8594:\t\t\t}\n8595:\t\t\tif (tags \u0026 ARG_TAG_ARENA) {\n8596:\t\t\t\tif (tags \u0026 ~ARG_TAG_ARENA) {\n8597:\t\t\t\t\tbpf_log(log, \"arg#%d arena cannot be combined with any other tags\\n\", i);\n8598:\t\t\t\t\treturn -EINVAL;\n8599:\t\t\t\t}\n8600:\t\t\t\tsub-\u003eargs[slots_used++].arg_type = ARG_PTR_TO_ARENA;\n8601:\t\t\t\tcontinue;\n8602:\t\t\t}\n8603:\t\t\tif (is_global) { /* generic user data pointer */\n8604:\t\t\t\tu32 mem_size;\n8605:\t\n8606:\t\t\t\tif (tags \u0026 ARG_TAG_NULLABLE) {\n8607:\t\t\t\t\tbpf_log(log, \"arg#%d has invalid combination of tags\\n\", i);\n8608:\t\t\t\t\treturn -EINVAL;\n8609:\t\t\t\t}\n8610:\t\n8611:\t\t\t\tt = btf_type_skip_modifiers(btf, t-\u003etype, NULL);\n8612:\t\t\t\tref_t = btf_resolve_size(btf, t, \u0026mem_size);\n8613:\t\t\t\tif (IS_ERR(ref_t)) {\n8614:\t\t\t\t\tbpf_log(log, \"arg#%d reference type('%s %s') size cannot be determined: %ld\\n\",\n8615:\t\t\t\t\t\ti, btf_type_str(t), btf_name_by_offset(btf, t-\u003ename_off),\n8616:\t\t\t\t\t\tPTR_ERR(ref_t));\n8617:\t\t\t\t\treturn -EINVAL;\n"
} |
| 59/3 | 2026/09/29 21:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35800 output: 38 thoughts: 28 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Analyzing `btf_check_arg_slots` in the Context of Function Argument Preparation** Okay, so I'm digging into `btf_prepare_func_args` and I need to figure out the calling context of `btf_check_arg_slots`. I immediately think, I need to trace this specific function. Where exactly is `btf_check_arg_slots` being invoked within that larger function's scope? Is it used in error checking? Is it for optimization? What parts of the arguments are being evaluated with this function? I'm going to determine what's happening at this function's call sites and understand its specific role. My goal is to thoroughly understand how the arguments are prepared in relation to the BTF metadata, and this is a key step in that process. |
| 60/3 | 2026/09/29 21:24 | tool | read-file |
0mArgs:{
"File": "kernel/bpf/btf.c",
"FirstLine": 8385,
"LineCount": 35
}Results: {
"Contents": "8385:\t}\n8386:\t\n8387:\tstatic int btf_check_arg_slots(struct bpf_verifier_log *log, const char *tname,\n8388:\t\t\t\t bool is_global, u32 slot_cnt,\n8389:\t\t\t\t struct bpf_subprog_info *sub)\n8390:\t{\n8391:\t\tif (slot_cnt \u003c= MAX_BPF_FUNC_REG_ARGS)\n8392:\t\t\treturn 0;\n8393:\t\n8394:\t\tif (is_global) {\n8395:\t\t\tbpf_log(log,\n8396:\t\t\t\t\"global function %s() needs %d \u003e %d argument slots, \"\n8397:\t\t\t\t\"stack args not supported\\n\",\n8398:\t\t\t\ttname, slot_cnt, MAX_BPF_FUNC_REG_ARGS);\n8399:\t\t\treturn -EINVAL;\n8400:\t\t}\n8401:\t\tif (!bpf_jit_supports_stack_args()) {\n8402:\t\t\tbpf_log(log, \"JIT does not support function %s() with %d argument slots\\n\",\n8403:\t\t\t\ttname, slot_cnt);\n8404:\t\t\treturn -EFAULT;\n8405:\t\t}\n8406:\t\tsub-\u003estack_arg_cnt = slot_cnt - MAX_BPF_FUNC_REG_ARGS;\n8407:\t\treturn 0;\n8408:\t}\n8409:\t\n8410:\t/* Process BTF of a function to produce high-level expectation of function\n8411:\t * arguments (like ARG_PTR_TO_CTX, or ARG_PTR_TO_MEM, etc). This information\n8412:\t * is cached in subprog info for reuse.\n8413:\t * Returns:\n8414:\t * EFAULT - there is a verifier bug. Abort verification.\n8415:\t * EINVAL - cannot convert BTF.\n8416:\t * 0 - Successfully processed BTF and constructed argument expectations.\n8417:\t */\n8418:\tint btf_prepare_func_args(struct bpf_verifier_env *env, int subprog)\n8419:\t{\n"
} |
| 61/3 | 2026/09/29 21:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36650 output: 31 thoughts: 2787 Thoughts: **KMSAN Needs Assessment for BPF Verifier Patch** Okay, here's the breakdown. We're assessing whether this patch to the BPF verifier requires a KMSAN run. Remember, KMSAN is for catching uninitialized *kernel* memory reads and info leaks that KASAN, LOCKDEP, and the usual suspects *won't* catch. It's a resource hog, so we're only going to use it if absolutely necessary. We need to analyze this patch based on the four conditions: sending kernel structures to userspace, conditional logic using uninitialized variables, allocation of complex data structures with potential uninitialized fields, and logic changes that might expose uninitialized bytes. So, first thing's first. No kernel structures are being *added* or *modified* to be sent to user space directly by this patch. This is verifier logic. That's a check. Now, for conditional logic and uninitialized variables, let's look closely at the new structures and variables. We've got a `struct bpf_verifier_env` which has a `bpf_subprog_scratch` field that's explicitly zeroed with `memset`. The `meta` struct in `btf_check_func_arg_match` is *also* zeroed, and all its fields are explicitly set. *Importantly*, the code *explicitly* initializes the `meta` struct, so no uninitialized variables there. We're good. But let's check further. The patch is changing how we handle subprograms, and those structures are all initialized using `memset`, so it appears safe to assume we don't have this. Now, we looked at how this interacts with the `is_kfunc` logic. We dug through the interactions with `meta` and all the called functions. The focus is to avoid having the verifier code pass around uninitialized memory. Since all potentially uninitialized values are zeroed, we should be fine, and we can move on with that assumption, but we *must* remember that the BPF verifier deals with user-provided BPF programs. BPF programs can read memory, but it's *not* kernel memory, so KMSAN isn't the right tool, and we don't need it. So, let's check our points. No structures sent to user space. No use of uninitialized variables or branching on them (everything is zeroed). No complex allocations, and no bounds check changes exposing uninitialized memory. BPF programs are not kernel memory, and therefore KMSAN will not be useful. This patch looks like it deals with *verifier* logic, which has checks. It's safe to assume that the patch *doesn't* introduce any uninitialized memory issues that only KMSAN could detect. KMSAN is not required. |
| 62/3 | 2026/09/29 21:24 | tool | grepper |
0mArgs:{
"Expression": "\\.func_proto\\b",
"PathPrefix": "kernel/bpf/"
}Results: {
"Output": "kernel/bpf/verifier.c=2868=int bpf_add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, u16 offset)\n--\nkernel/bpf/verifier.c-2970-\tmeta.func_id = kfunc.id;\nkernel/bpf/verifier.c:2971:\tmeta.func_proto = kfunc.proto;\nkernel/bpf/verifier.c-2972-\tmeta.func_name = kfunc.name;\n--\nkernel/bpf/verifier.c=10849=static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog, struct btf *btf)\n--\nkernel/bpf/verifier.c-10880-\tmeta.fn = fn;\nkernel/bpf/verifier.c:10881:\tmeta.func_proto = func_proto;\nkernel/bpf/verifier.c-10882-\n--\nkernel/bpf/verifier.c=14430=s64 bpf_kfunc_stack_access_bytes(struct bpf_verifier_env *env, struct bpf_insn *insn,\n--\nkernel/bpf/verifier.c-14444-\tbtf = meta.btf;\nkernel/bpf/verifier.c:14445:\targs = btf_params(meta.func_proto);\nkernel/bpf/verifier.c:14446:\tnargs = btf_type_vlen(meta.func_proto);\nkernel/bpf/verifier.c-14447-\n--\nkernel/bpf/verifier.c=14678=static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,\n--\nkernel/bpf/verifier.c-14953-\t/* Check return type */\nkernel/bpf/verifier.c:14954:\tt = btf_type_skip_modifiers(desc_btf, meta.func_proto-\u003etype, NULL);\nkernel/bpf/verifier.c-14955-\n--\nkernel/bpf/verifier.c=18707=bool bpf_get_call_summary(struct bpf_verifier_env *env, struct bpf_insn *call,\n--\nkernel/bpf/verifier.c-18737-\t\t\treturn false;\nkernel/bpf/verifier.c:18738:\t\tcs-\u003earg_slot_cnt = btf_proto_slots(meta.btf, meta.func_proto);\nkernel/bpf/verifier.c-18739-\t\tcs-\u003efastcall = meta.kfunc_flags \u0026 KF_FASTCALL;\nkernel/bpf/verifier.c:18740:\t\tcs-\u003eis_void = btf_type_is_void(btf_type_by_id(meta.btf, meta.func_proto-\u003etype));\nkernel/bpf/verifier.c-18741-\t\treturn true;\n"
} |
| 63/3 | 2026/09/29 21:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40836 output: 31 thoughts: 68 Thoughts: Okay, let's break this down. **Investigating Potential Uninitialized Variable Usage in Function Argument Checking** My initial observation is that across the codebase, `meta.func_proto` is initialized before it's used – that's good. And in the specific function `btf_check_func_arg_match`, I see the explicit assignment: `meta.func_proto = func_proto;`. So far, so good, no obvious issues jumping out. But this raises a red flag in my mind: What about calls to helpers? Are there helper functions that *also* use `meta.func_proto`? This is the crucial question. It's time to follow the trail. To be thorough, I need to check every instance where `check_func_args` is called. The goal is to determine if `meta.func_proto` has been properly set in *every* calling context, including within helper functions that might be indirectly involved. Gotta chase down every possible path to ensure the state is always initialized. |
| 64/3 | 2026/09/29 21:24 | tool | grepper |
0mArgs:{
"Expression": "check_func_args\\(",
"PathPrefix": "kernel/bpf/"
}Results: {
"Output": "kernel/bpf/verifier.c=9979=static int check_arg_extra_slot(struct bpf_verifier_env *env, struct bpf_func_state *caller,\n--\nkernel/bpf/verifier.c-9995-\nkernel/bpf/verifier.c:9996:static int check_func_args(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,\nkernel/bpf/verifier.c-9997-\t\t\t int insn_idx)\n--\nkernel/bpf/verifier.c=10849=static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog, struct btf *btf)\n--\nkernel/bpf/verifier.c-10882-\nkernel/bpf/verifier.c:10883:\treturn check_func_args(env, \u0026meta, env-\u003einsn_idx);\nkernel/bpf/verifier.c-10884-}\n--\nkernel/bpf/verifier.c=12055=static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn,\n--\nkernel/bpf/verifier.c-12145-\tmeta.fn = fn;\nkernel/bpf/verifier.c:12146:\terr = check_func_args(env, \u0026meta, insn_idx);\nkernel/bpf/verifier.c-12147-\tif (err)\n--\nkernel/bpf/verifier.c=14678=static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,\n--\nkernel/bpf/verifier.c-14791-\t/* Check the arguments */\nkernel/bpf/verifier.c:14792:\terr = check_func_args(env, \u0026meta, insn_idx);\nkernel/bpf/verifier.c-14793-\tif (err \u003c 0)\n"
} |
| 65/3 | 2026/09/29 21:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41675 output: 32 thoughts: 1030 Thoughts: **Analysis of KMSAN Applicability in Relation to `check_func_args` and Associated Functions** Okay, let's break this down. My main concern here is whether the recent changes introduce any risk of information leaks or uninitialized memory reads, which would necessitate KMSAN (Kernel Memory Sanitizer) consideration. I'm focusing on the modifications around `check_func_args` and how the `meta` structure is used. First, I've identified the call sites of `check_func_args`: 1. `check_helper_call` – where `meta.btf` is NULL. 2. `check_kfunc_call` – where `meta.btf` is set, along with `meta.func_id` and `meta.func_proto`. 3. `btf_check_func_arg_match` – where `meta.btf` is set, `meta.func_id` is zero (indicating a subprogram), and `meta.func_proto` is set, with `meta.fn` pointing to the `bpf_subprog_scratch`. Now, within `check_func_args`, I see that the code checks `meta->btf`. If it's NULL (as in helper calls), the code *doesn't* read `meta->func_proto`. If `meta->btf` is set (kfuncs or subprograms), `meta->func_proto` *is* initialized. This is important to note. Then, there's the `size` calculation: `size = (is_subprog(meta) && base_type(reg->type) == PTR_TO_STACK) ? -(int)mem_size : mem_size;`. This replaced a previous version that checked `meta == NULL` directly. Crucially, the behavior seems to be preserved. `btf_check_func_arg_match` now passes `&meta` where `is_subprog(&meta)` will be true. For helpers, `is_subprog(meta)` is false because `meta->btf` is NULL. For kfuncs, `is_subprog(meta)` is also false because `meta->func_id` is non-zero. So, the logic surrounding `size` is unchanged in terms of how it's handled in the branches. Next, I need to consider potential information leaks or uninitialized memory issues. After scrutinizing the code, I can confidently say that there are **no** new user copy operations introduced or modified. No new data structures are exposed to userspace, and there are no uninitialized buffers on the heap or stack. Critically, all relevant structures (`bpf_subprog_scratch`, `meta`) are fully zero-initialized using `memset`. Given these points, KASAN (Kernel Address Sanitizer) will cover any out-of-bounds, use-after-free, or double-free errors. KASAN is the tool for detecting these types of issues, while KMSAN focuses on uninitialized memory reads and information leaks. Because the newly touched or allocated structures are fully zeroed with `memset` and conditional branches correctly inspect properly initialized variables, there are no uninitialized memory risks. Any bugs that might arise due to verifier logic leading to out-of-bounds reads or invalid pointer dereferences will be caught by KASAN or standard verifier checks and tests. Therefore, `NeedsKMSAN` should remain `false`. Finally, just to be absolutely certain, let's double-check the potential for subtle problems. Specifically, is there a chance that `gen_subprog_arg_proto` might leave a field uninitialized? Nope. We can see `memset(proto, 0, sizeof(*proto))` is called, completely zeroing the `bpf_func_proto` struct, before any other operations. The `bpf_func_proto` struct itself contains the function pointer, boolean flags, and enum fields, all zeroed by `memset`. Moreover, `fn` points to `&env->bpf_subprog_scratch`, which is cleanly zeroed every time `gen_subprog_arg_proto` is called. Last check, `check_outgoing_stack_args`, is there anything there? Let me check. |
| 66/3 | 2026/09/29 21:24 | tool | grepper |
0mArgs:{
"Expression": "check_outgoing_stack_args",
"PathPrefix": "kernel/bpf/"
}Results: {
"Output": "kernel/bpf/verifier.c=4423=static int mark_arg_precision(struct bpf_verifier_env *env, argno_t argno)\n--\nkernel/bpf/verifier.c-4431-\nkernel/bpf/verifier.c:4432:static int check_outgoing_stack_args(struct bpf_verifier_env *env, struct bpf_func_state *caller,\nkernel/bpf/verifier.c-4433-\t\t\t\t int nargs, const char *callee_name, const struct btf *btf,\n--\nkernel/bpf/verifier.c=9996=static int check_func_args(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,\n--\nkernel/bpf/verifier.c-10018-\tif (proto_slots \u003e MAX_BPF_FUNC_REG_ARGS) {\nkernel/bpf/verifier.c:10019:\t\terr = check_outgoing_stack_args(env, caller, proto_slots, meta-\u003efunc_name,\nkernel/bpf/verifier.c-10020-\t\t\t\t\t\tmeta-\u003ebtf, proto_slots == nargs ? args : NULL);\n--\nkernel/bpf/verifier.c=10849=static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog, struct btf *btf)\n--\nkernel/bpf/verifier.c-10865-\t\tif (bpf_in_stack_arg_cnt(sub) \u003e 0) {\nkernel/bpf/verifier.c:10866:\t\t\terr = check_outgoing_stack_args(env, caller, sub-\u003earg_slot_cnt,\nkernel/bpf/verifier.c-10867-\t\t\t\t\t\t\tbpf_subprog_name(env, subprog),\n"
} |
| 67/3 | 2026/09/29 21:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44119 output: 246 thoughts: 606 Thoughts: **KMSAN Assessment: No Uninitialized Memory Hazards** Okay, let's break this down. In `btf_check_func_arg_match`, we've got the initial argument preparation: I see the call to `btf_prepare_func_args`, and if that fails, we check for stack arguments. *That* calls `check_outgoing_stack_args`, all pretty standard stuff. Later, `check_func_args` *also* calls `check_outgoing_stack_args`, but this is consistent because it does it with the same relevant parameters as before. Basically, it’s refactoring and consolidating how we handle the checks. I've confirmed that the argument validation is logically sound, with no redundant operations or opportunities for unexpected behavior. So, the patch is changing how we *do* argument checking, but not changing the *nature* of it. My analysis shows that there's no way this introduces any uninitialized memory issues. We're zero-initializing everything we bring in: the new `struct bpf_call_arg_meta meta` on the stack is memset'd and also `env->bpf_subprog_scratch` on the heap/environment is initialized too. We're not doing any risky kernel-to-user memory transfers. No user-visible buffers, either. The logic flow doesn't rely on uninitialized kernel data. The only real risks here are related to functional bugs (like if the *type* checking is messed up), which KASAN, for instance, should catch. We're not enabling any new info leaks or read bugs. So, no specific KMSAN fuzzing needed, this is all good. Therefore, for the tool call: `NeedsKMSAN`: false. And I have the explanation ready. |
| 68/3 | 2026/09/29 21:24 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch refactors BPF subprogram argument verification in `kernel/bpf/verifier.c` to unify it with the helper/kfunc argument checking path (`check_func_args()`), avoiding duplicated logic in `btf_check_func_arg_match()`.\n\nAll newly introduced or modified structures, such as `env-\u003ebpf_subprog_scratch` and the stack-allocated `struct bpf_call_arg_meta meta`, are explicitly cleared with `memset` before use, leaving no uninitialized fields. Furthermore, the patch does not introduce or modify any copy operations to userspace, does not alter buffer initialization, and does not introduce conditional branches based on uninitialized memory. Any potential regressions or bugs in verifier type-checking or register tracking would manifest as logical errors, out-of-bounds access, or invalid pointer dereferences, which are already covered by KASAN and standard verifier assertions. Consequently, there is no risk of uninitialized memory usage or info-leaks that would require a dedicated KMSAN fuzzing session.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch refactors BPF subprogram argument verification in `kernel/bpf/verifier.c` to unify it with the helper/kfunc argument checking path (`check_func_args()`), avoiding duplicated logic in `btf_check_func_arg_match()`.\n\nAll newly introduced or modified structures, such as `env-\u003ebpf_subprog_scratch` and the stack-allocated `struct bpf_call_arg_meta meta`, are explicitly cleared with `memset` before use, leaving no uninitialized fields. Furthermore, the patch does not introduce or modify any copy operations to userspace, does not alter buffer initialization, and does not introduce conditional branches based on uninitialized memory. Any potential regressions or bugs in verifier type-checking or register tracking would manifest as logical errors, out-of-bounds access, or invalid pointer dereferences, which are already covered by KASAN and standard verifier assertions. Consequently, there is no risk of uninitialized memory usage or info-leaks that would require a dedicated KMSAN fuzzing session.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|