Rename ARG_PTR_TO_STACK_OR_NULL to ARG_PTR_TO_STACK and use flag to mark that the argument may be null. Signed-off-by: Hao Luo <haoluo@xxxxxxxxxx> --- include/linux/bpf.h | 2 +- kernel/bpf/bpf_iter.c | 5 ++++- kernel/bpf/task_iter.c | 5 ++++- kernel/bpf/verifier.c | 5 ++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index a6dd5e85113d..da4fa15127d6 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -336,7 +336,7 @@ struct bpf_arg_type { ARG_PTR_TO_BTF_ID_SOCK_COMMON, /* pointer to in-kernel sock_common or bpf-mirrored bpf_sock */ ARG_PTR_TO_PERCPU_BTF_ID, /* pointer to in-kernel percpu type */ ARG_PTR_TO_FUNC, /* pointer to a bpf program function */ - ARG_PTR_TO_STACK_OR_NULL, /* pointer to stack or NULL */ + ARG_PTR_TO_STACK, /* pointer to stack */ ARG_PTR_TO_CONST_STR, /* pointer to a null terminated read-only string */ ARG_PTR_TO_TIMER, /* pointer to bpf_timer */ __BPF_ARG_TYPE_MAX, diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c index 4fdf225c01f9..d3bded3e05d3 100644 --- a/kernel/bpf/bpf_iter.c +++ b/kernel/bpf/bpf_iter.c @@ -711,6 +711,9 @@ const struct bpf_func_proto bpf_for_each_map_elem_proto = { .ret_type = RET_INTEGER, .arg1 = { .type = ARG_CONST_MAP_PTR }, .arg2 = { .type = ARG_PTR_TO_FUNC }, - .arg3 = { .type = ARG_PTR_TO_STACK_OR_NULL }, + .arg3 = { + .type = ARG_PTR_TO_STACK, + .flag = ARG_FLAG_MAYBE_NULL, + }, .arg4 = { .type = ARG_ANYTHING }, }; diff --git a/kernel/bpf/task_iter.c b/kernel/bpf/task_iter.c index 0a5e3cf593b5..fc72701ae6b6 100644 --- a/kernel/bpf/task_iter.c +++ b/kernel/bpf/task_iter.c @@ -625,7 +625,10 @@ const struct bpf_func_proto bpf_find_vma_proto = { .arg1_btf_id = &btf_task_struct_ids[0], .arg2 = { .type = ARG_ANYTHING }, .arg3 = { .type = ARG_PTR_TO_FUNC }, - .arg4 = { .type = ARG_PTR_TO_STACK_OR_NULL }, + .arg4 = { + .type = ARG_PTR_TO_STACK, + .flag = ARG_FLAG_MAYBE_NULL, + }, .arg5 = { .type = ARG_ANYTHING }, }; diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 9c4a8df25ef2..9c68b664f4f4 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -480,8 +480,7 @@ static bool arg_type_may_be_refcounted(struct bpf_arg_type arg) static bool arg_type_may_be_null(struct bpf_arg_type arg) { - return arg.flag & ARG_FLAG_MAYBE_NULL || - arg.type == ARG_PTR_TO_STACK_OR_NULL; + return arg.flag & ARG_FLAG_MAYBE_NULL; } /* Determine whether the function releases some resources allocated by another @@ -5101,7 +5100,7 @@ static const struct bpf_reg_types *compatible_reg_types[__BPF_ARG_TYPE_MAX] = { [ARG_PTR_TO_LONG] = &int_ptr_types, [ARG_PTR_TO_PERCPU_BTF_ID] = &percpu_btf_ptr_types, [ARG_PTR_TO_FUNC] = &func_ptr_types, - [ARG_PTR_TO_STACK_OR_NULL] = &stack_ptr_types, + [ARG_PTR_TO_STACK] = &stack_ptr_types, [ARG_PTR_TO_CONST_STR] = &const_str_ptr_types, [ARG_PTR_TO_TIMER] = &timer_types, }; -- 2.34.0.rc0.344.g81b53c2807-goog