@@ -332,7 +332,7 @@ struct bpf_arg_type {
ARG_PTR_TO_SOCKET, /* pointer to bpf_sock (fullsock) */
ARG_PTR_TO_BTF_ID, /* pointer to in-kernel struct */
ARG_PTR_TO_ALLOC_MEM, /* pointer to dynamically allocated memory */
- ARG_CONST_ALLOC_SIZE_OR_ZERO, /* number of allocated bytes requested */
+ ARG_CONST_ALLOC_SIZE, /* number of allocated bytes requested */
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 */
@@ -363,7 +363,10 @@ const struct bpf_func_proto bpf_ringbuf_reserve_proto = {
.func = bpf_ringbuf_reserve,
.ret_type = RET_PTR_TO_ALLOC_MEM_OR_NULL,
.arg1 = { .type = ARG_CONST_MAP_PTR },
- .arg2 = { .type = ARG_CONST_ALLOC_SIZE_OR_ZERO },
+ .arg2 = {
+ .type = ARG_CONST_ALLOC_SIZE,
+ .flag = ARG_FLAG_MAYBE_NULL,
+ },
.arg3 = { .type = ARG_ANYTHING },
};
@@ -4957,7 +4957,7 @@ static bool arg_type_is_mem_size(struct bpf_arg_type arg)
static bool arg_type_is_alloc_size(struct bpf_arg_type arg)
{
- return arg.type == ARG_CONST_ALLOC_SIZE_OR_ZERO;
+ return arg.type == ARG_CONST_ALLOC_SIZE;
}
static bool arg_type_is_int_ptr(struct bpf_arg_type arg)
@@ -5084,7 +5084,7 @@ static const struct bpf_reg_types *compatible_reg_types[__BPF_ARG_TYPE_MAX] = {
[ARG_PTR_TO_MAP_VALUE] = &map_key_value_types,
[ARG_PTR_TO_UNINIT_MAP_VALUE] = &map_key_value_types,
[ARG_CONST_SIZE] = &scalar_types,
- [ARG_CONST_ALLOC_SIZE_OR_ZERO] = &scalar_types,
+ [ARG_CONST_ALLOC_SIZE] = &scalar_types,
[ARG_CONST_MAP_PTR] = &const_map_ptr_types,
[ARG_PTR_TO_CTX] = &context_types,
[ARG_PTR_TO_SOCK_COMMON] = &sock_types,
Rename ARG_CONST_ALLOC_SIZE_OR_ZERO to ARG_CONST_ALLOC_SIZE and use flag to mark that the argument may be zero. Signed-off-by: Hao Luo <haoluo@google.com> --- include/linux/bpf.h | 2 +- kernel/bpf/ringbuf.c | 5 ++++- kernel/bpf/verifier.c | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-)