selftests/x86/ptrace_syscall: Fix for yet more glibc interference
Subsystems (3)
PATCH 1/1 selftests/x86/ptrace_syscall: Fix for yet more glibc interference
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.
Cc stable at vger.kernel.org
Signed-off-by Andy Lutomirski <luto at kernel.org>
--- tools/testing/selftests/x86/ptrace_syscall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/x86/ptrace_syscall.c +6 -2
@@ -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 );
@@ -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 );
Signature · 6 lines
2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
tip-bot for Andy Lutomirski
merge botselftests/x86/ptrace_syscall: Fix for yet more glibc interference
Commit-ID: 4b0b37d4cc54b21a6ecad7271cbc850555869c62 Gitweb: https://git.kernel.org/tip/4b0b37d4cc54b21a6ecad7271cbc850555869c62 Author: Andy Lutomirski <[email protected]> AuthorDate: Sat, 17 Mar 2018 08:25:07 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 19 Mar 2018 09:06:15 +0100
selftests/x86/ptrace_syscall: Fix for yet more glibc interference
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 <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Link http://lkml.kernel.org/r/bc80338b453afa187bc5f895bd8e2c8d6e264da2.1521300271.git.luto@kernel.org open here
Signed-off-by Ingo Molnar <[email protected]>
--- tools/testing/selftests/x86/ptrace_syscall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/x86/ptrace_syscall.c +6 -2
@@ -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 );
@@ -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 );