Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jul 2019 19:46:58 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349748 - head/sys/amd64/linux
Message-ID:  <201907041946.x64Jkw4m034179@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Thu Jul  4 19:46:58 2019
New Revision: 349748
URL: https://svnweb.freebsd.org/changeset/base/349748

Log:
  Add support for PTRACE_O_TRACEEXIT to linuxulator ptrace(2).
  This fixes strace 4.25 from Ubuntu 19.04.
  
  Reviewed by:	emaste
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20689

Modified:
  head/sys/amd64/linux/linux_ptrace.c

Modified: head/sys/amd64/linux/linux_ptrace.c
==============================================================================
--- head/sys/amd64/linux/linux_ptrace.c	Thu Jul  4 19:44:13 2019	(r349747)
+++ head/sys/amd64/linux/linux_ptrace.c	Thu Jul  4 19:46:58 2019	(r349748)
@@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$");
 #define	LINUX_PTRACE_GETREGSET		0x4204
 #define	LINUX_PTRACE_SEIZE		0x4206
 
+#define	LINUX_PTRACE_EVENT_EXIT		6
+
 #define	LINUX_PTRACE_O_TRACESYSGOOD	1
 #define	LINUX_PTRACE_O_TRACEFORK	2
 #define	LINUX_PTRACE_O_TRACEVFORK	4
@@ -139,6 +141,9 @@ linux_ptrace_status(struct thread *td, pid_t pid, int 
 	if ((pem->ptrace_flags & LINUX_PTRACE_O_TRACESYSGOOD) &&
 	    lwpinfo.pl_flags & PL_FLAG_SCX)
 		status |= (LINUX_SIGTRAP | 0x80) << 8;
+	if ((pem->ptrace_flags & LINUX_PTRACE_O_TRACEEXIT) &&
+	    lwpinfo.pl_flags & PL_FLAG_EXITED)
+		status |= (LINUX_SIGTRAP | LINUX_PTRACE_EVENT_EXIT << 8) << 8;
 	LINUX_PEM_SUNLOCK(pem);
 
 	return (status);
@@ -359,9 +364,9 @@ linux_ptrace_setoptions(struct thread *td, pid_t pid, 
 		mask |= PTRACE_VFORK; /* XXX: Close enough? */
 
 	if (data & LINUX_PTRACE_O_TRACEEXIT) {
-		linux_msg(td, "PTRACE_O_TRACEEXIT not implemented; "
-		    "returning EINVAL");
-		return (EINVAL);
+		pem->ptrace_flags |= LINUX_PTRACE_O_TRACEEXIT;
+	} else {
+		pem->ptrace_flags &= ~LINUX_PTRACE_O_TRACEEXIT;
 	}
 
 	return (kern_ptrace(td, PT_SET_EVENT_MASK, pid, &mask, sizeof(mask)));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201907041946.x64Jkw4m034179>