Skip to content

Commit

Permalink
selftests/x86/ptrace_syscall: Fix for yet more glibc interference
Browse files Browse the repository at this point in the history
glibc keeps getting cleverer, and my version now turns raise() into
more than one syscall.  Since the test relies on ptrace seeing an
exact set of syscalls, this breaks the test.  Replace raise(SIGSTOP)
with syscall(SYS_tgkill, ...) to force glibc to get out of our way.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kselftest@vger.kernel.org
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/bc80338b453afa187bc5f895bd8e2c8d6e264da2.1521300271.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Andy Lutomirski authored and Ingo Molnar committed Mar 19, 2018
1 parent bb8c13d commit 4b0b37d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/testing/selftests/x86/ptrace_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ static void test_ptrace_syscall_restart(void)
if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0)
err(1, "PTRACE_TRACEME");

pid_t pid = getpid(), tid = syscall(SYS_gettid);

printf("\tChild will make one syscall\n");
raise(SIGSTOP);
syscall(SYS_tgkill, pid, tid, SIGSTOP);

syscall(SYS_gettid, 10, 11, 12, 13, 14, 15);
_exit(0);
Expand Down Expand Up @@ -301,9 +303,11 @@ static void test_restart_under_ptrace(void)
if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0)
err(1, "PTRACE_TRACEME");

pid_t pid = getpid(), tid = syscall(SYS_gettid);

printf("\tChild will take a nap until signaled\n");
setsigign(SIGUSR1, SA_RESTART);
raise(SIGSTOP);
syscall(SYS_tgkill, pid, tid, SIGSTOP);

syscall(SYS_pause, 0, 0, 0, 0, 0, 0);
_exit(0);
Expand Down

0 comments on commit 4b0b37d

Please sign in to comment.