Dmitry V. Levin | 38a34c9 | 2015-12-17 17:56:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1994-1996 Rick Sladkey <jrs@world.std.com> |
| 3 | * Copyright (c) 1996-2000 Wichert Akkerman <wichert@cistron.nl> |
| 4 | * Copyright (c) 2005-2007 Roland McGrath <roland@redhat.com> |
| 5 | * Copyright (c) 2008-2015 Dmitry V. Levin <ldv@altlinux.org> |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 6 | * Copyright (c) 2014-2018 The strace developers. |
Dmitry V. Levin | 38a34c9 | 2015-12-17 17:56:48 +0000 | [diff] [blame] | 7 | * All rights reserved. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 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. |
| 19 | * |
| 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. |
| 30 | */ |
| 31 | |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 32 | #include "defs.h" |
| 33 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 34 | #include <linux/prctl.h> |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 35 | |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 36 | #include "xstring.h" |
| 37 | |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 38 | #include "xlat/prctl_options.h" |
Dmitry V. Levin | eb76c4b | 2015-12-06 15:33:53 +0000 | [diff] [blame] | 39 | #include "xlat/pr_cap_ambient.h" |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 40 | #include "xlat/pr_dumpable.h" |
| 41 | #include "xlat/pr_fp_mode.h" |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 42 | #include "xlat/pr_mce_kill.h" |
| 43 | #include "xlat/pr_mce_kill_policy.h" |
| 44 | #include "xlat/pr_set_mm.h" |
Elliott Hughes | 03a418e | 2018-06-15 13:11:40 -0700 | [diff] [blame] | 45 | #include "xlat/pr_spec_cmds.h" |
| 46 | #include "xlat/pr_spec_get_store_bypass_flags.h" |
| 47 | #include "xlat/pr_spec_set_store_bypass_flags.h" |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 48 | #include "xlat/pr_sve_vl_flags.h" |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 49 | #include "xlat/pr_tsc.h" |
Dmitry V. Levin | eb76c4b | 2015-12-06 15:33:53 +0000 | [diff] [blame] | 50 | #include "xlat/pr_unalign_flags.h" |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 51 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 52 | #ifndef TASK_COMM_LEN |
| 53 | # define TASK_COMM_LEN 16 |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 54 | #endif |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 55 | |
Dmitry V. Levin | 2af6903 | 2015-02-04 23:50:50 +0000 | [diff] [blame] | 56 | #ifdef HAVE_LINUX_SECCOMP_H |
| 57 | # include <linux/seccomp.h> |
| 58 | #endif |
Dmitry V. Levin | 2af6903 | 2015-02-04 23:50:50 +0000 | [diff] [blame] | 59 | #include "xlat/seccomp_mode.h" |
| 60 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 61 | #ifdef HAVE_LINUX_SECUREBITS_H |
| 62 | # include <linux/securebits.h> |
| 63 | #endif |
| 64 | #include "xlat/secbits.h" |
| 65 | |
| 66 | /* these constants are the same as in <linux/capability.h> */ |
| 67 | enum { |
| 68 | #include "caps0.h" |
| 69 | #include "caps1.h" |
| 70 | }; |
| 71 | |
| 72 | #include "xlat/cap.h" |
| 73 | |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 74 | #ifndef PR_SVE_VL_LEN_MASK |
| 75 | # define PR_SVE_VL_LEN_MASK 0xffff |
| 76 | #endif |
| 77 | |
| 78 | |
Dmitry V. Levin | 3691562 | 2015-07-25 09:43:01 +0000 | [diff] [blame] | 79 | static void |
| 80 | print_prctl_args(struct tcb *tcp, const unsigned int first) |
| 81 | { |
| 82 | unsigned int i; |
| 83 | |
| 84 | for (i = first; i < tcp->s_ent->nargs; ++i) |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 85 | tprintf(", %#" PRI_klx, tcp->u_arg[i]); |
Dmitry V. Levin | 3691562 | 2015-07-25 09:43:01 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 88 | static char * |
| 89 | sprint_sve_val(kernel_ulong_t arg) |
| 90 | { |
| 91 | static char out[sizeof("PR_SVE_SET_VL_ONEXEC|PR_SVE_VL_INHERIT|0x") + |
| 92 | sizeof(kernel_ulong_t) * 2]; |
| 93 | |
| 94 | kernel_ulong_t vl = arg & PR_SVE_VL_LEN_MASK; |
| 95 | kernel_ulong_t flags = arg & ~PR_SVE_VL_LEN_MASK; |
| 96 | const char *flags_str = sprintflags("", pr_sve_vl_flags, flags); |
| 97 | |
| 98 | xsprintf(out, "%s%s%#" PRI_klx, |
| 99 | flags_str ?: "", flags_str ? "|" : "", vl); |
| 100 | |
| 101 | return out; |
| 102 | } |
| 103 | |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 104 | SYS_FUNC(prctl) |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 105 | { |
Dmitry V. Levin | b8eec60 | 2016-05-16 22:19:31 +0000 | [diff] [blame] | 106 | const unsigned int option = tcp->u_arg[0]; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 107 | const kernel_ulong_t arg2 = tcp->u_arg[1]; |
| 108 | const kernel_ulong_t arg3 = tcp->u_arg[2]; |
| 109 | /* |
| 110 | * PR_SET_VMA is the only command which actually uses these arguments |
| 111 | * currently, and it is available only on Android for now. |
| 112 | */ |
| 113 | #ifdef __ANDROID__ |
| 114 | const kernel_ulong_t arg4 = tcp->u_arg[3]; |
| 115 | const kernel_ulong_t arg5 = tcp->u_arg[4]; |
| 116 | #endif |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 117 | unsigned int i; |
| 118 | |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 119 | if (entering(tcp)) |
Dmitry V. Levin | b8eec60 | 2016-05-16 22:19:31 +0000 | [diff] [blame] | 120 | printxval(prctl_options, option, "PR_???"); |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 121 | |
Dmitry V. Levin | b8eec60 | 2016-05-16 22:19:31 +0000 | [diff] [blame] | 122 | switch (option) { |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 123 | case PR_GET_KEEPCAPS: |
| 124 | case PR_GET_SECCOMP: |
| 125 | case PR_GET_TIMERSLACK: |
| 126 | case PR_GET_TIMING: |
Dmitry V. Levin | 1b28330 | 2015-12-06 15:29:04 +0000 | [diff] [blame] | 127 | return RVAL_DECODED; |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 128 | |
| 129 | case PR_GET_CHILD_SUBREAPER: |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 130 | case PR_GET_ENDIAN: |
| 131 | case PR_GET_FPEMU: |
| 132 | case PR_GET_FPEXC: |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 133 | if (entering(tcp)) |
| 134 | tprints(", "); |
| 135 | else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 136 | printnum_int(tcp, arg2, "%u"); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 137 | break; |
| 138 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 139 | case PR_GET_DUMPABLE: |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 140 | if (entering(tcp)) |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 141 | break; |
| 142 | if (syserror(tcp)) |
| 143 | return 0; |
| 144 | tcp->auxstr = xlookup(pr_dumpable, (kernel_ulong_t) tcp->u_rval); |
| 145 | return RVAL_STR; |
| 146 | |
| 147 | case PR_GET_NAME: |
| 148 | if (entering(tcp)) { |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 149 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 150 | } else { |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 151 | if (syserror(tcp)) |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 152 | printaddr(arg2); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 153 | else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 154 | printstr_ex(tcp, arg2, TASK_COMM_LEN, |
| 155 | QUOTE_0_TERMINATED); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 156 | } |
| 157 | break; |
| 158 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 159 | case PR_GET_PDEATHSIG: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 160 | if (entering(tcp)) { |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 161 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 162 | } else if (!umove_or_printaddr(tcp, arg2, &i)) { |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 163 | tprints("["); |
| 164 | tprints(signame(i)); |
| 165 | tprints("]"); |
| 166 | } |
| 167 | break; |
| 168 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 169 | case PR_GET_SECUREBITS: |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 170 | if (entering(tcp)) |
| 171 | break; |
| 172 | if (syserror(tcp) || tcp->u_rval == 0) |
| 173 | return 0; |
Dmitry V. Levin | 6274ecc | 2016-05-15 14:23:06 +0000 | [diff] [blame] | 174 | tcp->auxstr = sprintflags("", secbits, |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 175 | (kernel_ulong_t) tcp->u_rval); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 176 | return RVAL_STR; |
| 177 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 178 | case PR_GET_TID_ADDRESS: |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 179 | if (entering(tcp)) |
| 180 | tprints(", "); |
| 181 | else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 182 | printnum_kptr(tcp, arg2); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 183 | break; |
| 184 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 185 | case PR_GET_TSC: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 186 | if (entering(tcp)) { |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 187 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 188 | } else if (!umove_or_printaddr(tcp, arg2, &i)) { |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 189 | tprints("["); |
| 190 | printxval(pr_tsc, i, "PR_TSC_???"); |
| 191 | tprints("]"); |
| 192 | } |
| 193 | break; |
| 194 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 195 | case PR_GET_UNALIGN: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 196 | if (entering(tcp)) { |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 197 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 198 | } else if (!umove_or_printaddr(tcp, arg2, &i)) { |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 199 | tprints("["); |
| 200 | printflags(pr_unalign_flags, i, "PR_UNALIGN_???"); |
| 201 | tprints("]"); |
| 202 | } |
| 203 | break; |
| 204 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 205 | case PR_GET_FP_MODE: |
| 206 | if (entering(tcp)) |
| 207 | break; |
| 208 | if (syserror(tcp) || tcp->u_rval == 0) |
| 209 | return 0; |
| 210 | tcp->auxstr = sprintflags("", pr_fp_mode, |
| 211 | (kernel_ulong_t) tcp->u_rval); |
| 212 | return RVAL_STR; |
| 213 | |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 214 | case PR_SVE_SET_VL: |
| 215 | if (entering(tcp)) { |
| 216 | tprintf(", %s", sprint_sve_val(arg2)); |
| 217 | return 0; |
| 218 | } |
| 219 | ATTRIBUTE_FALLTHROUGH; |
| 220 | |
| 221 | case PR_SVE_GET_VL: |
| 222 | if (entering(tcp)) |
| 223 | break; |
| 224 | if (syserror(tcp) || tcp->u_rval == 0) |
| 225 | return 0; |
| 226 | |
| 227 | tcp->auxstr = sprint_sve_val(tcp->u_rval); |
| 228 | |
| 229 | return RVAL_STR; |
| 230 | |
Elliott Hughes | 03a418e | 2018-06-15 13:11:40 -0700 | [diff] [blame] | 231 | case PR_GET_SPECULATION_CTRL: |
| 232 | if (entering(tcp)) { |
| 233 | tprints(", "); |
| 234 | printxval64(pr_spec_cmds, arg2, "PR_SPEC_???"); |
| 235 | |
| 236 | break; |
| 237 | } |
| 238 | |
| 239 | if (syserror(tcp)) |
| 240 | return 0; |
| 241 | |
| 242 | switch (arg2) { |
| 243 | case PR_SPEC_STORE_BYPASS: |
| 244 | tcp->auxstr = sprintflags("", |
| 245 | pr_spec_get_store_bypass_flags, |
| 246 | (kernel_ulong_t) tcp->u_rval); |
| 247 | break; |
| 248 | } |
| 249 | |
| 250 | return RVAL_STR; |
| 251 | |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 252 | /* PR_TASK_PERF_EVENTS_* take no arguments. */ |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 253 | case PR_TASK_PERF_EVENTS_DISABLE: |
| 254 | case PR_TASK_PERF_EVENTS_ENABLE: |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 255 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 256 | |
| 257 | case PR_SET_CHILD_SUBREAPER: |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 258 | case PR_SET_ENDIAN: |
| 259 | case PR_SET_FPEMU: |
| 260 | case PR_SET_FPEXC: |
| 261 | case PR_SET_KEEPCAPS: |
| 262 | case PR_SET_TIMING: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 263 | tprintf(", %" PRI_klu, arg2); |
| 264 | return RVAL_DECODED; |
| 265 | |
| 266 | case PR_SET_DUMPABLE: |
| 267 | tprints(", "); |
| 268 | printxval64(pr_dumpable, arg2, "SUID_DUMP_???"); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 269 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 270 | |
| 271 | case PR_CAPBSET_DROP: |
Dmitry V. Levin | 1b28330 | 2015-12-06 15:29:04 +0000 | [diff] [blame] | 272 | case PR_CAPBSET_READ: |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 273 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 274 | printxval64(cap, arg2, "CAP_???"); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 275 | return RVAL_DECODED; |
| 276 | |
Dmitry V. Levin | eb76c4b | 2015-12-06 15:33:53 +0000 | [diff] [blame] | 277 | case PR_CAP_AMBIENT: |
| 278 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 279 | printxval64(pr_cap_ambient, arg2, |
Dmitry V. Levin | c5f6863 | 2016-05-16 23:22:11 +0000 | [diff] [blame] | 280 | "PR_CAP_AMBIENT_???"); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 281 | switch (arg2) { |
Dmitry V. Levin | eb76c4b | 2015-12-06 15:33:53 +0000 | [diff] [blame] | 282 | case PR_CAP_AMBIENT_RAISE: |
| 283 | case PR_CAP_AMBIENT_LOWER: |
| 284 | case PR_CAP_AMBIENT_IS_SET: |
| 285 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 286 | printxval64(cap, arg3, "CAP_???"); |
Dmitry V. Levin | eb76c4b | 2015-12-06 15:33:53 +0000 | [diff] [blame] | 287 | print_prctl_args(tcp, 3); |
| 288 | break; |
| 289 | default: |
| 290 | print_prctl_args(tcp, 2); |
| 291 | break; |
| 292 | } |
| 293 | return RVAL_DECODED; |
| 294 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 295 | case PR_MCE_KILL: |
| 296 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 297 | printxval64(pr_mce_kill, arg2, "PR_MCE_KILL_???"); |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 298 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 299 | if (PR_MCE_KILL_SET == arg2) |
| 300 | printxval64(pr_mce_kill_policy, arg3, |
| 301 | "PR_MCE_KILL_???"); |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 302 | else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 303 | tprintf("%#" PRI_klx, arg3); |
Dmitry V. Levin | 3691562 | 2015-07-25 09:43:01 +0000 | [diff] [blame] | 304 | print_prctl_args(tcp, 3); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 305 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 306 | |
| 307 | case PR_SET_NAME: |
| 308 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 309 | printstr_ex(tcp, arg2, TASK_COMM_LEN - 1, |
| 310 | QUOTE_0_TERMINATED); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 311 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 312 | |
Elliott Hughes | 1d246ce | 2015-07-29 22:49:38 +0000 | [diff] [blame] | 313 | #ifdef __ANDROID__ |
Elliott Hughes | 1d246ce | 2015-07-29 22:49:38 +0000 | [diff] [blame] | 314 | # ifndef PR_SET_VMA_ANON_NAME |
| 315 | # define PR_SET_VMA_ANON_NAME 0 |
| 316 | # endif |
| 317 | case PR_SET_VMA: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 318 | if (arg2 == PR_SET_VMA_ANON_NAME) { |
| 319 | tprintf(", PR_SET_VMA_ANON_NAME, %#" PRI_klx, arg3); |
| 320 | tprintf(", %" PRI_klu ", ", arg4); |
| 321 | printstr(tcp, arg5); |
Elliott Hughes | 1d246ce | 2015-07-29 22:49:38 +0000 | [diff] [blame] | 322 | } else { |
| 323 | /* There are no other sub-options now, but there |
| 324 | * might be in future... */ |
| 325 | print_prctl_args(tcp, 1); |
| 326 | } |
| 327 | return RVAL_DECODED; |
| 328 | #endif |
| 329 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 330 | case PR_SET_MM: |
| 331 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 332 | printxval(pr_set_mm, arg2, "PR_SET_MM_???"); |
Dmitry V. Levin | 3691562 | 2015-07-25 09:43:01 +0000 | [diff] [blame] | 333 | print_prctl_args(tcp, 2); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 334 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 335 | |
| 336 | case PR_SET_PDEATHSIG: |
| 337 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 338 | if (arg2 > 128) |
| 339 | tprintf("%" PRI_klu, arg2); |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 340 | else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 341 | tprints(signame(arg2)); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 342 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 343 | |
| 344 | case PR_SET_PTRACER: |
| 345 | tprints(", "); |
Elliott Hughes | 03a418e | 2018-06-15 13:11:40 -0700 | [diff] [blame] | 346 | if ((int) arg2 == -1) { |
| 347 | print_xlat_ex(arg2, "PR_SET_PTRACER_ANY", |
| 348 | XLAT_STYLE_DEFAULT); |
| 349 | } else { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 350 | tprintf("%" PRI_klu, arg2); |
Elliott Hughes | 03a418e | 2018-06-15 13:11:40 -0700 | [diff] [blame] | 351 | } |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 352 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 353 | |
| 354 | case PR_SET_SECCOMP: |
| 355 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 356 | printxval64(seccomp_mode, arg2, |
| 357 | "SECCOMP_MODE_???"); |
| 358 | if (SECCOMP_MODE_STRICT == arg2) |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 359 | return RVAL_DECODED; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 360 | if (SECCOMP_MODE_FILTER == arg2) { |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 361 | tprints(", "); |
Elliott Hughes | 77c3ff8 | 2017-09-08 17:11:00 -0700 | [diff] [blame] | 362 | decode_seccomp_fprog(tcp, arg3); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 363 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 364 | } |
Dmitry V. Levin | 3691562 | 2015-07-25 09:43:01 +0000 | [diff] [blame] | 365 | print_prctl_args(tcp, 2); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 366 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 367 | |
| 368 | case PR_SET_SECUREBITS: |
| 369 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 370 | printflags64(secbits, arg2, "SECBIT_???"); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 371 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 372 | |
| 373 | case PR_SET_TIMERSLACK: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 374 | tprintf(", %" PRI_kld, arg2); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 375 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 376 | |
| 377 | case PR_SET_TSC: |
| 378 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 379 | printxval(pr_tsc, arg2, "PR_TSC_???"); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 380 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 381 | |
| 382 | case PR_SET_UNALIGN: |
| 383 | tprints(", "); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 384 | printflags(pr_unalign_flags, arg2, "PR_UNALIGN_???"); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 385 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 386 | |
| 387 | case PR_SET_NO_NEW_PRIVS: |
| 388 | case PR_SET_THP_DISABLE: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 389 | tprintf(", %" PRI_klu, arg2); |
Dmitry V. Levin | 3691562 | 2015-07-25 09:43:01 +0000 | [diff] [blame] | 390 | print_prctl_args(tcp, 2); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 391 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 392 | |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 393 | case PR_MCE_KILL_GET: |
Dmitry V. Levin | 3691562 | 2015-07-25 09:43:01 +0000 | [diff] [blame] | 394 | if (entering(tcp)) { |
| 395 | print_prctl_args(tcp, 1); |
| 396 | return 0; |
| 397 | } |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 398 | if (syserror(tcp)) |
| 399 | return 0; |
Dmitry V. Levin | 9134aab | 2016-05-14 21:46:05 +0000 | [diff] [blame] | 400 | tcp->auxstr = xlookup(pr_mce_kill_policy, |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 401 | (kernel_ulong_t) tcp->u_rval); |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 402 | return RVAL_STR; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 403 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 404 | case PR_SET_FP_MODE: |
| 405 | tprints(", "); |
| 406 | printflags(pr_fp_mode, arg2, "PR_FP_MODE_???"); |
| 407 | return RVAL_DECODED; |
| 408 | |
Elliott Hughes | 03a418e | 2018-06-15 13:11:40 -0700 | [diff] [blame] | 409 | case PR_SET_SPECULATION_CTRL: |
| 410 | tprints(", "); |
| 411 | printxval64(pr_spec_cmds, arg2, "PR_SPEC_???"); |
| 412 | tprints(", "); |
| 413 | |
| 414 | switch (arg2) { |
| 415 | case PR_SPEC_STORE_BYPASS: |
| 416 | printxval64(pr_spec_set_store_bypass_flags, arg3, |
| 417 | "PR_SPEC_???"); |
| 418 | break; |
| 419 | |
| 420 | default: |
| 421 | tprintf("%#" PRI_klx, arg3); |
| 422 | } |
| 423 | |
| 424 | return RVAL_DECODED; |
| 425 | |
Dmitry V. Levin | 1b28330 | 2015-12-06 15:29:04 +0000 | [diff] [blame] | 426 | case PR_GET_NO_NEW_PRIVS: |
| 427 | case PR_GET_THP_DISABLE: |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 428 | case PR_MPX_DISABLE_MANAGEMENT: |
| 429 | case PR_MPX_ENABLE_MANAGEMENT: |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 430 | default: |
Dmitry V. Levin | 3691562 | 2015-07-25 09:43:01 +0000 | [diff] [blame] | 431 | print_prctl_args(tcp, 1); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 432 | return RVAL_DECODED; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 433 | } |
| 434 | return 0; |
| 435 | } |
| 436 | |
Elliott Hughes | 77c3ff8 | 2017-09-08 17:11:00 -0700 | [diff] [blame] | 437 | #if defined X86_64 || defined X32 || defined I386 |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 438 | # include "xlat/archvals.h" |
| 439 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 440 | SYS_FUNC(arch_prctl) |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 441 | { |
Dmitry V. Levin | b8eec60 | 2016-05-16 22:19:31 +0000 | [diff] [blame] | 442 | const unsigned int option = tcp->u_arg[0]; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 443 | const kernel_ulong_t addr = tcp->u_arg[1]; |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 444 | |
Dmitry V. Levin | b8eec60 | 2016-05-16 22:19:31 +0000 | [diff] [blame] | 445 | if (entering(tcp)) |
| 446 | printxval(archvals, option, "ARCH_???"); |
| 447 | |
| 448 | switch (option) { |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 449 | case ARCH_GET_GS: |
| 450 | case ARCH_GET_FS: |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 451 | if (entering(tcp)) |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 452 | tprints(", "); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 453 | else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 454 | printnum_ptr(tcp, addr); |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 455 | return 0; |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 456 | } |
Dmitry V. Levin | 1e88073 | 2015-02-14 01:51:03 +0000 | [diff] [blame] | 457 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 458 | tprintf(", %#" PRI_klx, addr); |
Dmitry V. Levin | 210a6b6 | 2015-07-17 21:49:17 +0000 | [diff] [blame] | 459 | return RVAL_DECODED; |
Dmitry V. Levin | 53c993d | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 460 | } |
Elliott Hughes | 77c3ff8 | 2017-09-08 17:11:00 -0700 | [diff] [blame] | 461 | #endif /* X86_64 || X32 || I386 */ |