]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/bpf: Fix cgroup_xattr/read_cgroupfs_xattr
authorSong Liu <song@kernel.org>
Fri, 27 Jun 2025 19:12:21 +0000 (12:12 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 27 Jun 2025 21:34:08 +0000 (14:34 -0700)
commitbacdf5a0e69d343e2a380be768c1f277088e35d8
treedceff0d33cd21ed336cb31c8b3fa801bee3b817d
parenta5a7b25d7535ce5d8db0c121ef588bc6ca3a39dc
selftests/bpf: Fix cgroup_xattr/read_cgroupfs_xattr

cgroup_xattr/read_cgroupfs_xattr has two issues:

1. cgroup_xattr/read_cgroupfs_xattr messes up lo without creating a netns
   first. This causes issue with other tests.

   Fix this by using a different hook (lsm.s/file_open) and not messing
   with lo.

2. cgroup_xattr/read_cgroupfs_xattr sets up cgroups without proper
   mount namespaces.

   Fix this by using the existing cgroup helpers. A new helper
   set_cgroup_xattr() is added to set xattr on cgroup files.

Fixes: f4fba2d6d282 ("selftests/bpf: Add tests for bpf_cgroup_read_xattr")
Reported-by: Alexei Starovoitov <ast@kernel.org>
Closes: https://lore.kernel.org/bpf/CAADnVQ+iqMi2HEj_iH7hsx+XJAsqaMWqSDe4tzcGAnehFWA9Sw@mail.gmail.com/
Signed-off-by: Song Liu <song@kernel.org>
Tested-by: Eduard Zingerman <eddyz87@gmail.com>
Tested-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Link: https://lore.kernel.org/r/20250627191221.765921-1-song@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/cgroup_helpers.c
tools/testing/selftests/bpf/cgroup_helpers.h
tools/testing/selftests/bpf/prog_tests/cgroup_xattr.c
tools/testing/selftests/bpf/progs/read_cgroupfs_xattr.c