linux-stable/tools
Yonghong Song 33da1bcbfa selftests/bpf: Fix flaky cgroup_iter_sleepable subtest
[ Upstream commit 5439cfa7fe ]

Occasionally, with './test_progs -j' on my vm, I will hit the
following failure:

  test_cgrp_local_storage:PASS:join_cgroup /cgrp_local_storage 0 nsec
  test_cgroup_iter_sleepable:PASS:skel_open 0 nsec
  test_cgroup_iter_sleepable:PASS:skel_load 0 nsec
  test_cgroup_iter_sleepable:PASS:attach_iter 0 nsec
  test_cgroup_iter_sleepable:PASS:iter_create 0 nsec
  test_cgroup_iter_sleepable:FAIL:cgroup_id unexpected cgroup_id: actual 1 != expected 2812
  #48/5    cgrp_local_storage/cgroup_iter_sleepable:FAIL
  #48      cgrp_local_storage:FAIL

Finally, I decided to do some investigation since the test is introduced
by myself. It turns out the reason is due to cgroup_fd with value 0.
In cgroup_iter, a cgroup_fd of value 0 means the root cgroup.

	/* from cgroup_iter.c */
        if (fd)
                cgrp = cgroup_v1v2_get_from_fd(fd);
        else if (id)
                cgrp = cgroup_get_from_id(id);
        else /* walk the entire hierarchy by default. */
                cgrp = cgroup_get_from_path("/");

That is why we got cgroup_id 1 instead of expected 2812.

Why we got a cgroup_fd 0? Nobody should really touch 'stdin' (fd 0) in
test_progs. I traced 'close' syscall with stack trace and found the root
cause, which is a bug in bpf_obj_pinning.c. Basically, the code closed
fd 0 although it should not. Fixing the bug in bpf_obj_pinning.c also
resolved the above cgroup_iter_sleepable subtest failure.

Fixes: 3b22f98e5a ("selftests/bpf: Add path_fd-based BPF_OBJ_PIN and BPF_OBJ_GET tests")
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230827150551.1743497-1-yonghong.song@linux.dev
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-19 12:30:15 +02:00
..
accounting
arch asm-generic: regression fix for 6.5 2023-08-18 18:13:36 +02:00
bootconfig
bpf bpftool: Use a local bpf_perf_event_value to fix accessing its fields 2023-09-13 09:53:02 +02:00
build perf build: Fix broken feature check for libtracefs due to external lib changes 2023-07-11 13:17:05 -03:00
certs
cgroup
counter tools/counter: Makefile: Replace rmdir by rm to avoid make,clean failure 2023-07-24 10:29:52 -04:00
debugging
edid
firewire
firmware
gpio
hv vmbus_testing: fix wrong python syntax for integer value comparison 2023-07-23 23:19:30 +00:00
iio
include tools/nolibc: fix up startup failures for -O0 under gcc < 11.1.0 2023-09-13 09:53:01 +02:00
io_uring
kvm/kvm_stat
laptop
leds
lib libbpf: Set close-on-exec flag on gzopen 2023-09-13 09:53:06 +02:00
memory-model
mm tools/mm: fix undefined reference to pthread_once 2023-09-19 12:30:13 +02:00
net/ynl tools: ynl-gen: fix parse multi-attr enum attribute 2023-07-26 13:38:23 -07:00
objtool objtool/x86: Fixup frame-pointer vs rethunk 2023-08-17 00:44:35 +02:00
pci
pcmcia
perf perf test stat_bpf_counters_cgrp: Enhance perf stat cgroup BPF counter test 2023-09-19 12:30:15 +02:00
power platform-drivers-x86 for v6.5-1 2023-06-30 14:50:00 -07:00
rcu
scripts
spi
testing selftests/bpf: Fix flaky cgroup_iter_sleepable subtest 2023-09-19 12:30:15 +02:00
thermal
time
tracing
usb
verification
virtio tools/virtio: fix build break for aarch64 2023-06-27 10:47:08 -04:00
wmi
workqueue
Makefile