@@ -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,
@@ -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 },
};
@@ -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 },
};
@@ -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,
};
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@google.com> --- 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(-)