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 print_prctl_args(struct tcb *tcp, const unsigned int first)
39 for (i = first; i < tcp->s_ent->nargs; ++i)
40 tprintf(", %#lx", tcp->u_arg[i]);
48 printxval(prctl_options, tcp->u_arg[0], "PR_???");
50 switch (tcp->u_arg[0]) {
54 case PR_GET_TIMERSLACK:
58 return syserror(tcp) ? 0 : RVAL_UDECIMAL;
60 case PR_GET_CHILD_SUBREAPER:
67 printnum_int(tcp, tcp->u_arg[1], "%u");
75 printaddr(tcp->u_arg[1]);
77 printstr(tcp, tcp->u_arg[1], -1);
81 case PR_GET_PDEATHSIG:
84 else if (!umove_or_printaddr(tcp, tcp->u_arg[1], &i)) {
91 case PR_GET_SECUREBITS:
94 if (syserror(tcp) || tcp->u_rval == 0)
96 tcp->auxstr = sprintflags("", secbits, tcp->u_rval);
99 case PR_GET_TID_ADDRESS:
103 printnum_ptr(tcp, tcp->u_arg[1]);
109 else if (!umove_or_printaddr(tcp, tcp->u_arg[1], &i)) {
111 printxval(pr_tsc, i, "PR_TSC_???");
119 else if (!umove_or_printaddr(tcp, tcp->u_arg[1], &i)) {
121 printflags(pr_unalign_flags, i, "PR_UNALIGN_???");
126 /* PR_TASK_PERF_EVENTS_* take no arguments. */
127 case PR_TASK_PERF_EVENTS_DISABLE:
128 case PR_TASK_PERF_EVENTS_ENABLE:
131 case PR_SET_CHILD_SUBREAPER:
132 case PR_SET_DUMPABLE:
136 case PR_SET_KEEPCAPS:
138 tprintf(", %lu", tcp->u_arg[1]);
141 case PR_CAPBSET_DROP:
143 printxval(cap, tcp->u_arg[1], "CAP_???");
146 case PR_CAPBSET_READ:
149 printxval(cap, tcp->u_arg[1], "CAP_???");
152 return syserror(tcp) ? 0 : RVAL_UDECIMAL;
156 printxval(pr_mce_kill, tcp->u_arg[1], "PR_MCE_KILL_???");
158 if (PR_MCE_KILL_SET == tcp->u_arg[1])
159 printxval(pr_mce_kill_policy, tcp->u_arg[2],
162 tprintf("%#lx", tcp->u_arg[2]);
163 print_prctl_args(tcp, 3);
168 printstr(tcp, tcp->u_arg[1], TASK_COMM_LEN);
173 # define PR_SET_VMA 0x53564d41
175 # ifndef PR_SET_VMA_ANON_NAME
176 # define PR_SET_VMA_ANON_NAME 0
179 if (tcp->u_arg[1] == PR_SET_VMA_ANON_NAME) {
180 tprintf(", %lu", tcp->u_arg[1]);
181 tprintf(", %#lx", tcp->u_arg[2]);
182 tprintf(", %lu, ", tcp->u_arg[3]);
183 printstr(tcp, tcp->u_arg[4], -1);
185 /* There are no other sub-options now, but there
186 * might be in future... */
187 print_prctl_args(tcp, 1);
194 printxval(pr_set_mm, tcp->u_arg[1], "PR_SET_MM_???");
195 print_prctl_args(tcp, 2);
198 case PR_SET_PDEATHSIG:
200 if ((unsigned long) tcp->u_arg[1] > 128)
201 tprintf("%lu", tcp->u_arg[1]);
203 tprints(signame(tcp->u_arg[1]));
208 if (tcp->u_arg[1] == -1)
209 tprints("PR_SET_PTRACER_ANY");
211 tprintf("%lu", tcp->u_arg[1]);
216 printxval(seccomp_mode, tcp->u_arg[1],
218 if (SECCOMP_MODE_STRICT == tcp->u_arg[1])
220 if (SECCOMP_MODE_FILTER == tcp->u_arg[1]) {
222 print_seccomp_filter(tcp, tcp->u_arg[2]);
225 print_prctl_args(tcp, 2);
228 case PR_SET_SECUREBITS:
230 printflags(secbits, tcp->u_arg[1], "SECBIT_???");
233 case PR_SET_TIMERSLACK:
234 tprintf(", %ld", tcp->u_arg[1]);
239 printxval(pr_tsc, tcp->u_arg[1], "PR_TSC_???");
244 printflags(pr_unalign_flags, tcp->u_arg[1], "PR_UNALIGN_???");
247 case PR_SET_NO_NEW_PRIVS:
248 case PR_SET_THP_DISABLE:
249 tprintf(", %lu", tcp->u_arg[1]);
250 print_prctl_args(tcp, 2);
253 case PR_GET_NO_NEW_PRIVS:
254 case PR_GET_THP_DISABLE:
256 print_prctl_args(tcp, 1);
259 return syserror(tcp) ? 0 : RVAL_UDECIMAL;
261 case PR_MCE_KILL_GET:
263 print_prctl_args(tcp, 1);
268 tcp->auxstr = xlookup(pr_mce_kill_policy, tcp->u_rval);
269 return tcp->auxstr ? RVAL_STR : RVAL_UDECIMAL;
271 case PR_MPX_DISABLE_MANAGEMENT:
272 case PR_MPX_ENABLE_MANAGEMENT:
274 print_prctl_args(tcp, 1);
280 #if defined X86_64 || defined X32
281 # include <asm/prctl.h>
282 # include "xlat/archvals.h"
287 printxval(archvals, tcp->u_arg[0], "ARCH_???");
289 switch (tcp->u_arg[0]) {
295 printnum_ptr(tcp, tcp->u_arg[1]);
299 tprintf(", %#lx", tcp->u_arg[1]);
302 #endif /* X86_64 || X32 */