Blame SOURCES/strace-rh1466535.patch

3ca629
commit 1b93f4032a246e0aa43c2f424921e0aace57b994
3ca629
Author: Eugene Syromyatnikov <evgsyr@gmail.com>
3ca629
Date:   Fri Aug 4 11:33:04 2017 +0200
3ca629
3ca629
    Improve handling of unexpected tracees
3ca629
    
3ca629
    When receiving a ptrace stop of an unexpected child, handle it
3ca629
    in the most transparent way possible:
3ca629
    - detach it instead of PTRACE_CONT'ing;
3ca629
    - send it the signal with which it has been stopped.
3ca629
    This should hopefully help to deal with processes that have been created
3ca629
    with misused CLONE_PTRACE flag set.
3ca629
    
3ca629
    * strace.c (maybe_allocate_tcb) <WIFSTOPPED(status) && !followfork>:
3ca629
    Calculate the signal similarly to the way next_event does,
3ca629
    forward it to the unexpected tracee, and detach the tracee.
3ca629
3ca629
commit 7a35b711df127664e7430b2644ae92c75f3d5f67
3ca629
Author: Dmitry V. Levin <ldv@altlinux.org>
3ca629
Date:   Sun Aug 6 13:27:07 2017 +0000
3ca629
3ca629
    Fix handling of unexpected tracees when PTRACE_SEIZE is not in use
3ca629
    
3ca629
    * strace.c (maybe_allocate_tcb) <WIFSTOPPED(status) && !followfork>:
3ca629
    The expected ptrace stop signal in case of !use seize is not
3ca629
    syscall_trap_sig but SIGSTOP.  An idea of using PTRACE_GETSIGINFO to
3ca629
    distinguish signal stops that should be re-injected from other kinds
3ca629
    of stops didn't work out due to kernel implementation peculiarities
3ca629
    of initial ptrace-stop.
3ca629
3ca629
commit 330f4633d5103938982602b6f21f761570e3482c
3ca629
Author: Dmitry V. Levin <ldv@altlinux.org>
3ca629
Date:   Sun Aug 6 15:10:56 2017 +0000
3ca629
3ca629
    Simplify handling of unexpected tracees
3ca629
    
3ca629
    * strace.c (maybe_allocate_tcb) <WIFSTOPPED(status) && !followfork>:
3ca629
    Remove the dance around possible re-injection of WSTOPSIG(status)
3ca629
    as the only observable stop here is the initial ptrace-stop.
3ca629
3ca629
diff -rup a/strace.c b/strace.c
3ca629
--- a/strace.c	2017-08-31 14:04:21.000000000 -0400
3ca629
+++ b/strace.c	2017-08-31 14:51:32.523134570 -0400
3ca629
@@ -1958,11 +1958,15 @@ maybe_allocate_tcb(const int pid, int st
3ca629
 			error_msg("Process %d attached", pid);
3ca629
 		return tcp;
3ca629
 	} else {
3ca629
-		/* This can happen if a clone call used
3ca629
-		 * CLONE_PTRACE itself.
3ca629
+		/*
3ca629
+		 * This can happen if a clone call misused CLONE_PTRACE itself.
3ca629
+		 *
3ca629
+		 * There used to be a dance around possible re-injection of
3ca629
+		 * WSTOPSIG(status), but it was later removed as the only
3ca629
+		 * observable stop here is the initial ptrace-stop.
3ca629
 		 */
3ca629
-		ptrace(PTRACE_CONT, pid, (char *) 0, 0);
3ca629
-		error_msg("Stop of unknown pid %u seen, PTRACE_CONTed it", pid);
3ca629
+		ptrace(PTRACE_DETACH, pid, NULL, 0L);
3ca629
+		error_msg("Detached unknown pid %d", pid);
3ca629
 		return NULL;
3ca629
 	}
3ca629
 }