]> granicus.if.org Git - strace/commitdiff
Fix handling of unexpected tracees when PTRACE_SEIZE is not in use
authorDmitry V. Levin <ldv@altlinux.org>
Sun, 6 Aug 2017 13:27:07 +0000 (13:27 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 6 Aug 2017 13:27:07 +0000 (13:27 +0000)
* strace.c (maybe_allocate_tcb) <WIFSTOPPED(status) && !followfork>:
The expected ptrace stop signal in case of !use seize is not
syscall_trap_sig but SIGSTOP.  An idea of using PTRACE_GETSIGINFO to
distinguish signal stops that should be re-injected from other kinds
of stops didn't work out due to kernel implementation peculiarities
of initial ptrace-stop.

strace.c

index 5a2adf02c8724e3d797683ead4b7219c648b5360..9217efe4c486631e4b2b8aaf4d35a3b4f9a78915 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -2095,10 +2095,15 @@ maybe_allocate_tcb(const int pid, int status)
                 * This can happen if a clone call misused CLONE_PTRACE itself.
                 */
                unsigned int sig = WSTOPSIG(status);
-               unsigned int event = (unsigned int) status >> 16;
 
-               if (event == PTRACE_EVENT_STOP || sig == syscall_trap_sig)
-                       sig = 0;
+               if (use_seize) {
+                       unsigned int event = (unsigned int) status >> 16;
+                       if (event == PTRACE_EVENT_STOP)
+                               sig = 0;
+               } else {
+                       if (sig == SIGSTOP)
+                               sig = 0;
+               }
 
                ptrace(PTRACE_DETACH, pid, NULL, (unsigned long) sig);
                error_msg("Detached unknown pid %d%s%s", pid,