[PATCH/v2] Do not trace children with CLONE_UNTRACED flag

Wang Chao wang.chao at cn.fujitsu.com
Wed Sep 15 05:21:28 UTC 2010


If clone is called with flag CLONE_UNTRACED, I think we should
not set CLONE_PTRACE flag in its arguments.

* process.c [LINUX] (internal_fork): If the syscall is clone and
  CLONE_UNTRACED flag is set in its arguments, do not trace this
  new child.

Signed-off-by: Wang Chao <wang.chao at cn.fujitsu.com>
---
 process.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/process.c b/process.c
index 8999fc6..851297c 100644
--- a/process.c
+++ b/process.c
@@ -796,8 +796,12 @@ int
 internal_fork(struct tcb *tcp)
 {
 	if (entering(tcp)) {
+		tcp->flags &= ~TCB_FOLLOWFORK;
 		if (!followfork)
 			return 0;
+		if ((sysent[tcp->scno].sys_func == sys_clone) &&
+		    (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
+			return 0;
 		fork_tcb(tcp);
 		if (setbpt(tcp) < 0)
 			return 0;
-- 
1.6.5.2





More information about the Strace-devel mailing list