Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 torvalds#41/1 cgroup1_hierarchy/test_cgroup1_hierarchy:OK torvalds#41/2 cgroup1_hierarchy/test_root_cgid:OK torvalds#41/3 cgroup1_hierarchy/test_invalid_level:OK torvalds#41/4 cgroup1_hierarchy/test_invalid_cgid:OK torvalds#41/5 cgroup1_hierarchy/test_invalid_hid:OK torvalds#41/6 cgroup1_hierarchy/test_invalid_cgrp_name:OK torvalds#41/7 cgroup1_hierarchy/test_invalid_cgrp_name2:OK torvalds#41/8 cgroup1_hierarchy/test_sleepable_prog:OK torvalds#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 <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
- Loading branch information