diff mbox series

[RFC,bpf-next,8/9] bpf: Rename ARG_CONST_ALLOC_SIZE_OR_ZERO

Message ID 20211109021624.1140446-9-haoluo@google.com (mailing list archive)
State RFC
Delegated to: BPF
Headers show
Series bpf: Clean up _OR_NULL arg types | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR fail merge-conflict

Commit Message

Hao Luo Nov. 9, 2021, 2:16 a.m. UTC
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(-)
diff mbox series

Patch

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 3313ba544758..a6dd5e85113d 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -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 */
diff --git a/kernel/bpf/ringbuf.c b/kernel/bpf/ringbuf.c
index a8af9c7c6423..132e03617881 100644
--- a/kernel/bpf/ringbuf.c
+++ b/kernel/bpf/ringbuf.c
@@ -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 },
 };
 
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 2e53605a051a..9c4a8df25ef2 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -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,