blob: d5a1b8a492b93ddb6dd41cf23d759c4059bc8660 [file] [log] [blame]
Greg Kroah-Hartman6f52b162017-11-01 15:08:43 +01001/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
David Howells607ca462012-10-13 10:46:48 +01002#ifndef _UAPI_LINUX_PTRACE_H
3#define _UAPI_LINUX_PTRACE_H
4/* ptrace.h */
5/* structs and defines to help the user use the ptrace system call. */
6
7/* has the defines to get at the registers. */
8
Andrey Vagin84c751b2013-04-30 15:27:59 -07009#include <linux/types.h>
David Howells607ca462012-10-13 10:46:48 +010010
11#define PTRACE_TRACEME 0
12#define PTRACE_PEEKTEXT 1
13#define PTRACE_PEEKDATA 2
14#define PTRACE_PEEKUSR 3
15#define PTRACE_POKETEXT 4
16#define PTRACE_POKEDATA 5
17#define PTRACE_POKEUSR 6
18#define PTRACE_CONT 7
19#define PTRACE_KILL 8
20#define PTRACE_SINGLESTEP 9
21
22#define PTRACE_ATTACH 16
23#define PTRACE_DETACH 17
24
25#define PTRACE_SYSCALL 24
26
27/* 0x4200-0x4300 are reserved for architecture-independent additions. */
28#define PTRACE_SETOPTIONS 0x4200
29#define PTRACE_GETEVENTMSG 0x4201
30#define PTRACE_GETSIGINFO 0x4202
31#define PTRACE_SETSIGINFO 0x4203
32
33/*
34 * Generic ptrace interface that exports the architecture specific regsets
35 * using the corresponding NT_* types (which are also used in the core dump).
36 * Please note that the NT_PRSTATUS note type in a core dump contains a full
37 * 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the
38 * elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the
39 * other user_regset flavors, the user_regset layout and the ELF core dump note
40 * payload are exactly the same layout.
41 *
42 * This interface usage is as follows:
43 * struct iovec iov = { buf, len};
44 *
45 * ret = ptrace(PTRACE_GETREGSET/PTRACE_SETREGSET, pid, NT_XXX_TYPE, &iov);
46 *
47 * On the successful completion, iov.len will be updated by the kernel,
48 * specifying how much the kernel has written/read to/from the user's iov.buf.
49 */
50#define PTRACE_GETREGSET 0x4204
51#define PTRACE_SETREGSET 0x4205
52
53#define PTRACE_SEIZE 0x4206
54#define PTRACE_INTERRUPT 0x4207
55#define PTRACE_LISTEN 0x4208
56
Andrey Vagin84c751b2013-04-30 15:27:59 -070057#define PTRACE_PEEKSIGINFO 0x4209
58
59struct ptrace_peeksiginfo_args {
60 __u64 off; /* from which siginfo to start */
61 __u32 flags;
62 __s32 nr; /* how may siginfos to take */
63};
64
Andrey Vagin29000ca2013-07-03 15:08:12 -070065#define PTRACE_GETSIGMASK 0x420a
66#define PTRACE_SETSIGMASK 0x420b
67
Tycho Andersenf8e529e2015-10-27 09:23:59 +090068#define PTRACE_SECCOMP_GET_FILTER 0x420c
Tycho Andersen26500472017-10-11 09:39:21 -060069#define PTRACE_SECCOMP_GET_METADATA 0x420d
70
71struct seccomp_metadata {
Tycho Andersen2a040f92018-02-20 19:47:45 -070072 __u64 filter_off; /* Input: which filter */
73 __u64 flags; /* Output: filter's flags */
Tycho Andersen26500472017-10-11 09:39:21 -060074};
Tycho Andersenf8e529e2015-10-27 09:23:59 +090075
Andrey Vagin84c751b2013-04-30 15:27:59 -070076/* Read signals from a shared (process wide) queue */
77#define PTRACE_PEEKSIGINFO_SHARED (1 << 0)
78
David Howells607ca462012-10-13 10:46:48 +010079/* Wait extended result codes for the above trace options. */
80#define PTRACE_EVENT_FORK 1
81#define PTRACE_EVENT_VFORK 2
82#define PTRACE_EVENT_CLONE 3
83#define PTRACE_EVENT_EXEC 4
84#define PTRACE_EVENT_VFORK_DONE 5
85#define PTRACE_EVENT_EXIT 6
86#define PTRACE_EVENT_SECCOMP 7
87/* Extended result codes which enabled by means other than options. */
88#define PTRACE_EVENT_STOP 128
89
90/* Options set using PTRACE_SETOPTIONS or using PTRACE_SEIZE @data param */
91#define PTRACE_O_TRACESYSGOOD 1
92#define PTRACE_O_TRACEFORK (1 << PTRACE_EVENT_FORK)
93#define PTRACE_O_TRACEVFORK (1 << PTRACE_EVENT_VFORK)
94#define PTRACE_O_TRACECLONE (1 << PTRACE_EVENT_CLONE)
95#define PTRACE_O_TRACEEXEC (1 << PTRACE_EVENT_EXEC)
96#define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE)
97#define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT)
98#define PTRACE_O_TRACESECCOMP (1 << PTRACE_EVENT_SECCOMP)
99
Oleg Nesterov992fb6e2012-12-17 16:03:07 -0800100/* eventless options */
Tycho Andersen13c4a902015-06-13 09:02:48 -0600101#define PTRACE_O_EXITKILL (1 << 20)
102#define PTRACE_O_SUSPEND_SECCOMP (1 << 21)
Oleg Nesterov992fb6e2012-12-17 16:03:07 -0800103
Tycho Andersen13c4a902015-06-13 09:02:48 -0600104#define PTRACE_O_MASK (\
105 0x000000ff | PTRACE_O_EXITKILL | PTRACE_O_SUSPEND_SECCOMP)
David Howells607ca462012-10-13 10:46:48 +0100106
107#include <asm/ptrace.h>
108
109
110#endif /* _UAPI_LINUX_PTRACE_H */