@@ -324,7 +324,6 @@ struct bpf_arg_type {
ARG_CONST_SIZE, /* number of bytes accessed from memory */
ARG_PTR_TO_CTX, /* pointer to context */
- ARG_PTR_TO_CTX_OR_NULL, /* pointer to context or NULL */
ARG_ANYTHING, /* any (initialized) argument is ok */
ARG_PTR_TO_SPIN_LOCK, /* pointer to bpf_spin_lock */
ARG_PTR_TO_SOCK_COMMON, /* pointer to sock_common */
@@ -1888,7 +1888,10 @@ static const struct bpf_func_proto bpf_get_netns_cookie_sockopt_proto = {
.func = bpf_get_netns_cookie_sockopt,
.gpl_only = false,
.ret_type = RET_INTEGER,
- .arg1 = { .type = ARG_PTR_TO_CTX_OR_NULL },
+ .arg1 = {
+ .type = ARG_PTR_TO_CTX,
+ .flag = ARG_FLAG_MAYBE_NULL,
+ },
};
#endif
@@ -481,7 +481,6 @@ 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_CTX_OR_NULL ||
arg.type == ARG_PTR_TO_SOCKET_OR_NULL ||
arg.type == ARG_PTR_TO_ALLOC_MEM_OR_NULL ||
arg.type == ARG_PTR_TO_STACK_OR_NULL;
@@ -5090,7 +5089,6 @@ static const struct bpf_reg_types *compatible_reg_types[__BPF_ARG_TYPE_MAX] = {
[ARG_CONST_ALLOC_SIZE_OR_ZERO] = &scalar_types,
[ARG_CONST_MAP_PTR] = &const_map_ptr_types,
[ARG_PTR_TO_CTX] = &context_types,
- [ARG_PTR_TO_CTX_OR_NULL] = &context_types,
[ARG_PTR_TO_SOCK_COMMON] = &sock_types,
#ifdef CONFIG_NET
[ARG_PTR_TO_BTF_ID_SOCK_COMMON] = &btf_id_sock_common_types,
@@ -4691,7 +4691,10 @@ static const struct bpf_func_proto bpf_get_netns_cookie_sock_proto = {
.func = bpf_get_netns_cookie_sock,
.gpl_only = false,
.ret_type = RET_INTEGER,
- .arg1 = { .type = ARG_PTR_TO_CTX_OR_NULL },
+ .arg1 = {
+ .type = ARG_PTR_TO_CTX,
+ .flag = ARG_FLAG_MAYBE_NULL,
+ },
};
BPF_CALL_1(bpf_get_netns_cookie_sock_addr, struct bpf_sock_addr_kern *, ctx)
@@ -4703,7 +4706,10 @@ static const struct bpf_func_proto bpf_get_netns_cookie_sock_addr_proto = {
.func = bpf_get_netns_cookie_sock_addr,
.gpl_only = false,
.ret_type = RET_INTEGER,
- .arg1 = { .type = ARG_PTR_TO_CTX_OR_NULL },
+ .arg1 = {
+ .type = ARG_PTR_TO_CTX,
+ .flag = ARG_FLAG_MAYBE_NULL,
+ },
};
BPF_CALL_1(bpf_get_netns_cookie_sock_ops, struct bpf_sock_ops_kern *, ctx)
@@ -4715,7 +4721,10 @@ static const struct bpf_func_proto bpf_get_netns_cookie_sock_ops_proto = {
.func = bpf_get_netns_cookie_sock_ops,
.gpl_only = false,
.ret_type = RET_INTEGER,
- .arg1 = { .type = ARG_PTR_TO_CTX_OR_NULL },
+ .arg1 = {
+ .type = ARG_PTR_TO_CTX,
+ .flag = ARG_FLAG_MAYBE_NULL,
+ },
};
BPF_CALL_1(bpf_get_netns_cookie_sk_msg, struct sk_msg *, ctx)
@@ -4727,7 +4736,10 @@ static const struct bpf_func_proto bpf_get_netns_cookie_sk_msg_proto = {
.func = bpf_get_netns_cookie_sk_msg,
.gpl_only = false,
.ret_type = RET_INTEGER,
- .arg1 = { .type = ARG_PTR_TO_CTX_OR_NULL },
+ .arg1 = {
+ .type = ARG_PTR_TO_CTX,
+ .flag = ARG_FLAG_MAYBE_NULL,
+ },
};
BPF_CALL_1(bpf_get_socket_uid, struct sk_buff *, skb)
Remove ARG_PTR_TO_CTX_OR_NULL and use flag to mark that the argument may be null. Signed-off-by: Hao Luo <haoluo@google.com> --- include/linux/bpf.h | 1 - kernel/bpf/cgroup.c | 5 ++++- kernel/bpf/verifier.c | 2 -- net/core/filter.c | 20 ++++++++++++++++---- 4 files changed, 20 insertions(+), 8 deletions(-)