Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: add wrong type test to cgroup dev

Current cgroup_dev test mostly tests that device operation is accepted or
refused base on passed major/minor (and so, any operation performed during
test involves only char device)

Add a small subtest ensuring that the device type passed to bpf program
allows it to take decisions as well.

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
Link: https://lore.kernel.org/r/20240731-convert_dev_cgroup-v4-3-849425d90de6@bootlin.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>

authored by

Alexis Lothoré (eBPF Foundation) and committed by
Martin KaFai Lau
84cdbff4 d83d8230

+4
+4
tools/testing/selftests/bpf/prog_tests/cgroup_dev.c
··· 114 114 if (test__start_subtest("deny-write")) 115 115 test_write("/dev/zero", buf, TEST_BUFFER_SIZE, -1, EPERM); 116 116 117 + if (test__start_subtest("deny-mknod-wrong-type")) 118 + test_mknod("/dev/test_dev_cgroup_block", S_IFBLK, 1, 3, -1, 119 + EPERM); 120 + 117 121 cleanup_progs: 118 122 dev_cgroup__destroy(skel); 119 123 cleanup_cgroup: