[PATCH] Do not trace children created with CLONE_UNTRACED flag
Wang Chao
wang.chao at cn.fujitsu.com
Tue Sep 7 07:49:21 UTC 2010
If clone is called with flag CLONE_UNTRACED, I think we should
not set CLONE_PTRACE flag in its arguments.
* defs.h [LINUX]: New flag to indicate that the clone is called
with CLONE_UNTRACED, and we do not setbpt on it.
* util.c [LINUX]: Define CLONE_UNTRACED.
[LINUX] (setbpt): Check it.
* process.c [LINUX] (internal_fork): Check for TCB_CLONE_UNTRACED.
Signed-off-by: Wang Chao <wang.chao at cn.fujitsu.com>
---
defs.h | 1 +
process.c | 7 +++++++
util.c | 7 +++++++
3 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/defs.h b/defs.h
index 4b9c29e..cee8551 100644
--- a/defs.h
+++ b/defs.h
@@ -383,6 +383,7 @@ struct tcb {
# endif
# define TCB_CLONE_THREAD 010000 /* CLONE_THREAD set in creating syscall */
# define TCB_GROUP_EXITING 020000 /* TCB_EXITING was exit_group, not _exit */
+# define TCB_CLONE_UNTRACED 040000 /* clone a new child with CLONE_UNTRACED */
# include <sys/syscall.h>
# ifndef __NR_exit_group
# /* Hack: Most headers around are too old to have __NR_exit_group. */
diff --git a/process.c b/process.c
index 8af960a..f3f0901 100644
--- a/process.c
+++ b/process.c
@@ -809,6 +809,13 @@ internal_fork(struct tcb *tcp)
if (!(tcp->flags & TCB_FOLLOWFORK))
return 0;
+ if (tcp->flags & TCB_CLONE_UNTRACED) {
+ tcp->flags &= ~TCB_CLONE_UNTRACED;
+ if (!(tcp->nchildren > 0))
+ tcp->flags &= ~TCB_FOLLOWFORK;
+ return 0;
+ }
+
bpt = tcp->flags & TCB_BPTSET;
if (syserror(tcp)) {
diff --git a/util.c b/util.c
index 07cbfde..380c16d 100644
--- a/util.c
+++ b/util.c
@@ -1271,6 +1271,9 @@ printcall(struct tcb *tcp)
# ifndef CLONE_STOPPED
# define CLONE_STOPPED 0x02000000
# endif
+# ifndef CLONE_UNTRACED
+# define CLONE_UNTRACED 0x00800000
+# endif
# ifdef IA64
@@ -1537,6 +1540,10 @@ setbpt(struct tcb *tcp)
clear also CLONE_VM but only in the CLONE_VFORK case as
otherwise we would break pthread_create. */
+ if (tcp->u_arg[arg0_index] & CLONE_UNTRACED) {
+ tcp->flags |= TCB_CLONE_UNTRACED;
+ return 0;
+ }
if ((arg_setup (tcp, &state) < 0
|| set_arg0 (tcp, &state,
(tcp->u_arg[arg0_index] | CLONE_PTRACE)
--
1.6.5.2
More information about the Strace-devel
mailing list