2 * Copyright (c) 1999-2000 Wichert Akkerman <wichert@cistron.nl>
3 * Copyright (c) 2002-2005 Roland McGrath <roland@redhat.com>
4 * Copyright (c) 2008 Jan Kratochvil <jan.kratochvil@redhat.com>
5 * Copyright (c) 2009-2013 Denys Vlasenko <dvlasenk@redhat.com>
6 * Copyright (c) 2006-2015 Dmitry V. Levin <ldv@altlinux.org>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 # define CSIGNAL 0x000000ff
40 #include "xlat/clone_flags.h"
41 #include "xlat/setns_types.h"
42 #include "xlat/unshare_flags.h"
47 # define ARG_STACKSIZE (tcp->scno == __NR_clone2 ? 2 : -1)
48 # define ARG_PTID (tcp->scno == __NR_clone2 ? 3 : 2)
49 # define ARG_CTID (tcp->scno == __NR_clone2 ? 4 : 3)
50 # define ARG_TLS (tcp->scno == __NR_clone2 ? 5 : 4)
51 #elif defined S390 || defined S390X || defined CRISV10 || defined CRISV32
57 #elif defined X86_64 || defined X32
58 /* x86 personality processes have the last two arguments flipped. */
62 # define ARG_CTID ((current_personality != 1) ? 3 : 4)
63 # define ARG_TLS ((current_personality != 1) ? 4 : 3)
64 #elif defined ALPHA || defined TILE || defined OR1K || defined RISCV
78 #if defined I386 || defined X86_64 || defined X32
79 extern void print_user_desc(struct tcb *, long);
80 #endif /* I386 || X86_64 || X32 */
85 const char *sep = "|";
86 unsigned long flags = tcp->u_arg[ARG_FLAGS];
87 tprints("child_stack=");
88 printaddr(tcp->u_arg[ARG_STACK]);
91 if (ARG_STACKSIZE != -1)
92 tprintf("stack_size=%#lx, ",
93 tcp->u_arg[ARG_STACKSIZE]);
96 if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
98 if ((flags & CSIGNAL) != 0)
99 tprintf("%s%s", sep, signame(flags & CSIGNAL));
100 if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
101 |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
103 if (flags & CLONE_PARENT_SETTID) {
104 tprints(", parent_tidptr=");
105 printaddr(tcp->u_arg[ARG_PTID]);
107 if (flags & CLONE_SETTLS) {
108 #if defined I386 || defined X86_64 || defined X32
110 if (current_personality == 1)
114 print_user_desc(tcp, tcp->u_arg[ARG_TLS]);
119 #endif /* I386 || X86_64 || X32 */
122 printaddr(tcp->u_arg[ARG_TLS]);
125 if (flags & (CLONE_CHILD_SETTID|CLONE_CHILD_CLEARTID)) {
126 tprints(", child_tidptr=");
127 printaddr(tcp->u_arg[ARG_CTID]);
130 /* TODO on syscall entry:
131 * We can clear CLONE_PTRACE here since it is an ancient hack
132 * to allow us to catch children, and we use another hack for that.
133 * But CLONE_PTRACE can conceivably be used by malicious programs
134 * to subvert us. By clearing this bit, we can defend against it:
135 * in untraced execution, CLONE_PTRACE should have no effect.
137 * We can also clear CLONE_UNTRACED, since it allows to start
138 * children outside of our control. At the moment
139 * I'm trying to figure out whether there is a *legitimate*
140 * use of this flag which we should respect.
147 printfd(tcp, tcp->u_arg[0]);
149 printxval(setns_types, tcp->u_arg[1], "CLONE_NEW???");
156 printflags64(unshare_flags, getarg_ull(tcp, 0), "CLONE_???");
162 return RVAL_DECODED | RVAL_UDECIMAL;