Skip to content

Commit 124e8c2

Browse files
Alexei Starovoitovborkmann
authored andcommitted
bpf: Relax tuple len requirement for sk helpers.
__bpf_skc_lookup() safely handles incorrect values of tuple len, hence we can allow zero to be passed as tuple len. This patch alone doesn't make an observable verifier difference. It's a trivial improvement that might simplify bpf programs. Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent cdbde08 commit 124e8c2

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

net/core/filter.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6815,7 +6815,7 @@ static const struct bpf_func_proto bpf_skc_lookup_tcp_proto = {
68156815
.ret_type = RET_PTR_TO_SOCK_COMMON_OR_NULL,
68166816
.arg1_type = ARG_PTR_TO_CTX,
68176817
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
6818-
.arg3_type = ARG_CONST_SIZE,
6818+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
68196819
.arg4_type = ARG_ANYTHING,
68206820
.arg5_type = ARG_ANYTHING,
68216821
};
@@ -6834,7 +6834,7 @@ static const struct bpf_func_proto bpf_sk_lookup_tcp_proto = {
68346834
.ret_type = RET_PTR_TO_SOCKET_OR_NULL,
68356835
.arg1_type = ARG_PTR_TO_CTX,
68366836
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
6837-
.arg3_type = ARG_CONST_SIZE,
6837+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
68386838
.arg4_type = ARG_ANYTHING,
68396839
.arg5_type = ARG_ANYTHING,
68406840
};
@@ -6853,7 +6853,7 @@ static const struct bpf_func_proto bpf_sk_lookup_udp_proto = {
68536853
.ret_type = RET_PTR_TO_SOCKET_OR_NULL,
68546854
.arg1_type = ARG_PTR_TO_CTX,
68556855
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
6856-
.arg3_type = ARG_CONST_SIZE,
6856+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
68576857
.arg4_type = ARG_ANYTHING,
68586858
.arg5_type = ARG_ANYTHING,
68596859
};
@@ -6877,7 +6877,7 @@ static const struct bpf_func_proto bpf_tc_skc_lookup_tcp_proto = {
68776877
.ret_type = RET_PTR_TO_SOCK_COMMON_OR_NULL,
68786878
.arg1_type = ARG_PTR_TO_CTX,
68796879
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
6880-
.arg3_type = ARG_CONST_SIZE,
6880+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
68816881
.arg4_type = ARG_ANYTHING,
68826882
.arg5_type = ARG_ANYTHING,
68836883
};
@@ -6901,7 +6901,7 @@ static const struct bpf_func_proto bpf_tc_sk_lookup_tcp_proto = {
69016901
.ret_type = RET_PTR_TO_SOCKET_OR_NULL,
69026902
.arg1_type = ARG_PTR_TO_CTX,
69036903
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
6904-
.arg3_type = ARG_CONST_SIZE,
6904+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
69056905
.arg4_type = ARG_ANYTHING,
69066906
.arg5_type = ARG_ANYTHING,
69076907
};
@@ -6925,7 +6925,7 @@ static const struct bpf_func_proto bpf_tc_sk_lookup_udp_proto = {
69256925
.ret_type = RET_PTR_TO_SOCKET_OR_NULL,
69266926
.arg1_type = ARG_PTR_TO_CTX,
69276927
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
6928-
.arg3_type = ARG_CONST_SIZE,
6928+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
69296929
.arg4_type = ARG_ANYTHING,
69306930
.arg5_type = ARG_ANYTHING,
69316931
};
@@ -6963,7 +6963,7 @@ static const struct bpf_func_proto bpf_xdp_sk_lookup_udp_proto = {
69636963
.ret_type = RET_PTR_TO_SOCKET_OR_NULL,
69646964
.arg1_type = ARG_PTR_TO_CTX,
69656965
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
6966-
.arg3_type = ARG_CONST_SIZE,
6966+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
69676967
.arg4_type = ARG_ANYTHING,
69686968
.arg5_type = ARG_ANYTHING,
69696969
};
@@ -6987,7 +6987,7 @@ static const struct bpf_func_proto bpf_xdp_skc_lookup_tcp_proto = {
69876987
.ret_type = RET_PTR_TO_SOCK_COMMON_OR_NULL,
69886988
.arg1_type = ARG_PTR_TO_CTX,
69896989
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
6990-
.arg3_type = ARG_CONST_SIZE,
6990+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
69916991
.arg4_type = ARG_ANYTHING,
69926992
.arg5_type = ARG_ANYTHING,
69936993
};
@@ -7011,7 +7011,7 @@ static const struct bpf_func_proto bpf_xdp_sk_lookup_tcp_proto = {
70117011
.ret_type = RET_PTR_TO_SOCKET_OR_NULL,
70127012
.arg1_type = ARG_PTR_TO_CTX,
70137013
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
7014-
.arg3_type = ARG_CONST_SIZE,
7014+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
70157015
.arg4_type = ARG_ANYTHING,
70167016
.arg5_type = ARG_ANYTHING,
70177017
};
@@ -7031,7 +7031,7 @@ static const struct bpf_func_proto bpf_sock_addr_skc_lookup_tcp_proto = {
70317031
.ret_type = RET_PTR_TO_SOCK_COMMON_OR_NULL,
70327032
.arg1_type = ARG_PTR_TO_CTX,
70337033
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
7034-
.arg3_type = ARG_CONST_SIZE,
7034+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
70357035
.arg4_type = ARG_ANYTHING,
70367036
.arg5_type = ARG_ANYTHING,
70377037
};
@@ -7050,7 +7050,7 @@ static const struct bpf_func_proto bpf_sock_addr_sk_lookup_tcp_proto = {
70507050
.ret_type = RET_PTR_TO_SOCKET_OR_NULL,
70517051
.arg1_type = ARG_PTR_TO_CTX,
70527052
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
7053-
.arg3_type = ARG_CONST_SIZE,
7053+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
70547054
.arg4_type = ARG_ANYTHING,
70557055
.arg5_type = ARG_ANYTHING,
70567056
};
@@ -7069,7 +7069,7 @@ static const struct bpf_func_proto bpf_sock_addr_sk_lookup_udp_proto = {
70697069
.ret_type = RET_PTR_TO_SOCKET_OR_NULL,
70707070
.arg1_type = ARG_PTR_TO_CTX,
70717071
.arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
7072-
.arg3_type = ARG_CONST_SIZE,
7072+
.arg3_type = ARG_CONST_SIZE_OR_ZERO,
70737073
.arg4_type = ARG_ANYTHING,
70747074
.arg5_type = ARG_ANYTHING,
70757075
};

0 commit comments

Comments
 (0)