Patch "bpf/selftests: Fix namespace mount setup in tc_redirect" has been added to the 5.15-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

    bpf/selftests: Fix namespace mount setup in tc_redirect

to the 5.15-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:
     bpf-selftests-fix-namespace-mount-setup-in-tc_redire.patch
and it can be found in the queue-5.15 subdirectory.

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



commit 80db4bb97e035464fc615ed937104464e8024fdd
Author: Jiri Olsa <jolsa@xxxxxxxxxx>
Date:   Tue Jan 4 13:10:30 2022 +0100

    bpf/selftests: Fix namespace mount setup in tc_redirect
    
    [ Upstream commit 5e22dd18626726028a93ff1350a8a71a00fd843d ]
    
    The tc_redirect umounts /sys in the new namespace, which can be
    mounted as shared and cause global umount. The lazy umount also
    takes down mounted trees under /sys like debugfs, which won't be
    available after sysfs mounts again and could cause fails in other
    tests.
    
      # cat /proc/self/mountinfo | grep debugfs
      34 23 0:7 / /sys/kernel/debug rw,nosuid,nodev,noexec,relatime shared:14 - debugfs debugfs rw
      # cat /proc/self/mountinfo | grep sysfs
      23 86 0:22 / /sys rw,nosuid,nodev,noexec,relatime shared:2 - sysfs sysfs rw
      # mount | grep debugfs
      debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
    
      # ./test_progs -t tc_redirect
      #164 tc_redirect:OK
      Summary: 1/4 PASSED, 0 SKIPPED, 0 FAILED
    
      # mount | grep debugfs
      # cat /proc/self/mountinfo | grep debugfs
      # cat /proc/self/mountinfo | grep sysfs
      25 86 0:22 / /sys rw,relatime shared:2 - sysfs sysfs rw
    
    Making the sysfs private under the new namespace so the umount won't
    trigger the global sysfs umount.
    
    Reported-by: Hangbin Liu <haliu@xxxxxxxxxx>
    Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Cc: Jussi Maki <joamaki@xxxxxxxxx>
    Link: https://lore.kernel.org/bpf/20220104121030.138216-1-jolsa@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
index e7201ba29ccd6..47e3159729d21 100644
--- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
+++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
@@ -105,6 +105,13 @@ static int setns_by_fd(int nsfd)
 	if (!ASSERT_OK(err, "unshare"))
 		return err;
 
+	/* Make our /sys mount private, so the following umount won't
+	 * trigger the global umount in case it's shared.
+	 */
+	err = mount("none", "/sys", NULL, MS_PRIVATE, NULL);
+	if (!ASSERT_OK(err, "remount private /sys"))
+		return err;
+
 	err = umount2("/sys", MNT_DETACH);
 	if (!ASSERT_OK(err, "umount2 /sys"))
 		return err;



[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