Patch "selftests/bpf: Fix flaky cgroup_iter_sleepable subtest" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    selftests/bpf: Fix flaky cgroup_iter_sleepable subtest

to the 6.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     selftests-bpf-fix-flaky-cgroup_iter_sleepable-subtes.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c820a048112793b96dde618ef0f80a2d5ba874ec
Author: Yonghong Song <yonghong.song@xxxxxxxxx>
Date:   Sun Aug 27 08:05:51 2023 -0700

    selftests/bpf: Fix flaky cgroup_iter_sleepable subtest
    
    [ Upstream commit 5439cfa7fe612e7d02d5a1234feda3fa6e483ba7 ]
    
    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: 3b22f98e5a05 ("selftests/bpf: Add path_fd-based BPF_OBJ_PIN and BPF_OBJ_GET tests")
    Signed-off-by: Yonghong Song <yonghong.song@xxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20230827150551.1743497-1-yonghong.song@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_obj_pinning.c b/tools/testing/selftests/bpf/prog_tests/bpf_obj_pinning.c
index 31f1e815f6719..ee0458a5ce789 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_obj_pinning.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_obj_pinning.c
@@ -8,6 +8,7 @@
 #include <linux/unistd.h>
 #include <linux/mount.h>
 #include <sys/syscall.h>
+#include "bpf/libbpf_internal.h"
 
 static inline int sys_fsopen(const char *fsname, unsigned flags)
 {
@@ -155,7 +156,7 @@ static void validate_pin(int map_fd, const char *map_name, int src_value,
 	ASSERT_OK(err, "obj_pin");
 
 	/* cleanup */
-	if (pin_opts.path_fd >= 0)
+	if (path_kind == PATH_FD_REL && pin_opts.path_fd >= 0)
 		close(pin_opts.path_fd);
 	if (old_cwd[0])
 		ASSERT_OK(chdir(old_cwd), "restore_cwd");
@@ -220,7 +221,7 @@ static void validate_get(int map_fd, const char *map_name, int src_value,
 		goto cleanup;
 
 	/* cleanup */
-	if (get_opts.path_fd >= 0)
+	if (path_kind == PATH_FD_REL && get_opts.path_fd >= 0)
 		close(get_opts.path_fd);
 	if (old_cwd[0])
 		ASSERT_OK(chdir(old_cwd), "restore_cwd");



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux