Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
| 6 | * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation |
| 7 | * Linux for s390 port by D.J. Barrow |
| 8 | * <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com> |
Wichert Akkerman | ccef637 | 2002-05-01 16:39:22 +0000 | [diff] [blame] | 9 | * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH |
| 10 | * port by Greg Banks <gbanks@pocketpenguins.com> |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 11 | * Copyright (c) 1999-2018 The strace developers. |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 12 | * |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 13 | * All rights reserved. |
| 14 | * |
| 15 | * Redistribution and use in source and binary forms, with or without |
| 16 | * modification, are permitted provided that the following conditions |
| 17 | * are met: |
| 18 | * 1. Redistributions of source code must retain the above copyright |
| 19 | * notice, this list of conditions and the following disclaimer. |
| 20 | * 2. Redistributions in binary form must reproduce the above copyright |
| 21 | * notice, this list of conditions and the following disclaimer in the |
| 22 | * documentation and/or other materials provided with the distribution. |
| 23 | * 3. The name of the author may not be used to endorse or promote products |
| 24 | * derived from this software without specific prior written permission. |
| 25 | * |
| 26 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 27 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 28 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 29 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 30 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 31 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 32 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 35 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 36 | */ |
| 37 | |
| 38 | #include "defs.h" |
Dmitry V. Levin | 6eee4e0 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 39 | |
Dmitry V. Levin | c41808b | 2013-03-18 00:52:29 +0000 | [diff] [blame] | 40 | #ifdef HAVE_ELF_H |
| 41 | # include <elf.h> |
| 42 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 43 | |
Dmitry V. Levin | fadf379 | 2015-02-13 00:26:38 +0000 | [diff] [blame] | 44 | #include "ptrace.h" |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 45 | #include "regs.h" |
| 46 | |
| 47 | #include "xlat/nt_descriptor_types.h" |
Dmitry V. Levin | 6eee4e0 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 48 | #include "xlat/ptrace_cmds.h" |
| 49 | #include "xlat/ptrace_setoptions_flags.h" |
Dmitry V. Levin | 809ee3e | 2016-05-12 15:45:24 +0000 | [diff] [blame] | 50 | #include "xlat/ptrace_peeksiginfo_flags.h" |
Dmitry V. Levin | 6eee4e0 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 51 | |
Denys Vlasenko | 513e9c2 | 2012-03-21 14:39:22 +0100 | [diff] [blame] | 52 | #define uoff(member) offsetof(struct user, member) |
Dmitry V. Levin | c6ce4fd | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 53 | #define XLAT_UOFF(member) { uoff(member), "offsetof(struct user, " #member ")" } |
Denys Vlasenko | 513e9c2 | 2012-03-21 14:39:22 +0100 | [diff] [blame] | 54 | |
Dmitry V. Levin | 8c0ef94 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 55 | static const struct xlat struct_user_offsets[] = { |
Dmitry V. Levin | fced7b0 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 56 | #include "userent.h" |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 57 | XLAT_END |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 60 | static void |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 61 | print_user_offset_addr(const kernel_ulong_t addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 62 | { |
Elliott Hughes | c187376 | 2018-12-19 15:13:36 -0800 | [diff] [blame] | 63 | bool no_str = false; |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 64 | const struct xlat *x; |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 65 | |
| 66 | for (x = struct_user_offsets; x->str; ++x) { |
| 67 | if (x->val >= addr) |
| 68 | break; |
| 69 | } |
| 70 | |
Elliott Hughes | c187376 | 2018-12-19 15:13:36 -0800 | [diff] [blame] | 71 | if (!x->str || (x == struct_user_offsets && x->val > addr)) |
| 72 | no_str = true; |
| 73 | if (no_str || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 74 | printaddr(addr); |
Elliott Hughes | c187376 | 2018-12-19 15:13:36 -0800 | [diff] [blame] | 75 | if (no_str || xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW) |
| 76 | return; |
| 77 | |
| 78 | if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) |
| 79 | tprints(" /* "); |
| 80 | |
| 81 | if (x->val > addr) { |
| 82 | --x; |
| 83 | tprintf("%s + %" PRI_klu, |
| 84 | x->str, addr - (kernel_ulong_t) x->val); |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 85 | } else { |
| 86 | tprints(x->str); |
| 87 | } |
Elliott Hughes | c187376 | 2018-12-19 15:13:36 -0800 | [diff] [blame] | 88 | |
| 89 | if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) |
| 90 | tprints(" */"); |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | SYS_FUNC(ptrace) |
| 94 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 95 | const kernel_ulong_t request = tcp->u_arg[0]; |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 96 | const int pid = tcp->u_arg[1]; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 97 | const kernel_ulong_t addr = tcp->u_arg[2]; |
| 98 | const kernel_ulong_t data = tcp->u_arg[3]; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 99 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 100 | if (entering(tcp)) { |
Dmitry V. Levin | 73a8e97 | 2016-05-12 14:45:38 +0000 | [diff] [blame] | 101 | /* request */ |
| 102 | printxval64(ptrace_cmds, request, "PTRACE_???"); |
| 103 | |
Dmitry V. Levin | 89ca4aa | 2016-05-12 15:03:58 +0000 | [diff] [blame] | 104 | if (request == PTRACE_TRACEME) { |
| 105 | /* pid, addr, and data are ignored. */ |
| 106 | return RVAL_DECODED; |
| 107 | } |
| 108 | |
Dmitry V. Levin | 73a8e97 | 2016-05-12 14:45:38 +0000 | [diff] [blame] | 109 | /* pid */ |
Dmitry V. Levin | 91bd125 | 2016-05-12 15:10:41 +0000 | [diff] [blame] | 110 | tprintf(", %d", pid); |
Denys Vlasenko | be99497 | 2013-02-13 16:10:10 +0100 | [diff] [blame] | 111 | |
Dmitry V. Levin | 73a8e97 | 2016-05-12 14:45:38 +0000 | [diff] [blame] | 112 | /* addr */ |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 113 | switch (request) { |
Dmitry V. Levin | 91bd125 | 2016-05-12 15:10:41 +0000 | [diff] [blame] | 114 | case PTRACE_ATTACH: |
| 115 | case PTRACE_INTERRUPT: |
| 116 | case PTRACE_KILL: |
| 117 | case PTRACE_LISTEN: |
| 118 | /* addr and data are ignored */ |
| 119 | return RVAL_DECODED; |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 120 | case PTRACE_PEEKUSER: |
| 121 | case PTRACE_POKEUSER: |
Dmitry V. Levin | 91bd125 | 2016-05-12 15:10:41 +0000 | [diff] [blame] | 122 | tprints(", "); |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 123 | print_user_offset_addr(addr); |
| 124 | break; |
| 125 | case PTRACE_GETREGSET: |
| 126 | case PTRACE_SETREGSET: |
Dmitry V. Levin | 91bd125 | 2016-05-12 15:10:41 +0000 | [diff] [blame] | 127 | tprints(", "); |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 128 | printxval(nt_descriptor_types, addr, "NT_???"); |
| 129 | break; |
Dmitry V. Levin | 3a5cd34 | 2016-05-12 15:38:35 +0000 | [diff] [blame] | 130 | case PTRACE_GETSIGMASK: |
| 131 | case PTRACE_SETSIGMASK: |
| 132 | case PTRACE_SECCOMP_GET_FILTER: |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 133 | case PTRACE_SECCOMP_GET_METADATA: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 134 | tprintf(", %" PRI_klu, addr); |
Dmitry V. Levin | 3a5cd34 | 2016-05-12 15:38:35 +0000 | [diff] [blame] | 135 | break; |
Dmitry V. Levin | 809ee3e | 2016-05-12 15:45:24 +0000 | [diff] [blame] | 136 | case PTRACE_PEEKSIGINFO: { |
| 137 | tprints(", "); |
| 138 | struct { |
| 139 | uint64_t off; |
| 140 | uint32_t flags; |
| 141 | uint32_t nr; |
| 142 | } psi; |
| 143 | if (umove_or_printaddr(tcp, addr, &psi)) { |
| 144 | tprints(", "); |
| 145 | printaddr(data); |
| 146 | return RVAL_DECODED; |
| 147 | } |
| 148 | tprintf("{off=%" PRIu64 ", flags=", psi.off); |
| 149 | printflags(ptrace_peeksiginfo_flags, psi.flags, |
| 150 | "PTRACE_PEEKSIGINFO_???"); |
| 151 | tprintf(", nr=%u}", psi.nr); |
| 152 | break; |
| 153 | } |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 154 | default: |
Dmitry V. Levin | 91bd125 | 2016-05-12 15:10:41 +0000 | [diff] [blame] | 155 | tprints(", "); |
Dmitry V. Levin | 14446eb | 2015-07-17 21:12:05 +0000 | [diff] [blame] | 156 | printaddr(addr); |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 157 | } |
| 158 | |
Dmitry V. Levin | 8bd7f31 | 2016-05-12 16:49:34 +0000 | [diff] [blame] | 159 | # if defined IA64 || defined SPARC || defined SPARC64 |
| 160 | switch (request) { |
| 161 | # ifdef IA64 |
| 162 | case PTRACE_PEEKDATA: |
| 163 | case PTRACE_PEEKTEXT: |
| 164 | case PTRACE_PEEKUSER: |
| 165 | /* data is ignored */ |
| 166 | return RVAL_DECODED | RVAL_HEX; |
| 167 | # endif /* IA64 */ |
| 168 | # if defined SPARC || defined SPARC64 |
| 169 | case PTRACE_GETREGS: |
| 170 | case PTRACE_SETREGS: |
| 171 | case PTRACE_GETFPREGS: |
| 172 | case PTRACE_SETFPREGS: |
| 173 | /* data is ignored */ |
| 174 | return RVAL_DECODED; |
| 175 | # endif /* SPARC || SPARC64 */ |
| 176 | } |
| 177 | # endif /* IA64 || SPARC || SPARC64 */ |
| 178 | |
Dmitry V. Levin | 14446eb | 2015-07-17 21:12:05 +0000 | [diff] [blame] | 179 | tprints(", "); |
Denys Vlasenko | be99497 | 2013-02-13 16:10:10 +0100 | [diff] [blame] | 180 | |
Dmitry V. Levin | 91bd125 | 2016-05-12 15:10:41 +0000 | [diff] [blame] | 181 | /* data */ |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 182 | switch (request) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 183 | case PTRACE_CONT: |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 184 | case PTRACE_DETACH: |
Dmitry V. Levin | caa2bc3 | 2016-05-12 15:50:43 +0000 | [diff] [blame] | 185 | case PTRACE_SYSCALL: |
| 186 | #ifdef PTRACE_SINGLESTEP |
| 187 | case PTRACE_SINGLESTEP: |
| 188 | #endif |
| 189 | #ifdef PTRACE_SINGLEBLOCK |
| 190 | case PTRACE_SINGLEBLOCK: |
| 191 | #endif |
| 192 | #ifdef PTRACE_SYSEMU |
| 193 | case PTRACE_SYSEMU: |
| 194 | #endif |
| 195 | #ifdef PTRACE_SYSEMU_SINGLESTEP |
| 196 | case PTRACE_SYSEMU_SINGLESTEP: |
| 197 | #endif |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 198 | printsignal(data); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 199 | break; |
Dmitry V. Levin | 7c8e330 | 2016-05-12 15:53:28 +0000 | [diff] [blame] | 200 | case PTRACE_SEIZE: |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 201 | case PTRACE_SETOPTIONS: |
Dmitry V. Levin | 7c8e330 | 2016-05-12 15:53:28 +0000 | [diff] [blame] | 202 | #ifdef PTRACE_OLDSETOPTIONS |
| 203 | case PTRACE_OLDSETOPTIONS: |
| 204 | #endif |
Dmitry V. Levin | 388aca6 | 2016-05-12 16:35:54 +0000 | [diff] [blame] | 205 | printflags64(ptrace_setoptions_flags, data, "PTRACE_O_???"); |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 206 | break; |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 207 | case PTRACE_SETSIGINFO: |
| 208 | printsiginfo_at(tcp, data); |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 209 | break; |
Dmitry V. Levin | 1634de7 | 2016-05-12 16:52:49 +0000 | [diff] [blame] | 210 | case PTRACE_SETSIGMASK: |
| 211 | print_sigset_addr_len(tcp, data, addr); |
| 212 | break; |
Denys Vlasenko | be99497 | 2013-02-13 16:10:10 +0100 | [diff] [blame] | 213 | case PTRACE_SETREGSET: |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 214 | tprint_iov(tcp, /*len:*/ 1, data, IOV_DECODE_ADDR); |
Denys Vlasenko | be99497 | 2013-02-13 16:10:10 +0100 | [diff] [blame] | 215 | break; |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 216 | case PTRACE_SECCOMP_GET_METADATA: |
| 217 | if (verbose(tcp)) { |
| 218 | uint64_t filter_off; |
| 219 | if (addr < sizeof(filter_off) || |
| 220 | umove(tcp, data, &filter_off)) { |
| 221 | printaddr(data); |
| 222 | return RVAL_DECODED; |
| 223 | } |
| 224 | |
| 225 | tprintf("{filter_off=%" PRIu64, filter_off); |
| 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | printaddr(data); |
| 230 | break; |
Dmitry V. Levin | 8bd7f31 | 2016-05-12 16:49:34 +0000 | [diff] [blame] | 231 | #ifndef IA64 |
| 232 | case PTRACE_PEEKDATA: |
| 233 | case PTRACE_PEEKTEXT: |
| 234 | case PTRACE_PEEKUSER: |
| 235 | #endif |
Dmitry V. Levin | 846f617 | 2016-05-12 16:56:30 +0000 | [diff] [blame] | 236 | case PTRACE_GETEVENTMSG: |
Dmitry V. Levin | fadf379 | 2015-02-13 00:26:38 +0000 | [diff] [blame] | 237 | case PTRACE_GETREGSET: |
Dmitry V. Levin | 8bd7f31 | 2016-05-12 16:49:34 +0000 | [diff] [blame] | 238 | case PTRACE_GETSIGINFO: |
Dmitry V. Levin | 1634de7 | 2016-05-12 16:52:49 +0000 | [diff] [blame] | 239 | case PTRACE_GETSIGMASK: |
Dmitry V. Levin | 76b4c33 | 2016-05-13 02:33:33 +0000 | [diff] [blame] | 240 | case PTRACE_PEEKSIGINFO: |
Dmitry V. Levin | d9fb4a4 | 2016-05-12 16:58:38 +0000 | [diff] [blame] | 241 | case PTRACE_SECCOMP_GET_FILTER: |
Dmitry V. Levin | 8bd7f31 | 2016-05-12 16:49:34 +0000 | [diff] [blame] | 242 | if (verbose(tcp)) { |
| 243 | /* print data on exiting syscall */ |
| 244 | return 0; |
| 245 | } |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 246 | ATTRIBUTE_FALLTHROUGH; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 247 | default: |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 248 | printaddr(data); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 249 | break; |
| 250 | } |
Dmitry V. Levin | 8bd7f31 | 2016-05-12 16:49:34 +0000 | [diff] [blame] | 251 | |
| 252 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 253 | } else { |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 254 | switch (request) { |
Dmitry V. Levin | 8bd7f31 | 2016-05-12 16:49:34 +0000 | [diff] [blame] | 255 | #ifndef IA64 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 256 | case PTRACE_PEEKDATA: |
| 257 | case PTRACE_PEEKTEXT: |
| 258 | case PTRACE_PEEKUSER: |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 259 | printnum_ptr(tcp, data); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 260 | break; |
Denys Vlasenko | 3e3490a | 2012-03-17 01:27:37 +0100 | [diff] [blame] | 261 | #endif |
Dmitry V. Levin | 846f617 | 2016-05-12 16:56:30 +0000 | [diff] [blame] | 262 | case PTRACE_GETEVENTMSG: |
| 263 | printnum_ulong(tcp, data); |
| 264 | break; |
| 265 | case PTRACE_GETREGSET: |
Fabien Siron | 2a54d8b | 2016-06-22 13:27:03 +0000 | [diff] [blame] | 266 | tprint_iov(tcp, /*len:*/ 1, data, IOV_DECODE_ADDR); |
Dmitry V. Levin | 846f617 | 2016-05-12 16:56:30 +0000 | [diff] [blame] | 267 | break; |
Dmitry V. Levin | ccdc82a | 2016-04-01 00:28:33 +0000 | [diff] [blame] | 268 | case PTRACE_GETSIGINFO: |
| 269 | printsiginfo_at(tcp, data); |
Denys Vlasenko | f535b54 | 2009-01-13 18:30:55 +0000 | [diff] [blame] | 270 | break; |
Dmitry V. Levin | 1634de7 | 2016-05-12 16:52:49 +0000 | [diff] [blame] | 271 | case PTRACE_GETSIGMASK: |
| 272 | print_sigset_addr_len(tcp, data, addr); |
| 273 | break; |
Dmitry V. Levin | 76b4c33 | 2016-05-13 02:33:33 +0000 | [diff] [blame] | 274 | case PTRACE_PEEKSIGINFO: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 275 | print_siginfo_array(tcp, data, tcp->u_rval); |
Dmitry V. Levin | 76b4c33 | 2016-05-13 02:33:33 +0000 | [diff] [blame] | 276 | break; |
Dmitry V. Levin | d9fb4a4 | 2016-05-12 16:58:38 +0000 | [diff] [blame] | 277 | case PTRACE_SECCOMP_GET_FILTER: |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 278 | print_seccomp_fprog(tcp, data, tcp->u_rval); |
Dmitry V. Levin | d9fb4a4 | 2016-05-12 16:58:38 +0000 | [diff] [blame] | 279 | break; |
Elliott Hughes | 28e98bc | 2018-06-14 16:59:04 -0700 | [diff] [blame] | 280 | case PTRACE_SECCOMP_GET_METADATA: { |
| 281 | const size_t offset = sizeof(uint64_t); |
| 282 | uint64_t flags = 0; |
| 283 | size_t ret_size = MIN((kernel_ulong_t) tcp->u_rval, |
| 284 | offset + sizeof(flags)); |
| 285 | |
| 286 | if (syserror(tcp) || ret_size <= offset) { |
| 287 | tprints("}"); |
| 288 | return 0; |
| 289 | } |
| 290 | |
| 291 | if (umoven(tcp, data + offset, ret_size - offset, |
| 292 | &flags)) { |
| 293 | tprints(", ...}"); |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | tprints(", flags="); |
| 298 | printflags64(seccomp_filter_flags, flags, |
| 299 | "SECCOMP_FILTER_FLAG_???"); |
| 300 | |
| 301 | if ((kernel_ulong_t) tcp->u_rval > ret_size) |
| 302 | tprints(", ..."); |
| 303 | |
| 304 | tprints("}"); |
| 305 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 306 | } |
| 307 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 308 | return 0; |
| 309 | } |