[PATCH] Do not trace children created with CLONE_UNTRACED flag

Roland McGrath roland at redhat.com
Wed Sep 8 01:06:04 UTC 2010


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

I can guess what your rationale for this might be, but I think
you should give it explicitly.

On its face, there is no good reason why any one clone call ought to be
treated different from another, in current kernels.  In practice, nobody
ever uses CLONE_UNTRACED today.  AFAIK, it was only ever used by some
old versions of linuxthreads (which has been obsolete for ages), and
even those only wanted it for some ancient kernel versions where the
ptrace wait interference was even worse than it is on non-ancient kernels.

I imagine that your motivation is to make strace's -f behavior today
match what it would do if implemented via PTRACE_O_TRACECLONE, where
we'd give up the option of tracing CLONE_UNTRACED children.  If that's
so, then just be clear about it.

Now, to the change itself.

I don't see why you've added a flag and everything.
What doesn't work about just doing this:

diff --git a/process.c b/process.c
index 59d7ba0..ebba77b 100644
--- a/process.c
+++ b/process.c
@@ -796,7 +796,7 @@ int
 internal_fork(struct tcb *tcp)
 {
 	if (entering(tcp)) {
-		if (!followfork)
+		if (!followfork || (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED))
 			return 0;
 		fork_tcb(tcp);
 		if (setbpt(tcp) < 0)

?


Thanks,
Roland




More information about the Strace-devel mailing list