5 #include "xlat/prctl_options.h"
6 #include "xlat/pr_unalign_flags.h"
7 #include "xlat/pr_mce_kill.h"
8 #include "xlat/pr_mce_kill_policy.h"
9 #include "xlat/pr_set_mm.h"
10 #include "xlat/pr_tsc.h"
13 # define TASK_COMM_LEN 16
16 #ifdef HAVE_LINUX_SECCOMP_H
17 # include <linux/seccomp.h>
19 #include "xlat/seccomp_mode.h"
21 #ifdef HAVE_LINUX_SECUREBITS_H
22 # include <linux/securebits.h>
24 #include "xlat/secbits.h"
26 /* these constants are the same as in <linux/capability.h> */
35 prctl_enter(struct tcb *tcp)
39 printxval(prctl_options, tcp->u_arg[0], "PR_???");
41 switch (tcp->u_arg[0]) {
42 /* PR_GET_* are decoded on exit. */
43 case PR_GET_CHILD_SUBREAPER:
50 case PR_GET_PDEATHSIG:
52 case PR_GET_SECUREBITS:
53 case PR_GET_TID_ADDRESS:
54 case PR_GET_TIMERSLACK:
58 /* PR_TASK_PERF_EVENTS_* have nothing to decode on enter. */
59 case PR_TASK_PERF_EVENTS_DISABLE:
60 case PR_TASK_PERF_EVENTS_ENABLE:
63 case PR_SET_CHILD_SUBREAPER:
70 tprintf(", %lu", tcp->u_arg[1]);
76 printxval(cap, tcp->u_arg[1], "CAP_???");
81 printxval(pr_mce_kill, tcp->u_arg[1], "PR_MCE_KILL_???");
83 if (PR_MCE_KILL_SET == tcp->u_arg[1])
84 printxval(pr_mce_kill_policy, tcp->u_arg[2],
87 tprintf("%#lx", tcp->u_arg[2]);
88 for (i = 3; i < tcp->s_ent->nargs; i++)
89 tprintf(", %#lx", tcp->u_arg[i]);
94 printstr(tcp, tcp->u_arg[1], TASK_COMM_LEN);
99 printxval(pr_set_mm, tcp->u_arg[1], "PR_SET_MM_???");
100 for (i = 2; i < tcp->s_ent->nargs; i++)
101 tprintf(", %#lx", tcp->u_arg[i]);
104 case PR_SET_PDEATHSIG:
106 if ((unsigned long) tcp->u_arg[1] > 128)
107 tprintf("%lu", tcp->u_arg[1]);
109 tprints(signame(tcp->u_arg[1]));
114 if (tcp->u_arg[1] == -1)
115 tprints("PR_SET_PTRACER_ANY");
117 tprintf("%lu", tcp->u_arg[1]);
122 printxval(seccomp_mode, tcp->u_arg[1],
124 if (SECCOMP_MODE_STRICT == tcp->u_arg[1])
126 if (SECCOMP_MODE_FILTER == tcp->u_arg[1]) {
128 print_seccomp_filter(tcp, tcp->u_arg[2]);
131 for (i = 2; i < tcp->s_ent->nargs; i++)
132 tprintf(", %#lx", tcp->u_arg[i]);
135 case PR_SET_SECUREBITS:
137 printflags(secbits, tcp->u_arg[1], "SECBIT_???");
140 case PR_SET_TIMERSLACK:
141 tprintf(", %ld", tcp->u_arg[1]);
146 printxval(pr_tsc, tcp->u_arg[1], "PR_TSC_???");
151 printflags(pr_unalign_flags, tcp->u_arg[1], "PR_UNALIGN_???");
154 case PR_SET_NO_NEW_PRIVS:
155 case PR_SET_THP_DISABLE:
156 tprintf(", %lu", tcp->u_arg[1]);
157 for (i = 2; i < tcp->s_ent->nargs; i++)
158 tprintf(", %#lx", tcp->u_arg[i]);
161 case PR_GET_NO_NEW_PRIVS:
162 case PR_GET_THP_DISABLE:
163 case PR_MCE_KILL_GET:
164 /* Return code of "GET" commands will be decoded on exit */
165 case PR_MPX_DISABLE_MANAGEMENT:
166 case PR_MPX_ENABLE_MANAGEMENT:
168 for (i = 1; i < tcp->s_ent->nargs; i++)
169 tprintf(", %#lx", tcp->u_arg[i]);
176 prctl_exit(struct tcb *tcp)
180 switch (tcp->u_arg[0]) {
181 case PR_CAPBSET_READ:
182 case PR_GET_DUMPABLE:
183 case PR_GET_KEEPCAPS:
184 case PR_GET_NO_NEW_PRIVS:
186 case PR_GET_THP_DISABLE:
187 case PR_GET_TIMERSLACK:
189 return syserror(tcp) ? 0 : RVAL_UDECIMAL;
191 case PR_GET_CHILD_SUBREAPER:
196 printnum_int(tcp, tcp->u_arg[1], "%u");
203 else if (syserror(tcp))
204 tprintf("%#lx", tcp->u_arg[1]);
206 printstr(tcp, tcp->u_arg[1], -1);
209 case PR_GET_PDEATHSIG:
213 else if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
214 tprintf("%#lx", tcp->u_arg[1]);
222 case PR_GET_SECUREBITS:
223 if (syserror(tcp) || tcp->u_rval == 0)
225 tcp->auxstr = sprintflags("", secbits, tcp->u_rval);
228 case PR_GET_TID_ADDRESS:
230 printnum_long(tcp, tcp->u_arg[1], "%#lx");
237 else if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
238 tprintf("%#lx", tcp->u_arg[1]);
241 printxval(pr_tsc, i, "PR_TSC_???");
250 else if (syserror(tcp) || umove(tcp, tcp->u_arg[1], &i) < 0)
251 tprintf("%#lx", tcp->u_arg[1]);
254 printflags(pr_unalign_flags, i, "PR_UNALIGN_???");
259 case PR_MCE_KILL_GET:
262 tcp->auxstr = xlookup(pr_mce_kill_policy, tcp->u_rval);
263 return tcp->auxstr ? RVAL_STR : RVAL_UDECIMAL;
273 return entering(tcp) ? prctl_enter(tcp) : prctl_exit(tcp);
276 #if defined X86_64 || defined X32
277 # include <asm/prctl.h>
278 # include "xlat/archvals.h"
283 printxval(archvals, tcp->u_arg[0], "ARCH_???");
285 switch (tcp->u_arg[0]) {
290 printnum_long(tcp, tcp->u_arg[1], "%#lx");
298 tprintf(", %#lx", tcp->u_arg[1]);
301 #endif /* X86_64 || X32 */