netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf/selftests: Fix namespace mount setup in tc_redirect
@ 2022-01-04 12:10 Jiri Olsa
  2022-01-05 12:40 ` patchwork-bot+netdevbpf
  2022-01-05 20:40 ` Andrii Nakryiko
  0 siblings, 2 replies; 6+ messages in thread
From: Jiri Olsa @ 2022-01-04 12:10 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: Jussi Maki, Hangbin Liu, netdev, bpf, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh

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.

Cc: Jussi Maki <joamaki@gmail.com>
Reported-by: Hangbin Liu <haliu@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/testing/selftests/bpf/prog_tests/tc_redirect.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
index 4b18b73df10b..c2426df58e17 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;
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf/selftests: Fix namespace mount setup in tc_redirect
  2022-01-04 12:10 [PATCH] bpf/selftests: Fix namespace mount setup in tc_redirect Jiri Olsa
@ 2022-01-05 12:40 ` patchwork-bot+netdevbpf
  2022-01-05 20:40 ` Andrii Nakryiko
  1 sibling, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-05 12:40 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: ast, daniel, andrii, joamaki, haliu, netdev, bpf, kafai,
	songliubraving, yhs, john.fastabend, kpsingh

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Tue,  4 Jan 2022 13:10:30 +0100 you wrote:
> 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)
> 
> [...]

Here is the summary with links:
  - bpf/selftests: Fix namespace mount setup in tc_redirect
    https://git.kernel.org/bpf/bpf-next/c/5e22dd186267

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf/selftests: Fix namespace mount setup in tc_redirect
  2022-01-04 12:10 [PATCH] bpf/selftests: Fix namespace mount setup in tc_redirect Jiri Olsa
  2022-01-05 12:40 ` patchwork-bot+netdevbpf
@ 2022-01-05 20:40 ` Andrii Nakryiko
  2022-01-06  7:35   ` Jiri Olsa
  1 sibling, 1 reply; 6+ messages in thread
From: Andrii Nakryiko @ 2022-01-05 20:40 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Jussi Maki,
	Hangbin Liu, Networking, bpf, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh

On Tue, Jan 4, 2022 at 4:10 AM Jiri Olsa <jolsa@redhat.com> wrote:
>
> 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.

Hey Jiri,

Thanks for the fix. Did you try making tc_redirect non-serial again
(s/serial_test_tc_redirect/test_tc_redirect/) and doing parallelized
test_progs run (./test_progs -j) in a tight loop for a while? I
suspect this might have been an issue forcing us to make this test
serial in the first place, so now that it's fixed, we can make
parallel test_progs a bit faster.

>
> Cc: Jussi Maki <joamaki@gmail.com>
> Reported-by: Hangbin Liu <haliu@redhat.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/testing/selftests/bpf/prog_tests/tc_redirect.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> index 4b18b73df10b..c2426df58e17 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;
> --
> 2.33.1
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf/selftests: Fix namespace mount setup in tc_redirect
  2022-01-05 20:40 ` Andrii Nakryiko
@ 2022-01-06  7:35   ` Jiri Olsa
  2022-01-17 19:25     ` Jiri Olsa
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2022-01-06  7:35 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Jussi Maki,
	Hangbin Liu, Networking, bpf, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh

On Wed, Jan 05, 2022 at 12:40:34PM -0800, Andrii Nakryiko wrote:
> On Tue, Jan 4, 2022 at 4:10 AM Jiri Olsa <jolsa@redhat.com> wrote:
> >
> > 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.
> 
> Hey Jiri,
> 
> Thanks for the fix. Did you try making tc_redirect non-serial again
> (s/serial_test_tc_redirect/test_tc_redirect/) and doing parallelized
> test_progs run (./test_progs -j) in a tight loop for a while? I
> suspect this might have been an issue forcing us to make this test
> serial in the first place, so now that it's fixed, we can make
> parallel test_progs a bit faster.

hi,
right, will try

jirka

> 
> >
> > Cc: Jussi Maki <joamaki@gmail.com>
> > Reported-by: Hangbin Liu <haliu@redhat.com>
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/testing/selftests/bpf/prog_tests/tc_redirect.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c
> > index 4b18b73df10b..c2426df58e17 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;
> > --
> > 2.33.1
> >
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf/selftests: Fix namespace mount setup in tc_redirect
  2022-01-06  7:35   ` Jiri Olsa
@ 2022-01-17 19:25     ` Jiri Olsa
  2022-01-19  3:48       ` Andrii Nakryiko
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2022-01-17 19:25 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Jussi Maki,
	Hangbin Liu, Networking, bpf, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh

On Thu, Jan 06, 2022 at 08:35:18AM +0100, Jiri Olsa wrote:
> On Wed, Jan 05, 2022 at 12:40:34PM -0800, Andrii Nakryiko wrote:
> > On Tue, Jan 4, 2022 at 4:10 AM Jiri Olsa <jolsa@redhat.com> wrote:
> > >
> > > 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.
> > 
> > Hey Jiri,
> > 
> > Thanks for the fix. Did you try making tc_redirect non-serial again
> > (s/serial_test_tc_redirect/test_tc_redirect/) and doing parallelized
> > test_progs run (./test_progs -j) in a tight loop for a while? I
> > suspect this might have been an issue forcing us to make this test
> > serial in the first place, so now that it's fixed, we can make
> > parallel test_progs a bit faster.
> 
> hi,
> right, will try

so I can't reproduce the issue in the first place - that means without my
fix and with reverted serial_test_tc_redirect change - by running parallelized
test_progs, could you guys try it?

jirka


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf/selftests: Fix namespace mount setup in tc_redirect
  2022-01-17 19:25     ` Jiri Olsa
@ 2022-01-19  3:48       ` Andrii Nakryiko
  0 siblings, 0 replies; 6+ messages in thread
From: Andrii Nakryiko @ 2022-01-19  3:48 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Jussi Maki,
	Hangbin Liu, Networking, bpf, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh

On Mon, Jan 17, 2022 at 11:25 AM Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Thu, Jan 06, 2022 at 08:35:18AM +0100, Jiri Olsa wrote:
> > On Wed, Jan 05, 2022 at 12:40:34PM -0800, Andrii Nakryiko wrote:
> > > On Tue, Jan 4, 2022 at 4:10 AM Jiri Olsa <jolsa@redhat.com> wrote:
> > > >
> > > > 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.
> > >
> > > Hey Jiri,
> > >
> > > Thanks for the fix. Did you try making tc_redirect non-serial again
> > > (s/serial_test_tc_redirect/test_tc_redirect/) and doing parallelized
> > > test_progs run (./test_progs -j) in a tight loop for a while? I
> > > suspect this might have been an issue forcing us to make this test
> > > serial in the first place, so now that it's fixed, we can make
> > > parallel test_progs a bit faster.
> >
> > hi,
> > right, will try
>
> so I can't reproduce the issue in the first place - that means without my
> fix and with reverted serial_test_tc_redirect change - by running parallelized
> test_progs, could you guys try it?
>

I tried it for a bunch of iterations and didn't repro it either.
Doesn't mean much as CI's environment is different, but I think it
might be worth making it parallel again and see if it reproes in CI
again.

> jirka
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-19  3:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-04 12:10 [PATCH] bpf/selftests: Fix namespace mount setup in tc_redirect Jiri Olsa
2022-01-05 12:40 ` patchwork-bot+netdevbpf
2022-01-05 20:40 ` Andrii Nakryiko
2022-01-06  7:35   ` Jiri Olsa
2022-01-17 19:25     ` Jiri Olsa
2022-01-19  3:48       ` Andrii Nakryiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).