summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAmery Hung <ameryhung@gmail.com>2026-09-28 11:53:29 -0700
committerAlexei Starovoitov <ast@kernel.org>2026-09-29 10:35:12 +0000
commit03f312c2cbd5ec0acb14f02701181af1ad0b8a08 (patch)
tree223db30784fb026491cc1501fc41213149ca82ab /kernel
parent3886a9fc38de0c4e03525be03570ea1473176479 (diff)
downloadlinux-03f312c2cbd5ec0acb14f02701181af1ad0b8a08.tar.gz
linux-03f312c2cbd5ec0acb14f02701181af1ad0b8a08.zip
bpf: Check subprog context arguments in the common path
Subprog and helper/kfunc context arguments require PTR_TO_CTX with an acceptable offset. Route subprog context arguments through check_func_arg() and update the verifier-log expectation. Signed-off-by: Amery Hung <ameryhung@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20260928185334.1004200-7-ameryhung@gmail.com
Diffstat (limited to 'kernel')
-rw-r--r--kernel/bpf/verifier.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 79b9e7242fee..659820a4b805 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -10880,22 +10880,11 @@ static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
t = btf_type_skip_modifiers(btf, args[arg].type, NULL);
nslots = btf_arg_slots(t);
- if (arg_type == ARG_SCALAR || arg_type == ARG_IGNORE) {
+ if (arg_type == ARG_SCALAR || arg_type == ARG_IGNORE ||
+ arg_type == ARG_PTR_TO_CTX) {
ret = check_func_arg(env, arg, slot, 0, &meta, env->insn_idx);
if (ret)
return ret;
- } else if (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_type) == ARG_PTR_TO_MEM) {
ret = check_func_arg_reg_off(env, reg, argno, ARG_PTR_TO_MEM);
if (ret < 0)