[PATCH] Reliably detect post-execve trap on ia64

Andreas Schwab schwab at redhat.com
Mon Feb 1 16:14:50 UTC 2010


* defs.h (TCB_WAITEXECVE) [IA64]: Don't define.
* syscall.c (get_scno) [IA64]: Don't check for TCB_WAITEXECVE.
(syscall_fixup) [IA64]: Check for post-execve signal.
---
 defs.h    |    2 +-
 syscall.c |   29 ++++++++++++-----------------
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/defs.h b/defs.h
index a869929..8802068 100644
--- a/defs.h
+++ b/defs.h
@@ -370,7 +370,7 @@ struct tcb {
  * See "stray syscall exit: eax = " message in syscall_fixup().
  */
 # if defined(ALPHA) || defined(AVR32) || defined(SPARC) || defined(SPARC64) \
-  || defined(POWERPC) || defined(IA64) || defined(HPPA) \
+  || defined(POWERPC) || defined(HPPA) \
   || defined(SH) || defined(SH64) || defined(S390) || defined(S390X) \
   || defined(ARM) || defined(MIPS) || defined(BFIN)
 #  define TCB_WAITEXECVE 02000	/* ignore SIGTRAP after exceve */
diff --git a/syscall.c b/syscall.c
index 3f551cd..1aba4da 100644
--- a/syscall.c
+++ b/syscall.c
@@ -980,24 +980,11 @@ get_scno(struct tcb *tcp)
 #	define IA64_PSR_IS	((long)1 << 34)
 	if (upeek (tcp, PT_CR_IPSR, &psr) >= 0)
 		ia32 = (psr & IA64_PSR_IS) != 0;
-	if (!(tcp->flags & TCB_INSYSCALL)) {
-		if (ia32) {
-			if (upeek(tcp, PT_R1, &scno) < 0)	/* orig eax */
-				return -1;
-		} else {
-			if (upeek (tcp, PT_R15, &scno) < 0)
-				return -1;
-		}
-		/* Check if we return from execve. */
-		if (tcp->flags & TCB_WAITEXECVE) {
-			tcp->flags &= ~TCB_WAITEXECVE;
-			return 0;
-		}
-	} else {
-		/* syscall in progress */
-		if (upeek (tcp, PT_R8, &r8) < 0)
+	if (ia32) {
+		if (upeek(tcp, PT_R1, &scno) < 0)	/* orig eax */
 			return -1;
-		if (upeek (tcp, PT_R10, &r10) < 0)
+	} else {
+		if (upeek (tcp, PT_R15, &scno) < 0)
 			return -1;
 	}
 # elif defined (ARM)
@@ -1487,6 +1474,14 @@ syscall_fixup(struct tcb *tcp)
 			fprintf(stderr, "stray syscall exit: r8 = %ld\n", r8);
 		return 0;
 	}
+	if (!ia32 && !(tcp->flags & TCB_INSYSCALL) && tcp->scno == SYS_execve) {
+		siginfo_t si;
+
+		/* Check whether this is the execve post-exec signal.  */
+		if (ptrace(PTRACE_GETSIGINFO, tcp->pid, 0, (long)&si) == 0)
+			if (si.si_code == SI_USER)
+				return 0;
+	}
 #elif defined(CRISV10) || defined(CRISV32)
 	if (upeek(tcp, 4*PT_R10, &r10) < 0)
 		return -1;
-- 
1.6.6.1


Andreas.

-- 
Andreas Schwab, schwab at redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."




More information about the Strace-devel mailing list