]> granicus.if.org Git - strace/commitdiff
Do not trace children cloned with CLONE_UNTRACED flag
authorWang Chao <wang.chao@cn.fujitsu.com>
Thu, 16 Sep 2010 03:20:56 +0000 (11:20 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 17 Sep 2010 16:54:52 +0000 (16:54 +0000)
If clone is called with flag CLONE_UNTRACED, to be consistent with
option PTRACE_O_TRACECLONE, we should not set CLONE_PTRACE flag on
its arguments.

* process.c [LINUX] (internal_fork): Check the syscall and arguments.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
process.c

index 8999fc67d052b26f97d3f83179138265acc3198b..2366d1f3ada1c05e4d128545e194d1bf157951ef 100644 (file)
--- a/process.c
+++ b/process.c
@@ -796,8 +796,17 @@ int
 internal_fork(struct tcb *tcp)
 {
        if (entering(tcp)) {
+               tcp->flags &= ~TCB_FOLLOWFORK;
                if (!followfork)
                        return 0;
+               /*
+                * In occasion of using PTRACE_O_TRACECLONE, we won't see the
+                * new child if clone is called with flag CLONE_UNTRACED, so
+                * we keep the same logic with that option and don't trace it.
+                */
+               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;