Commit 19468ed
selftests/bpf: Run cgroup1_hierarchy test in own mount namespace
The cgroup1_hierarchy test uses setup_classid_environment to setup
cgroupv1 environment. The problem is that the environment is set in
/sys/fs/cgroup and therefore, if not run under an own mount namespace,
effectively deletes all system cgroups:
$ ls /sys/fs/cgroup | wc -l
27
$ sudo ./test_progs -t cgroup1_hierarchy
starfive-tech#41/1 cgroup1_hierarchy/test_cgroup1_hierarchy:OK
starfive-tech#41/2 cgroup1_hierarchy/test_root_cgid:OK
starfive-tech#41/3 cgroup1_hierarchy/test_invalid_level:OK
starfive-tech#41/4 cgroup1_hierarchy/test_invalid_cgid:OK
starfive-tech#41/5 cgroup1_hierarchy/test_invalid_hid:OK
starfive-tech#41/6 cgroup1_hierarchy/test_invalid_cgrp_name:OK
starfive-tech#41/7 cgroup1_hierarchy/test_invalid_cgrp_name2:OK
starfive-tech#41/8 cgroup1_hierarchy/test_sleepable_prog:OK
starfive-tech#41 cgroup1_hierarchy:OK
Summary: 1/8 PASSED, 0 SKIPPED, 0 FAILED
$ ls /sys/fs/cgroup | wc -l
1
To avoid this, run setup_cgroup_environment first which will create an
own mount namespace. This only affects the cgroupv1_hierarchy test as
all other cgroup1 test progs already run setup_cgroup_environment prior
to running setup_classid_environment.
Also add a comment to the header of setup_classid_environment to warn
against this invalid usage in future.
Fixes: 3607692 ("selftests/bpf: Add selftests for cgroup1 hierarchy")
Signed-off-by: Viktor Malik <vmalik@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240429112311.402497-1-vmalik@redhat.com1 parent a303487 commit 19468ed
File tree
2 files changed
+9
-1
lines changed- tools/testing/selftests/bpf
- prog_tests
2 files changed
+9
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
508 | 508 | | |
509 | 509 | | |
510 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
511 | 514 | | |
512 | 515 | | |
513 | 516 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
| |||
153 | 156 | | |
154 | 157 | | |
155 | 158 | | |
| 159 | + | |
| 160 | + | |
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
0 commit comments