187 lines · c
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */2#ifndef _UAPI_LINUX_PTRACE_H3#define _UAPI_LINUX_PTRACE_H4/* 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 9#include <linux/types.h>10 11#define PTRACE_TRACEME 012#define PTRACE_PEEKTEXT 113#define PTRACE_PEEKDATA 214#define PTRACE_PEEKUSR 315#define PTRACE_POKETEXT 416#define PTRACE_POKEDATA 517#define PTRACE_POKEUSR 618#define PTRACE_CONT 719#define PTRACE_KILL 820#define PTRACE_SINGLESTEP 921 22#define PTRACE_ATTACH 1623#define PTRACE_DETACH 1724 25#define PTRACE_SYSCALL 2426 27/* 0x4200-0x4300 are reserved for architecture-independent additions. */28#define PTRACE_SETOPTIONS 0x420029#define PTRACE_GETEVENTMSG 0x420130#define PTRACE_GETSIGINFO 0x420231#define PTRACE_SETSIGINFO 0x420332 33/*34 * Generic ptrace interface that exports the architecture specific regsets35 * 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 full37 * 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the38 * elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the39 * other user_regset flavors, the user_regset layout and the ELF core dump note40 * 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 0x420451#define PTRACE_SETREGSET 0x420552 53#define PTRACE_SEIZE 0x420654#define PTRACE_INTERRUPT 0x420755#define PTRACE_LISTEN 0x420856 57#define PTRACE_PEEKSIGINFO 0x420958 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 65#define PTRACE_GETSIGMASK 0x420a66#define PTRACE_SETSIGMASK 0x420b67 68#define PTRACE_SECCOMP_GET_FILTER 0x420c69#define PTRACE_SECCOMP_GET_METADATA 0x420d70 71struct seccomp_metadata {72 __u64 filter_off; /* Input: which filter */73 __u64 flags; /* Output: filter's flags */74};75 76#define PTRACE_GET_SYSCALL_INFO 0x420e77#define PTRACE_SYSCALL_INFO_NONE 078#define PTRACE_SYSCALL_INFO_ENTRY 179#define PTRACE_SYSCALL_INFO_EXIT 280#define PTRACE_SYSCALL_INFO_SECCOMP 381 82struct ptrace_syscall_info {83 __u8 op; /* PTRACE_SYSCALL_INFO_* */84 __u8 pad[3];85 __u32 arch;86 __u64 instruction_pointer;87 __u64 stack_pointer;88 union {89 struct {90 __u64 nr;91 __u64 args[6];92 } entry;93 struct {94 __s64 rval;95 __u8 is_error;96 } exit;97 struct {98 __u64 nr;99 __u64 args[6];100 __u32 ret_data;101 } seccomp;102 };103};104 105#define PTRACE_GET_RSEQ_CONFIGURATION 0x420f106 107struct ptrace_rseq_configuration {108 __u64 rseq_abi_pointer;109 __u32 rseq_abi_size;110 __u32 signature;111 __u32 flags;112 __u32 pad;113};114 115#define PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG 0x4210116#define PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG 0x4211117 118/*119 * struct ptrace_sud_config - Per-task configuration for Syscall User Dispatch120 * @mode: One of PR_SYS_DISPATCH_ON or PR_SYS_DISPATCH_OFF121 * @selector: Tracees user virtual address of SUD selector122 * @offset: SUD exclusion area (virtual address)123 * @len: Length of SUD exclusion area124 *125 * Used to get/set the syscall user dispatch configuration for a tracee.126 * Selector is optional (may be NULL), and if invalid will produce127 * a SIGSEGV in the tracee upon first access.128 *129 * If mode is PR_SYS_DISPATCH_ON, syscall dispatch will be enabled. If130 * PR_SYS_DISPATCH_OFF, syscall dispatch will be disabled and all other131 * parameters must be 0. The value in *selector (if not null), also determines132 * whether syscall dispatch will occur.133 *134 * The Syscall User Dispatch Exclusion area described by offset/len is the135 * virtual address space from which syscalls will not produce a user136 * dispatch.137 */138struct ptrace_sud_config {139 __u64 mode;140 __u64 selector;141 __u64 offset;142 __u64 len;143};144 145/*146 * These values are stored in task->ptrace_message147 * by ptrace_stop to describe the current syscall-stop.148 */149#define PTRACE_EVENTMSG_SYSCALL_ENTRY 1150#define PTRACE_EVENTMSG_SYSCALL_EXIT 2151 152/* Read signals from a shared (process wide) queue */153#define PTRACE_PEEKSIGINFO_SHARED (1 << 0)154 155/* Wait extended result codes for the above trace options. */156#define PTRACE_EVENT_FORK 1157#define PTRACE_EVENT_VFORK 2158#define PTRACE_EVENT_CLONE 3159#define PTRACE_EVENT_EXEC 4160#define PTRACE_EVENT_VFORK_DONE 5161#define PTRACE_EVENT_EXIT 6162#define PTRACE_EVENT_SECCOMP 7163/* Extended result codes which enabled by means other than options. */164#define PTRACE_EVENT_STOP 128165 166/* Options set using PTRACE_SETOPTIONS or using PTRACE_SEIZE @data param */167#define PTRACE_O_TRACESYSGOOD 1168#define PTRACE_O_TRACEFORK (1 << PTRACE_EVENT_FORK)169#define PTRACE_O_TRACEVFORK (1 << PTRACE_EVENT_VFORK)170#define PTRACE_O_TRACECLONE (1 << PTRACE_EVENT_CLONE)171#define PTRACE_O_TRACEEXEC (1 << PTRACE_EVENT_EXEC)172#define PTRACE_O_TRACEVFORKDONE (1 << PTRACE_EVENT_VFORK_DONE)173#define PTRACE_O_TRACEEXIT (1 << PTRACE_EVENT_EXIT)174#define PTRACE_O_TRACESECCOMP (1 << PTRACE_EVENT_SECCOMP)175 176/* eventless options */177#define PTRACE_O_EXITKILL (1 << 20)178#define PTRACE_O_SUSPEND_SECCOMP (1 << 21)179 180#define PTRACE_O_MASK (\181 0x000000ff | PTRACE_O_EXITKILL | PTRACE_O_SUSPEND_SECCOMP)182 183#include <asm/ptrace.h>184 185 186#endif /* _UAPI_LINUX_PTRACE_H */187