selftests/bpf: Add testcase for bpf_task_under_cgroup
authorFeng Zhou <zhoufeng.zf@bytedance.com>
Sat, 6 May 2023 03:15:45 +0000 (11:15 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 6 May 2023 20:56:38 +0000 (13:56 -0700)
commit49e0263ab40f15a11cefa397bb17a0204505cead
tree0aa9ef72877daa223b52b9856933342d9172b401
parentb5ad4cdc46c7d6e7f8d2c9e24b6c9a1edec95154
selftests/bpf: Add testcase for bpf_task_under_cgroup

test_progs:
Tests new kfunc bpf_task_under_cgroup().

The bpf program saves the new task's pid within a given cgroup to
the remote_pid, which is convenient for the user-mode program to
verify the test correctness.

The user-mode program creates its own mount namespace, and mounts the
cgroupsv2 hierarchy in there, call the fork syscall, then check if
remote_pid and local_pid are unequal.

Signed-off-by: Feng Zhou <zhoufeng.zf@bytedance.com>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20230506031545.35991-3-zhoufeng.zf@bytedance.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/DENYLIST.s390x
tools/testing/selftests/bpf/prog_tests/task_under_cgroup.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_task_under_cgroup.c [new file with mode: 0644]