Skip to contentSkip to conversation

selftests/seccomp: Remove SIGSTOP si_pid check

PATCH In review Kees Cook 2 participants 3 messages Dec 6, 2018 – Dec 12, 2018

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 selftests/seccomp: Remove SIGSTOP si_pid check

Commit f149b3155744 ("signal: Never allocate siginfo for SIGKILL or SIGSTOP") means that the seccomp selftest cannot check si_pid under SIGSTOP anymore. Since it's believed[1] there are no other userspace things depending on the old behavior, this removes the behavioral check in the selftest, since it's more a "extra" sanity check (which turns out, maybe, not to have been useful to test).

[1] https://lkml.kernel.org/r/CAGXu5jJaZAOzP1qFz66tYrtbuywqb+UN2SOA1VLHpCCOiYvYeg at mail.gmail.com

Reported-by Tycho Andersen <tycho at tycho.ws>
Suggested-by Eric W. Biederman <ebiederm at xmission.com>
Signed-off-by Kees Cook <keescook at chromium.org>

---
Shuah, can you make sure that Linus gets this before v4.20 is released? Thanks!

---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +7 -2
index e1473234968d..c9a2abf8be1b 100644
@@ -2731,9 +2731,14 @@ TEST(syscall_restart)
 	ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
 	ASSERT_EQ(true, WIFSTOPPED(status));
 	ASSERT_EQ(SIGSTOP, WSTOPSIG(status));
-	/* Verify signal delivery came from parent now. */
 	ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info));
-	EXPECT_EQ(getpid(), info.si_pid);
+	/*
+	 * There is no siginfo on SIGSTOP any more, so we can't verify
+	 * signal delivery came from parent now (getpid() == info.si_pid).
+	 * https://lkml.kernel.org/r/CAGXu5jJaZAOzP1qFz66tYrtbuywqb+UN2SOA1VLHpCCOiYvYeg at mail.gmail.com
+	 * At least verify the SIGSTOP via PTRACE_GETSIGINFO.
+	 */
+	EXPECT_EQ(SIGSTOP, info.si_signo);
 
 	/* Restart nanosleep with SIGCONT, which triggers restart_syscall. */
 	ASSERT_EQ(0, kill(child_pid, SIGCONT));
Signature · 5 lines
2.17.1


-- 
Kees Cook
author
#1 lore raw
Quoted 8 lines · Kees Cook

Commit f149b3155744 ("signal: Never allocate siginfo for SIGKILL or SIGSTOP") means that the seccomp selftest cannot check si_pid under SIGSTOP anymore. Since it's believed[1] there are no other userspace things depending on the old behavior, this removes the behavioral check in the selftest, since it's more a "extra" sanity check (which turns out, maybe, not to have been useful to test).

Quoted 7 lines

[1] https://lkml.kernel.org/r/CAGXu5jJaZAOzP1qFz66tYrtbuywqb+UN2SOA1VLHpCCOiYvYeg at mail.gmail.com

Reported-by Tycho Andersen <tycho at tycho.ws>
Suggested-by Eric W. Biederman <ebiederm at xmission.com>
Signed-off-by Kees Cook <keescook at chromium.org>

---
Shuah, can you make sure that Linus gets this before v4.20 is released? Thanks!

Ping. Shuah, can you get this to Linus (or should I send it directly?)

Thanks!

-Kees

Quoted 31 lines
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +7 -3
index e1473234968d..c9a2abf8be1b 100644
@@ -2731,9 +2731,14 @@ TEST(syscall_restart)
        ASSERT_EQ(child_pid, waitpid(child_pid, &status, 0));
        ASSERT_EQ(true, WIFSTOPPED(status));
        ASSERT_EQ(SIGSTOP, WSTOPSIG(status));
-       /* Verify signal delivery came from parent now. */
        ASSERT_EQ(0, ptrace(PTRACE_GETSIGINFO, child_pid, NULL, &info));
-       EXPECT_EQ(getpid(), info.si_pid);
+       /*
+        * There is no siginfo on SIGSTOP any more, so we can't verify
+        * signal delivery came from parent now (getpid() == info.si_pid).
+        * https://lkml.kernel.org/r/CAGXu5jJaZAOzP1qFz66tYrtbuywqb+UN2SOA1VLHpCCOiYvYeg at mail.gmail.com
+        * At least verify the SIGSTOP via PTRACE_GETSIGINFO.
+        */
+       EXPECT_EQ(SIGSTOP, info.si_signo);
 
        /* Restart nanosleep with SIGCONT, which triggers restart_syscall. */
        ASSERT_EQ(0, kill(child_pid, SIGCONT));
--

2.17.1

--
Kees Cook

Signature · 1 line
Kees Cook
maintainer
#2 lore raw
Quoted 11 lines · Kees Cook
Quoted 10 lines · Kees Cook

Commit f149b3155744 ("signal: Never allocate siginfo for SIGKILL or SIGSTOP") means that the seccomp selftest cannot check si_pid under SIGSTOP anymore. Since it's believed[1] there are no other userspace things depending on the old behavior, this removes the behavioral check in the selftest, since it's more a "extra" sanity check (which turns out, maybe, not to have been useful to test).

[1] https://lkml.kernel.org/r/CAGXu5jJaZAOzP1qFz66tYrtbuywqb+UN2SOA1VLHpCCOiYvYeg at mail.gmail.com

Quoted 8 lines
Quoted 5 lines
Reported-by Tycho Andersen <tycho at tycho.ws>
Suggested-by Eric W. Biederman <ebiederm at xmission.com>
Signed-off-by Kees Cook <keescook at chromium.org>

---
Shuah, can you make sure that Linus gets this before v4.20 is released? Thanks!

Ping. Shuah, can you get this to Linus (or should I send it directly?)

I will send this. Thanks for the ping.

-- Shuah