* Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs @ 2019-01-17 0:01 shuah 2019-01-17 0:30 ` Kees Cook 0 siblings, 1 reply; 10+ messages in thread From: shuah @ 2019-01-17 0:01 UTC (permalink / raw) To: Kees Cook, jmorris Cc: torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, shuah Hi Kees and James, seccomp_bpf test hangs right after the following test passes with EBUSY. Please see log at the end. /* Installing a second listener in the chain should EBUSY */ EXPECT_EQ(user_trap_syscall(__NR_getpid, SECCOMP_FILTER_FLAG_NEW_LISTENER), -1); EXPECT_EQ(errno, EBUSY); The user_notification_basic test starts running I assume and then the hang. The only commit I see that could be suspect is the following as it talks about adding SECCOMP_RET_USER_NOTIF commit d9a7fa67b4bfe6ce93ee9aab23ae2e7ca0763e84 Merge: f218a29c25ad 55b8cbe470d1 Author: Linus Torvalds <torvalds@linux-foundation.org> Date: Wed Jan 2 09:48:13 2019 -0800 Merge branch 'next-seccomp' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security Pull seccomp updates from James Morris: - Add SECCOMP_RET_USER_NOTIF - seccomp fixes for sparse warnings and s390 build (Tycho) * 'next-seccomp' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: seccomp, s390: fix build for syscall type change seccomp: fix poor type promotion samples: add an example of seccomp user trap seccomp: add a return code to trap to userspace seccomp: switch system call argument type to void * seccomp: hoist struct seccomp_data recalculation higher Any ideas on how to proceed? Here is the log. The following reproduces the problem. make -C tools/testing/selftests/seccomp/ run_tests seccomp_bpf.c:2947:global.get_metadata:Expected 0 (0) == seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_LOG, &prog) (18446744073709551615) seccomp_bpf.c:2959:global.get_metadata:Expected 1 (1) == read(pipefd[0], &buf, 1) (0) global.get_metadata: Test terminated by assertion [ FAIL ] global.get_metadata [ RUN ] global.user_notification_basic seccomp_bpf.c:3036:global.user_notification_basic:Expected 0 (0) == WEXITSTATUS(status) (1) seccomp_bpf.c:3039:global.user_notification_basic:Expected seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) seccomp_bpf.c:3040:global.user_notification_basic:Expected seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) seccomp_bpf.c:3041:global.user_notification_basic:Expected seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) seccomp_bpf.c:3042:global.user_notification_basic:Expected seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) seccomp_bpf.c:3047:global.user_notification_basic:Expected listener (18446744073709551615) >= 0 (0) seccomp_bpf.c:3053:global.user_notification_basic:Expected errno (13) == EBUSY (16) thanks, -- Shuah ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs 2019-01-17 0:01 Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs shuah @ 2019-01-17 0:30 ` Kees Cook 2019-01-17 0:44 ` Tycho Andersen 0 siblings, 1 reply; 10+ messages in thread From: Kees Cook @ 2019-01-17 0:30 UTC (permalink / raw) To: shuah, Tycho Andersen Cc: James Morris, Linus Torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK On Wed, Jan 16, 2019 at 4:01 PM shuah <shuah@kernel.org> wrote: > > Hi Kees and James, > > seccomp_bpf test hangs right after the following test passes > with EBUSY. Please see log at the end. > > /* Installing a second listener in the chain should EBUSY */ > EXPECT_EQ(user_trap_syscall(__NR_getpid, > SECCOMP_FILTER_FLAG_NEW_LISTENER), > -1); > EXPECT_EQ(errno, EBUSY); > > > The user_notification_basic test starts running I assume and then > the hang. > > The only commit I see that could be suspect is the following as > it talks about adding SECCOMP_RET_USER_NOTIF > > commit d9a7fa67b4bfe6ce93ee9aab23ae2e7ca0763e84 > Merge: f218a29c25ad 55b8cbe470d1 > Author: Linus Torvalds <torvalds@linux-foundation.org> > Date: Wed Jan 2 09:48:13 2019 -0800 > > Merge branch 'next-seccomp' of > git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security > > Pull seccomp updates from James Morris: > > - Add SECCOMP_RET_USER_NOTIF > > - seccomp fixes for sparse warnings and s390 build (Tycho) > > * 'next-seccomp' of > git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: > seccomp, s390: fix build for syscall type change > seccomp: fix poor type promotion > samples: add an example of seccomp user trap > seccomp: add a return code to trap to userspace > seccomp: switch system call argument type to void * > seccomp: hoist struct seccomp_data recalculation higher > > > Any ideas on how to proceed? Here is the log. The following > reproduces the problem. > > make -C tools/testing/selftests/seccomp/ run_tests > > > seccomp_bpf.c:2947:global.get_metadata:Expected 0 (0) == > seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_LOG, &prog) > (18446744073709551615) > seccomp_bpf.c:2959:global.get_metadata:Expected 1 (1) == read(pipefd[0], > &buf, 1) (0) > global.get_metadata: Test terminated by assertion > [ FAIL ] global.get_metadata > [ RUN ] global.user_notification_basic > seccomp_bpf.c:3036:global.user_notification_basic:Expected 0 (0) == > WEXITSTATUS(status) (1) > seccomp_bpf.c:3039:global.user_notification_basic:Expected > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > seccomp_bpf.c:3040:global.user_notification_basic:Expected > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > seccomp_bpf.c:3041:global.user_notification_basic:Expected > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > seccomp_bpf.c:3042:global.user_notification_basic:Expected > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > seccomp_bpf.c:3047:global.user_notification_basic:Expected listener > (18446744073709551615) >= 0 (0) > seccomp_bpf.c:3053:global.user_notification_basic:Expected errno (13) == > EBUSY (16) Looks like the test is unfriendly when running the current selftest on an old kernel version. A quick look seems like it's missing some ASSERT_* cases where EXPECT_* is used. I'll send a patch. -- Kees Cook ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs 2019-01-17 0:30 ` Kees Cook @ 2019-01-17 0:44 ` Tycho Andersen 2019-01-17 1:26 ` shuah 2019-01-17 16:11 ` Kees Cook 0 siblings, 2 replies; 10+ messages in thread From: Tycho Andersen @ 2019-01-17 0:44 UTC (permalink / raw) To: Kees Cook Cc: shuah, James Morris, Linus Torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK On Wed, Jan 16, 2019 at 04:30:26PM -0800, Kees Cook wrote: > On Wed, Jan 16, 2019 at 4:01 PM shuah <shuah@kernel.org> wrote: > > > > Hi Kees and James, > > > > seccomp_bpf test hangs right after the following test passes > > with EBUSY. Please see log at the end. > > > > /* Installing a second listener in the chain should EBUSY */ > > EXPECT_EQ(user_trap_syscall(__NR_getpid, > > SECCOMP_FILTER_FLAG_NEW_LISTENER), > > -1); > > EXPECT_EQ(errno, EBUSY); > > > > > > The user_notification_basic test starts running I assume and then > > the hang. > > > > The only commit I see that could be suspect is the following as > > it talks about adding SECCOMP_RET_USER_NOTIF > > > > commit d9a7fa67b4bfe6ce93ee9aab23ae2e7ca0763e84 > > Merge: f218a29c25ad 55b8cbe470d1 > > Author: Linus Torvalds <torvalds@linux-foundation.org> > > Date: Wed Jan 2 09:48:13 2019 -0800 > > > > Merge branch 'next-seccomp' of > > git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security > > > > Pull seccomp updates from James Morris: > > > > - Add SECCOMP_RET_USER_NOTIF > > > > - seccomp fixes for sparse warnings and s390 build (Tycho) > > > > * 'next-seccomp' of > > git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: > > seccomp, s390: fix build for syscall type change > > seccomp: fix poor type promotion > > samples: add an example of seccomp user trap > > seccomp: add a return code to trap to userspace > > seccomp: switch system call argument type to void * > > seccomp: hoist struct seccomp_data recalculation higher > > > > > > Any ideas on how to proceed? Here is the log. The following > > reproduces the problem. > > > > make -C tools/testing/selftests/seccomp/ run_tests > > > > > > seccomp_bpf.c:2947:global.get_metadata:Expected 0 (0) == > > seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_LOG, &prog) > > (18446744073709551615) > > seccomp_bpf.c:2959:global.get_metadata:Expected 1 (1) == read(pipefd[0], > > &buf, 1) (0) > > global.get_metadata: Test terminated by assertion > > [ FAIL ] global.get_metadata > > [ RUN ] global.user_notification_basic > > seccomp_bpf.c:3036:global.user_notification_basic:Expected 0 (0) == > > WEXITSTATUS(status) (1) > > seccomp_bpf.c:3039:global.user_notification_basic:Expected > > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > > seccomp_bpf.c:3040:global.user_notification_basic:Expected > > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > > seccomp_bpf.c:3041:global.user_notification_basic:Expected > > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > > seccomp_bpf.c:3042:global.user_notification_basic:Expected > > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > > seccomp_bpf.c:3047:global.user_notification_basic:Expected listener > > (18446744073709551615) >= 0 (0) > > seccomp_bpf.c:3053:global.user_notification_basic:Expected errno (13) == > > EBUSY (16) > > Looks like the test is unfriendly when running the current selftest on > an old kernel version. A quick look seems like it's missing some > ASSERT_* cases where EXPECT_* is used. I'll send a patch. ASSERT will kill the test case though right? I thought we were supposed to use EXPECT when we wanted it to keep going. In particular, it looks like in the get_metadata test, we should be using expect instead of assert in some places, so we can get to the write() that does the synchronization. Something like, diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 067cb4607d6c..4d2508af2483 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -2943,11 +2943,11 @@ TEST(get_metadata) }; /* one with log, one without */ - ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, + EXPECT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_LOG, &prog)); - ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)); + EXPECT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)); - ASSERT_EQ(0, close(pipefd[0])); + EXPECT_EQ(0, close(pipefd[0])); ASSERT_EQ(1, write(pipefd[1], "1", 1)); ASSERT_EQ(0, close(pipefd[1])); But also, is running new tests on an old kernel expected to work? I didn't know that :). Tycho ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs 2019-01-17 0:44 ` Tycho Andersen @ 2019-01-17 1:26 ` shuah 2019-01-17 16:12 ` Kees Cook 2019-01-17 16:11 ` Kees Cook 1 sibling, 1 reply; 10+ messages in thread From: shuah @ 2019-01-17 1:26 UTC (permalink / raw) To: Tycho Andersen, Kees Cook Cc: James Morris, Linus Torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, shuah On 1/16/19 5:44 PM, Tycho Andersen wrote: > On Wed, Jan 16, 2019 at 04:30:26PM -0800, Kees Cook wrote: >> On Wed, Jan 16, 2019 at 4:01 PM shuah <shuah@kernel.org> wrote: >>> >>> Hi Kees and James, >>> >>> seccomp_bpf test hangs right after the following test passes >>> with EBUSY. Please see log at the end. >>> >>> /* Installing a second listener in the chain should EBUSY */ >>> EXPECT_EQ(user_trap_syscall(__NR_getpid, >>> SECCOMP_FILTER_FLAG_NEW_LISTENER), >>> -1); >>> EXPECT_EQ(errno, EBUSY); >>> >>> >>> The user_notification_basic test starts running I assume and then >>> the hang. >>> >>> The only commit I see that could be suspect is the following as >>> it talks about adding SECCOMP_RET_USER_NOTIF >>> >>> commit d9a7fa67b4bfe6ce93ee9aab23ae2e7ca0763e84 >>> Merge: f218a29c25ad 55b8cbe470d1 >>> Author: Linus Torvalds <torvalds@linux-foundation.org> >>> Date: Wed Jan 2 09:48:13 2019 -0800 >>> >>> Merge branch 'next-seccomp' of >>> git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security >>> >>> Pull seccomp updates from James Morris: >>> >>> - Add SECCOMP_RET_USER_NOTIF >>> >>> - seccomp fixes for sparse warnings and s390 build (Tycho) >>> >>> * 'next-seccomp' of >>> git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: >>> seccomp, s390: fix build for syscall type change >>> seccomp: fix poor type promotion >>> samples: add an example of seccomp user trap >>> seccomp: add a return code to trap to userspace >>> seccomp: switch system call argument type to void * >>> seccomp: hoist struct seccomp_data recalculation higher >>> >>> >>> Any ideas on how to proceed? Here is the log. The following >>> reproduces the problem. >>> >>> make -C tools/testing/selftests/seccomp/ run_tests >>> >>> >>> seccomp_bpf.c:2947:global.get_metadata:Expected 0 (0) == >>> seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_LOG, &prog) >>> (18446744073709551615) >>> seccomp_bpf.c:2959:global.get_metadata:Expected 1 (1) == read(pipefd[0], >>> &buf, 1) (0) >>> global.get_metadata: Test terminated by assertion >>> [ FAIL ] global.get_metadata >>> [ RUN ] global.user_notification_basic >>> seccomp_bpf.c:3036:global.user_notification_basic:Expected 0 (0) == >>> WEXITSTATUS(status) (1) >>> seccomp_bpf.c:3039:global.user_notification_basic:Expected >>> seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) >>> seccomp_bpf.c:3040:global.user_notification_basic:Expected >>> seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) >>> seccomp_bpf.c:3041:global.user_notification_basic:Expected >>> seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) >>> seccomp_bpf.c:3042:global.user_notification_basic:Expected >>> seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) >>> seccomp_bpf.c:3047:global.user_notification_basic:Expected listener >>> (18446744073709551615) >= 0 (0) >>> seccomp_bpf.c:3053:global.user_notification_basic:Expected errno (13) == >>> EBUSY (16) >> >> Looks like the test is unfriendly when running the current selftest on >> an old kernel version. A quick look seems like it's missing some >> ASSERT_* cases where EXPECT_* is used. I'll send a patch. > > ASSERT will kill the test case though right? I thought we were > supposed to use EXPECT when we wanted it to keep going. In particular, > it looks like in the get_metadata test, we should be using expect > instead of assert in some places, so we can get to the write() that > does the synchronization. Something like, > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 067cb4607d6c..4d2508af2483 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -2943,11 +2943,11 @@ TEST(get_metadata) > }; > > /* one with log, one without */ > - ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, > + EXPECT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, > SECCOMP_FILTER_FLAG_LOG, &prog)); > - ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)); > + EXPECT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)); > > - ASSERT_EQ(0, close(pipefd[0])); > + EXPECT_EQ(0, close(pipefd[0])); > ASSERT_EQ(1, write(pipefd[1], "1", 1)); > ASSERT_EQ(0, close(pipefd[1])); > > > But also, is running new tests on an old kernel expected to work? I > didn't know that :). > I am running Linux 5.0-rc2 and not an older kernel. thanks, -- Shuah ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs 2019-01-17 1:26 ` shuah @ 2019-01-17 16:12 ` Kees Cook 2019-01-17 16:27 ` Tycho Andersen 0 siblings, 1 reply; 10+ messages in thread From: Kees Cook @ 2019-01-17 16:12 UTC (permalink / raw) To: shuah Cc: Tycho Andersen, James Morris, Linus Torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK On Wed, Jan 16, 2019 at 5:26 PM shuah <shuah@kernel.org> wrote: > I am running Linux 5.0-rc2 and not an older kernel. Weird. I couldn't reproduce this on 5.0-rc2, but I did see it on a kernel without seccomp user_notif. Does the patch I sent fix it for you? (And if so, can you take it in your tree?) Thanks! -- Kees Cook ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs 2019-01-17 16:12 ` Kees Cook @ 2019-01-17 16:27 ` Tycho Andersen 2019-01-17 16:41 ` Kees Cook 0 siblings, 1 reply; 10+ messages in thread From: Tycho Andersen @ 2019-01-17 16:27 UTC (permalink / raw) To: Kees Cook Cc: shuah, James Morris, Linus Torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK On Thu, Jan 17, 2019 at 08:12:50AM -0800, Kees Cook wrote: > On Wed, Jan 16, 2019 at 5:26 PM shuah <shuah@kernel.org> wrote: > > I am running Linux 5.0-rc2 and not an older kernel. > > Weird. I couldn't reproduce this on 5.0-rc2, but I did see it on a > kernel without seccomp user_notif. Does the patch I sent fix it for > you? (And if so, can you take it in your tree?) I can reproduce it; you have to run it as non-root. I think your patch is necessary to get it to at least fail. The question is: what should we do about these tests that require real root? Skip them if we're not real-root, I guess? Tycho ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs 2019-01-17 16:27 ` Tycho Andersen @ 2019-01-17 16:41 ` Kees Cook 2019-01-17 16:45 ` Tycho Andersen 0 siblings, 1 reply; 10+ messages in thread From: Kees Cook @ 2019-01-17 16:41 UTC (permalink / raw) To: Tycho Andersen Cc: shuah, James Morris, Linus Torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK On Thu, Jan 17, 2019 at 8:27 AM Tycho Andersen <tycho@tycho.ws> wrote: > > On Thu, Jan 17, 2019 at 08:12:50AM -0800, Kees Cook wrote: > > On Wed, Jan 16, 2019 at 5:26 PM shuah <shuah@kernel.org> wrote: > > > I am running Linux 5.0-rc2 and not an older kernel. > > > > Weird. I couldn't reproduce this on 5.0-rc2, but I did see it on a > > kernel without seccomp user_notif. Does the patch I sent fix it for > > you? (And if so, can you take it in your tree?) > > I can reproduce it; you have to run it as non-root. I think your patch > is necessary to get it to at least fail. The question is: what should > we do about these tests that require real root? Skip them if we're not > real-root, I guess? Hm, maybe use the XFAIL() bit of the harness? Perhaps it's time to make it a root-only test and do internal priv-dropping to test the nnp-requiring parts? I'll add it to the TODO list... -Kees -- Kees Cook ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs 2019-01-17 16:41 ` Kees Cook @ 2019-01-17 16:45 ` Tycho Andersen 2019-01-17 17:53 ` shuah 0 siblings, 1 reply; 10+ messages in thread From: Tycho Andersen @ 2019-01-17 16:45 UTC (permalink / raw) To: Kees Cook Cc: shuah, James Morris, Linus Torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK On Thu, Jan 17, 2019 at 08:41:59AM -0800, Kees Cook wrote: > On Thu, Jan 17, 2019 at 8:27 AM Tycho Andersen <tycho@tycho.ws> wrote: > > > > On Thu, Jan 17, 2019 at 08:12:50AM -0800, Kees Cook wrote: > > > On Wed, Jan 16, 2019 at 5:26 PM shuah <shuah@kernel.org> wrote: > > > > I am running Linux 5.0-rc2 and not an older kernel. > > > > > > Weird. I couldn't reproduce this on 5.0-rc2, but I did see it on a > > > kernel without seccomp user_notif. Does the patch I sent fix it for > > > you? (And if so, can you take it in your tree?) > > > > I can reproduce it; you have to run it as non-root. I think your patch > > is necessary to get it to at least fail. The question is: what should > > we do about these tests that require real root? Skip them if we're not > > real-root, I guess? > > Hm, maybe use the XFAIL() bit of the harness? > > Perhaps it's time to make it a root-only test and do internal > priv-dropping to test the nnp-requiring parts? I'll add it to the TODO > list... Ok, I'll try to send a couple of patches soon to fix some of this up. But at least yours should should stop things from hanging for now. Thanks, Tycho ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs 2019-01-17 16:45 ` Tycho Andersen @ 2019-01-17 17:53 ` shuah 0 siblings, 0 replies; 10+ messages in thread From: shuah @ 2019-01-17 17:53 UTC (permalink / raw) To: Tycho Andersen, Kees Cook Cc: James Morris, Linus Torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, shuah On 1/17/19 9:45 AM, Tycho Andersen wrote: > On Thu, Jan 17, 2019 at 08:41:59AM -0800, Kees Cook wrote: >> On Thu, Jan 17, 2019 at 8:27 AM Tycho Andersen <tycho@tycho.ws> wrote: >>> >>> On Thu, Jan 17, 2019 at 08:12:50AM -0800, Kees Cook wrote: >>>> On Wed, Jan 16, 2019 at 5:26 PM shuah <shuah@kernel.org> wrote: >>>>> I am running Linux 5.0-rc2 and not an older kernel. >>>> >>>> Weird. I couldn't reproduce this on 5.0-rc2, but I did see it on a >>>> kernel without seccomp user_notif. Does the patch I sent fix it for >>>> you? (And if so, can you take it in your tree?) >>> >>> I can reproduce it; you have to run it as non-root. I think your patch >>> is necessary to get it to at least fail. The question is: what should >>> we do about these tests that require real root? Skip them if we're not >>> real-root, I guess? >> >> Hm, maybe use the XFAIL() bit of the harness? >> >> Perhaps it's time to make it a root-only test and do internal >> priv-dropping to test the nnp-requiring parts? I'll add it to the TODO >> list... > Yup that is a good way to handle it. Please skip the test with ksft skip code for non-root runs. > Ok, I'll try to send a couple of patches soon to fix some of this up. > But at least yours should should stop things from hanging for now. > I am going to take Kees's patch to prevent hangs right away. thanks, -- Shuah ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs 2019-01-17 0:44 ` Tycho Andersen 2019-01-17 1:26 ` shuah @ 2019-01-17 16:11 ` Kees Cook 1 sibling, 0 replies; 10+ messages in thread From: Kees Cook @ 2019-01-17 16:11 UTC (permalink / raw) To: Tycho Andersen Cc: shuah, James Morris, Linus Torvalds, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK On Wed, Jan 16, 2019 at 4:44 PM Tycho Andersen <tycho@tycho.ws> wrote: > > On Wed, Jan 16, 2019 at 04:30:26PM -0800, Kees Cook wrote: > > On Wed, Jan 16, 2019 at 4:01 PM shuah <shuah@kernel.org> wrote: > > > > > > Hi Kees and James, > > > > > > seccomp_bpf test hangs right after the following test passes > > > with EBUSY. Please see log at the end. > > > > > > /* Installing a second listener in the chain should EBUSY */ > > > EXPECT_EQ(user_trap_syscall(__NR_getpid, > > > SECCOMP_FILTER_FLAG_NEW_LISTENER), > > > -1); > > > EXPECT_EQ(errno, EBUSY); > > > > > > > > > The user_notification_basic test starts running I assume and then > > > the hang. > > > > > > The only commit I see that could be suspect is the following as > > > it talks about adding SECCOMP_RET_USER_NOTIF > > > > > > commit d9a7fa67b4bfe6ce93ee9aab23ae2e7ca0763e84 > > > Merge: f218a29c25ad 55b8cbe470d1 > > > Author: Linus Torvalds <torvalds@linux-foundation.org> > > > Date: Wed Jan 2 09:48:13 2019 -0800 > > > > > > Merge branch 'next-seccomp' of > > > git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security > > > > > > Pull seccomp updates from James Morris: > > > > > > - Add SECCOMP_RET_USER_NOTIF > > > > > > - seccomp fixes for sparse warnings and s390 build (Tycho) > > > > > > * 'next-seccomp' of > > > git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: > > > seccomp, s390: fix build for syscall type change > > > seccomp: fix poor type promotion > > > samples: add an example of seccomp user trap > > > seccomp: add a return code to trap to userspace > > > seccomp: switch system call argument type to void * > > > seccomp: hoist struct seccomp_data recalculation higher > > > > > > > > > Any ideas on how to proceed? Here is the log. The following > > > reproduces the problem. > > > > > > make -C tools/testing/selftests/seccomp/ run_tests > > > > > > > > > seccomp_bpf.c:2947:global.get_metadata:Expected 0 (0) == > > > seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_LOG, &prog) > > > (18446744073709551615) > > > seccomp_bpf.c:2959:global.get_metadata:Expected 1 (1) == read(pipefd[0], > > > &buf, 1) (0) > > > global.get_metadata: Test terminated by assertion > > > [ FAIL ] global.get_metadata > > > [ RUN ] global.user_notification_basic > > > seccomp_bpf.c:3036:global.user_notification_basic:Expected 0 (0) == > > > WEXITSTATUS(status) (1) > > > seccomp_bpf.c:3039:global.user_notification_basic:Expected > > > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > > > seccomp_bpf.c:3040:global.user_notification_basic:Expected > > > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > > > seccomp_bpf.c:3041:global.user_notification_basic:Expected > > > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > > > seccomp_bpf.c:3042:global.user_notification_basic:Expected > > > seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog) (18446744073709551615) == 0 (0) > > > seccomp_bpf.c:3047:global.user_notification_basic:Expected listener > > > (18446744073709551615) >= 0 (0) > > > seccomp_bpf.c:3053:global.user_notification_basic:Expected errno (13) == > > > EBUSY (16) > > > > Looks like the test is unfriendly when running the current selftest on > > an old kernel version. A quick look seems like it's missing some > > ASSERT_* cases where EXPECT_* is used. I'll send a patch. > > ASSERT will kill the test case though right? I thought we were > supposed to use EXPECT when we wanted it to keep going. In particular, > it looks like in the get_metadata test, we should be using expect > instead of assert in some places, so we can get to the write() that > does the synchronization. Something like, > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 067cb4607d6c..4d2508af2483 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -2943,11 +2943,11 @@ TEST(get_metadata) > }; > > /* one with log, one without */ > - ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, > + EXPECT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, > SECCOMP_FILTER_FLAG_LOG, &prog)); > - ASSERT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)); > + EXPECT_EQ(0, seccomp(SECCOMP_SET_MODE_FILTER, 0, &prog)); > > - ASSERT_EQ(0, close(pipefd[0])); > + EXPECT_EQ(0, close(pipefd[0])); > ASSERT_EQ(1, write(pipefd[1], "1", 1)); > ASSERT_EQ(0, close(pipefd[1])); Yeah, if it breaks badly on a failure, let's do it. > But also, is running new tests on an old kernel expected to work? I > didn't know that :). It should at least not hang. :) -- Kees Cook ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-01-17 17:53 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-01-17 0:01 Linux 5.0-rc2 seccomp_bpf user_notification_basic test hangs shuah 2019-01-17 0:30 ` Kees Cook 2019-01-17 0:44 ` Tycho Andersen 2019-01-17 1:26 ` shuah 2019-01-17 16:12 ` Kees Cook 2019-01-17 16:27 ` Tycho Andersen 2019-01-17 16:41 ` Kees Cook 2019-01-17 16:45 ` Tycho Andersen 2019-01-17 17:53 ` shuah 2019-01-17 16:11 ` Kees Cook
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).