The following prog types don't make sense without bpf cgroup: * BPF_PROG_TYPE_CGROUP_SKB * BPF_PROG_TYPE_CGROUP_SOCK * BPF_PROG_TYPE_CGROUP_SOCK_ADDR
Skip running verifier tests that exercise these prog types if kernel is built without proper support. See commit e5c504858a18 ("selftests/bpf: skip verifier sockmap tests on kernels without support") for original motivation. Signed-off-by: Stanislav Fomichev <s...@google.com> --- tools/testing/selftests/bpf/test_verifier.c | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index f5015566ae1b..b5470a399996 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -44,6 +44,7 @@ /* fallback to all features enabled */ # define CONFIG_BPF_STREAM_PARSER 1 # define CONFIG_XDP_SOCKETS 1 +# define CONFIG_CGROUP_BPF 1 #endif #include "bpf_rlimit.h" #include "bpf_rand.h" @@ -2098,6 +2099,7 @@ static struct bpf_test tests[] = { .errstr = "invalid bpf_context access", .result = REJECT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "check cb access: half", @@ -2256,6 +2258,7 @@ static struct bpf_test tests[] = { .errstr = "invalid bpf_context access", .result = REJECT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "check cb access: word", @@ -2428,6 +2431,7 @@ static struct bpf_test tests[] = { .errstr = "invalid bpf_context access", .result = REJECT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "check out of range skb->cb access", @@ -4981,6 +4985,7 @@ static struct bpf_test tests[] = { .result_unpriv = REJECT, .errstr_unpriv = "invalid bpf_context access off=76 size=4", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "direct packet read test#2 for CGROUP_SKB", @@ -5005,6 +5010,7 @@ static struct bpf_test tests[] = { }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "direct packet read test#3 for CGROUP_SKB", @@ -5036,6 +5042,7 @@ static struct bpf_test tests[] = { }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "direct packet read test#4 for CGROUP_SKB", @@ -5071,6 +5078,7 @@ static struct bpf_test tests[] = { }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid access of tc_classid for CGROUP_SKB", @@ -5083,6 +5091,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "invalid bpf_context access", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid access of data_meta for CGROUP_SKB", @@ -5095,6 +5104,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "invalid bpf_context access", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid access of flow_keys for CGROUP_SKB", @@ -5107,6 +5117,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "invalid bpf_context access", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid write access to napi_id for CGROUP_SKB", @@ -5121,6 +5132,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "invalid bpf_context access", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "valid cgroup storage access", @@ -5137,6 +5149,7 @@ static struct bpf_test tests[] = { .fixup_cgroup_storage = { 1 }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid cgroup storage access 1", @@ -5154,6 +5167,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "cannot pass map_type 1 into func bpf_get_local_storage", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid cgroup storage access 2", @@ -5168,6 +5182,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "fd 1 is not pointing to valid bpf_map", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid cgroup storage access 3", @@ -5185,6 +5200,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "invalid access to map value, value_size=64 off=256 size=4", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid cgroup storage access 4", @@ -5202,6 +5218,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "invalid access to map value, value_size=64 off=-2 size=4", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { @@ -5220,6 +5237,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "get_local_storage() doesn't support non-zero flags", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid cgroup storage access 6", @@ -5238,6 +5256,7 @@ static struct bpf_test tests[] = { .errstr = "get_local_storage() doesn't support non-zero flags", .errstr_unpriv = "R2 leaks addr into helper function", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "valid per-cpu cgroup storage access", @@ -5254,6 +5273,7 @@ static struct bpf_test tests[] = { .fixup_percpu_cgroup_storage = { 1 }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid per-cpu cgroup storage access 1", @@ -5271,6 +5291,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "cannot pass map_type 1 into func bpf_get_local_storage", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid per-cpu cgroup storage access 2", @@ -5285,6 +5306,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "fd 1 is not pointing to valid bpf_map", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid per-cpu cgroup storage access 3", @@ -5302,6 +5324,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "invalid access to map value, value_size=64 off=256 size=4", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid per-cpu cgroup storage access 4", @@ -5319,6 +5342,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "invalid access to map value, value_size=64 off=-2 size=4", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, }, { @@ -5337,6 +5361,7 @@ static struct bpf_test tests[] = { .result = REJECT, .errstr = "get_local_storage() doesn't support non-zero flags", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "invalid per-cpu cgroup storage access 6", @@ -5355,6 +5380,7 @@ static struct bpf_test tests[] = { .errstr = "get_local_storage() doesn't support non-zero flags", .errstr_unpriv = "R2 leaks addr into helper function", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "write tstamp from CGROUP_SKB", @@ -5369,6 +5395,7 @@ static struct bpf_test tests[] = { .result_unpriv = REJECT, .errstr_unpriv = "invalid bpf_context access off=152 size=8", .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "read tstamp from CGROUP_SKB", @@ -5380,6 +5407,7 @@ static struct bpf_test tests[] = { }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_CGROUP_SKB, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "multiple registers share map_lookup_elem result", @@ -10770,6 +10798,7 @@ static struct bpf_test tests[] = { .errstr = "R0 has value (0x0; 0xffffffff)", .result = REJECT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "bpf_exit with invalid return code. test2", @@ -10780,6 +10809,7 @@ static struct bpf_test tests[] = { }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "bpf_exit with invalid return code. test3", @@ -10791,6 +10821,7 @@ static struct bpf_test tests[] = { .errstr = "R0 has value (0x0; 0x3)", .result = REJECT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "bpf_exit with invalid return code. test4", @@ -10800,6 +10831,7 @@ static struct bpf_test tests[] = { }, .result = ACCEPT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "bpf_exit with invalid return code. test5", @@ -10810,6 +10842,7 @@ static struct bpf_test tests[] = { .errstr = "R0 has value (0x2; 0x0)", .result = REJECT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "bpf_exit with invalid return code. test6", @@ -10820,6 +10853,7 @@ static struct bpf_test tests[] = { .errstr = "R0 is not a known value (ctx)", .result = REJECT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "bpf_exit with invalid return code. test7", @@ -10832,6 +10866,7 @@ static struct bpf_test tests[] = { .errstr = "R0 has unknown scalar value", .result = REJECT, .prog_type = BPF_PROG_TYPE_CGROUP_SOCK, + .config_disabled = !IS_BUILTIN(CONFIG_CGROUP_BPF), }, { "calls: basic sanity", -- 2.20.0.rc2.403.gdbc3b29805-goog