16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells #ifndef _LINUX_PRCTL_H 3607ca46eSDavid Howells #define _LINUX_PRCTL_H 4607ca46eSDavid Howells 5f606b77fSCyrill Gorcunov #include <linux/types.h> 6f606b77fSCyrill Gorcunov 7607ca46eSDavid Howells /* Values to pass as first argument to prctl() */ 8607ca46eSDavid Howells 9607ca46eSDavid Howells #define PR_SET_PDEATHSIG 1 /* Second arg is a signal */ 10607ca46eSDavid Howells #define PR_GET_PDEATHSIG 2 /* Second arg is a ptr to return the signal */ 11607ca46eSDavid Howells 12607ca46eSDavid Howells /* Get/set current->mm->dumpable */ 13607ca46eSDavid Howells #define PR_GET_DUMPABLE 3 14607ca46eSDavid Howells #define PR_SET_DUMPABLE 4 15607ca46eSDavid Howells 16607ca46eSDavid Howells /* Get/set unaligned access control bits (if meaningful) */ 17607ca46eSDavid Howells #define PR_GET_UNALIGN 5 18607ca46eSDavid Howells #define PR_SET_UNALIGN 6 19607ca46eSDavid Howells # define PR_UNALIGN_NOPRINT 1 /* silently fix up unaligned user accesses */ 20607ca46eSDavid Howells # define PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user access */ 21607ca46eSDavid Howells 22607ca46eSDavid Howells /* Get/set whether or not to drop capabilities on setuid() away from 23607ca46eSDavid Howells * uid 0 (as per security/commoncap.c) */ 24607ca46eSDavid Howells #define PR_GET_KEEPCAPS 7 25607ca46eSDavid Howells #define PR_SET_KEEPCAPS 8 26607ca46eSDavid Howells 27607ca46eSDavid Howells /* Get/set floating-point emulation control bits (if meaningful) */ 28607ca46eSDavid Howells #define PR_GET_FPEMU 9 29607ca46eSDavid Howells #define PR_SET_FPEMU 10 30607ca46eSDavid Howells # define PR_FPEMU_NOPRINT 1 /* silently emulate fp operations accesses */ 31607ca46eSDavid Howells # define PR_FPEMU_SIGFPE 2 /* don't emulate fp operations, send SIGFPE instead */ 32607ca46eSDavid Howells 33607ca46eSDavid Howells /* Get/set floating-point exception mode (if meaningful) */ 34607ca46eSDavid Howells #define PR_GET_FPEXC 11 35607ca46eSDavid Howells #define PR_SET_FPEXC 12 36607ca46eSDavid Howells # define PR_FP_EXC_SW_ENABLE 0x80 /* Use FPEXC for FP exception enables */ 37607ca46eSDavid Howells # define PR_FP_EXC_DIV 0x010000 /* floating point divide by zero */ 38607ca46eSDavid Howells # define PR_FP_EXC_OVF 0x020000 /* floating point overflow */ 39607ca46eSDavid Howells # define PR_FP_EXC_UND 0x040000 /* floating point underflow */ 40607ca46eSDavid Howells # define PR_FP_EXC_RES 0x080000 /* floating point inexact result */ 41607ca46eSDavid Howells # define PR_FP_EXC_INV 0x100000 /* floating point invalid operation */ 42607ca46eSDavid Howells # define PR_FP_EXC_DISABLED 0 /* FP exceptions disabled */ 43607ca46eSDavid Howells # define PR_FP_EXC_NONRECOV 1 /* async non-recoverable exc. mode */ 44607ca46eSDavid Howells # define PR_FP_EXC_ASYNC 2 /* async recoverable exception mode */ 45607ca46eSDavid Howells # define PR_FP_EXC_PRECISE 3 /* precise exception mode */ 46607ca46eSDavid Howells 47607ca46eSDavid Howells /* Get/set whether we use statistical process timing or accurate timestamp 48607ca46eSDavid Howells * based process timing */ 49607ca46eSDavid Howells #define PR_GET_TIMING 13 50607ca46eSDavid Howells #define PR_SET_TIMING 14 51607ca46eSDavid Howells # define PR_TIMING_STATISTICAL 0 /* Normal, traditional, 52607ca46eSDavid Howells statistical process timing */ 53607ca46eSDavid Howells # define PR_TIMING_TIMESTAMP 1 /* Accurate timestamp based 54607ca46eSDavid Howells process timing */ 55607ca46eSDavid Howells 56607ca46eSDavid Howells #define PR_SET_NAME 15 /* Set process name */ 57607ca46eSDavid Howells #define PR_GET_NAME 16 /* Get process name */ 58607ca46eSDavid Howells 59607ca46eSDavid Howells /* Get/set process endian */ 60607ca46eSDavid Howells #define PR_GET_ENDIAN 19 61607ca46eSDavid Howells #define PR_SET_ENDIAN 20 62607ca46eSDavid Howells # define PR_ENDIAN_BIG 0 63607ca46eSDavid Howells # define PR_ENDIAN_LITTLE 1 /* True little endian mode */ 64607ca46eSDavid Howells # define PR_ENDIAN_PPC_LITTLE 2 /* "PowerPC" pseudo little endian */ 65607ca46eSDavid Howells 66607ca46eSDavid Howells /* Get/set process seccomp mode */ 67607ca46eSDavid Howells #define PR_GET_SECCOMP 21 68607ca46eSDavid Howells #define PR_SET_SECCOMP 22 69607ca46eSDavid Howells 70607ca46eSDavid Howells /* Get/set the capability bounding set (as per security/commoncap.c) */ 71607ca46eSDavid Howells #define PR_CAPBSET_READ 23 72607ca46eSDavid Howells #define PR_CAPBSET_DROP 24 73607ca46eSDavid Howells 74607ca46eSDavid Howells /* Get/set the process' ability to use the timestamp counter instruction */ 75607ca46eSDavid Howells #define PR_GET_TSC 25 76607ca46eSDavid Howells #define PR_SET_TSC 26 77607ca46eSDavid Howells # define PR_TSC_ENABLE 1 /* allow the use of the timestamp counter */ 78607ca46eSDavid Howells # define PR_TSC_SIGSEGV 2 /* throw a SIGSEGV instead of reading the TSC */ 79607ca46eSDavid Howells 80607ca46eSDavid Howells /* Get/set securebits (as per security/commoncap.c) */ 81607ca46eSDavid Howells #define PR_GET_SECUREBITS 27 82607ca46eSDavid Howells #define PR_SET_SECUREBITS 28 83607ca46eSDavid Howells 84607ca46eSDavid Howells /* 85607ca46eSDavid Howells * Get/set the timerslack as used by poll/select/nanosleep 86607ca46eSDavid Howells * A value of 0 means "use default" 87607ca46eSDavid Howells */ 88607ca46eSDavid Howells #define PR_SET_TIMERSLACK 29 89607ca46eSDavid Howells #define PR_GET_TIMERSLACK 30 90607ca46eSDavid Howells 91607ca46eSDavid Howells #define PR_TASK_PERF_EVENTS_DISABLE 31 92607ca46eSDavid Howells #define PR_TASK_PERF_EVENTS_ENABLE 32 93607ca46eSDavid Howells 94607ca46eSDavid Howells /* 95607ca46eSDavid Howells * Set early/late kill mode for hwpoison memory corruption. 96607ca46eSDavid Howells * This influences when the process gets killed on a memory corruption. 97607ca46eSDavid Howells */ 98607ca46eSDavid Howells #define PR_MCE_KILL 33 99607ca46eSDavid Howells # define PR_MCE_KILL_CLEAR 0 100607ca46eSDavid Howells # define PR_MCE_KILL_SET 1 101607ca46eSDavid Howells 102607ca46eSDavid Howells # define PR_MCE_KILL_LATE 0 103607ca46eSDavid Howells # define PR_MCE_KILL_EARLY 1 104607ca46eSDavid Howells # define PR_MCE_KILL_DEFAULT 2 105607ca46eSDavid Howells 106607ca46eSDavid Howells #define PR_MCE_KILL_GET 34 107607ca46eSDavid Howells 108607ca46eSDavid Howells /* 109607ca46eSDavid Howells * Tune up process memory map specifics. 110607ca46eSDavid Howells */ 111607ca46eSDavid Howells #define PR_SET_MM 35 112607ca46eSDavid Howells # define PR_SET_MM_START_CODE 1 113607ca46eSDavid Howells # define PR_SET_MM_END_CODE 2 114607ca46eSDavid Howells # define PR_SET_MM_START_DATA 3 115607ca46eSDavid Howells # define PR_SET_MM_END_DATA 4 116607ca46eSDavid Howells # define PR_SET_MM_START_STACK 5 117607ca46eSDavid Howells # define PR_SET_MM_START_BRK 6 118607ca46eSDavid Howells # define PR_SET_MM_BRK 7 119607ca46eSDavid Howells # define PR_SET_MM_ARG_START 8 120607ca46eSDavid Howells # define PR_SET_MM_ARG_END 9 121607ca46eSDavid Howells # define PR_SET_MM_ENV_START 10 122607ca46eSDavid Howells # define PR_SET_MM_ENV_END 11 123607ca46eSDavid Howells # define PR_SET_MM_AUXV 12 124607ca46eSDavid Howells # define PR_SET_MM_EXE_FILE 13 125f606b77fSCyrill Gorcunov # define PR_SET_MM_MAP 14 126f606b77fSCyrill Gorcunov # define PR_SET_MM_MAP_SIZE 15 127f606b77fSCyrill Gorcunov 128f606b77fSCyrill Gorcunov /* 129f606b77fSCyrill Gorcunov * This structure provides new memory descriptor 130f606b77fSCyrill Gorcunov * map which mostly modifies /proc/pid/stat[m] 131f606b77fSCyrill Gorcunov * output for a task. This mostly done in a 132f606b77fSCyrill Gorcunov * sake of checkpoint/restore functionality. 133f606b77fSCyrill Gorcunov */ 134f606b77fSCyrill Gorcunov struct prctl_mm_map { 135f606b77fSCyrill Gorcunov __u64 start_code; /* code section bounds */ 136f606b77fSCyrill Gorcunov __u64 end_code; 137f606b77fSCyrill Gorcunov __u64 start_data; /* data section bounds */ 138f606b77fSCyrill Gorcunov __u64 end_data; 139f606b77fSCyrill Gorcunov __u64 start_brk; /* heap for brk() syscall */ 140f606b77fSCyrill Gorcunov __u64 brk; 141f606b77fSCyrill Gorcunov __u64 start_stack; /* stack starts at */ 142f606b77fSCyrill Gorcunov __u64 arg_start; /* command line arguments bounds */ 143f606b77fSCyrill Gorcunov __u64 arg_end; 144f606b77fSCyrill Gorcunov __u64 env_start; /* environment variables bounds */ 145f606b77fSCyrill Gorcunov __u64 env_end; 146f606b77fSCyrill Gorcunov __u64 *auxv; /* auxiliary vector */ 147f606b77fSCyrill Gorcunov __u32 auxv_size; /* vector size */ 148f606b77fSCyrill Gorcunov __u32 exe_fd; /* /proc/$pid/exe link file */ 149f606b77fSCyrill Gorcunov }; 150607ca46eSDavid Howells 151607ca46eSDavid Howells /* 152607ca46eSDavid Howells * Set specific pid that is allowed to ptrace the current task. 153607ca46eSDavid Howells * A value of 0 mean "no process". 154607ca46eSDavid Howells */ 155607ca46eSDavid Howells #define PR_SET_PTRACER 0x59616d61 156607ca46eSDavid Howells # define PR_SET_PTRACER_ANY ((unsigned long)-1) 157607ca46eSDavid Howells 158607ca46eSDavid Howells #define PR_SET_CHILD_SUBREAPER 36 159607ca46eSDavid Howells #define PR_GET_CHILD_SUBREAPER 37 160607ca46eSDavid Howells 161607ca46eSDavid Howells /* 162607ca46eSDavid Howells * If no_new_privs is set, then operations that grant new privileges (i.e. 163607ca46eSDavid Howells * execve) will either fail or not grant them. This affects suid/sgid, 164607ca46eSDavid Howells * file capabilities, and LSMs. 165607ca46eSDavid Howells * 166607ca46eSDavid Howells * Operations that merely manipulate or drop existing privileges (setresuid, 167607ca46eSDavid Howells * capset, etc.) will still work. Drop those privileges if you want them gone. 168607ca46eSDavid Howells * 169607ca46eSDavid Howells * Changing LSM security domain is considered a new privilege. So, for example, 170607ca46eSDavid Howells * asking selinux for a specific new context (e.g. with runcon) will result 171607ca46eSDavid Howells * in execve returning -EPERM. 172607ca46eSDavid Howells * 1735fb94e9cSMauro Carvalho Chehab * See Documentation/userspace-api/no_new_privs.rst for more details. 174607ca46eSDavid Howells */ 175607ca46eSDavid Howells #define PR_SET_NO_NEW_PRIVS 38 176607ca46eSDavid Howells #define PR_GET_NO_NEW_PRIVS 39 177607ca46eSDavid Howells 178607ca46eSDavid Howells #define PR_GET_TID_ADDRESS 40 179607ca46eSDavid Howells 180a0715cc2SAlex Thorlton #define PR_SET_THP_DISABLE 41 181a0715cc2SAlex Thorlton #define PR_GET_THP_DISABLE 42 182a0715cc2SAlex Thorlton 183fe3d197fSDave Hansen /* 184f240652bSDave Hansen * No longer implemented, but left here to ensure the numbers stay reserved: 185fe3d197fSDave Hansen */ 186fe3d197fSDave Hansen #define PR_MPX_ENABLE_MANAGEMENT 43 187fe3d197fSDave Hansen #define PR_MPX_DISABLE_MANAGEMENT 44 188fe3d197fSDave Hansen 1899791554bSPaul Burton #define PR_SET_FP_MODE 45 1909791554bSPaul Burton #define PR_GET_FP_MODE 46 1919791554bSPaul Burton # define PR_FP_MODE_FR (1 << 0) /* 64b FP registers */ 1929791554bSPaul Burton # define PR_FP_MODE_FRE (1 << 1) /* 32b compatibility */ 1939791554bSPaul Burton 19458319057SAndy Lutomirski /* Control the ambient capability set */ 19558319057SAndy Lutomirski #define PR_CAP_AMBIENT 47 19658319057SAndy Lutomirski # define PR_CAP_AMBIENT_IS_SET 1 19758319057SAndy Lutomirski # define PR_CAP_AMBIENT_RAISE 2 19858319057SAndy Lutomirski # define PR_CAP_AMBIENT_LOWER 3 19958319057SAndy Lutomirski # define PR_CAP_AMBIENT_CLEAR_ALL 4 20058319057SAndy Lutomirski 2017582e220SDave Martin /* arm64 Scalable Vector Extension controls */ 2022d2123bcSDave Martin /* Flag values must be kept in sync with ptrace NT_ARM_SVE interface */ 2032d2123bcSDave Martin #define PR_SVE_SET_VL 50 /* set task vector length */ 2047582e220SDave Martin # define PR_SVE_SET_VL_ONEXEC (1 << 18) /* defer effect until exec */ 2052d2123bcSDave Martin #define PR_SVE_GET_VL 51 /* get task vector length */ 2062d2123bcSDave Martin /* Bits common to PR_SVE_SET_VL and PR_SVE_GET_VL */ 2077582e220SDave Martin # define PR_SVE_VL_LEN_MASK 0xffff 2087582e220SDave Martin # define PR_SVE_VL_INHERIT (1 << 17) /* inherit across exec */ 2097582e220SDave Martin 210b617cfc8SThomas Gleixner /* Per task speculation control */ 211b617cfc8SThomas Gleixner #define PR_GET_SPECULATION_CTRL 52 212b617cfc8SThomas Gleixner #define PR_SET_SPECULATION_CTRL 53 213b617cfc8SThomas Gleixner /* Speculation control variants */ 214b617cfc8SThomas Gleixner # define PR_SPEC_STORE_BYPASS 0 2159137bb27SThomas Gleixner # define PR_SPEC_INDIRECT_BRANCH 1 216e893bb1bSBalbir Singh # define PR_SPEC_L1D_FLUSH 2 217b617cfc8SThomas Gleixner /* Return and control values for PR_SET/GET_SPECULATION_CTRL */ 218b617cfc8SThomas Gleixner # define PR_SPEC_NOT_AFFECTED 0 219b617cfc8SThomas Gleixner # define PR_SPEC_PRCTL (1UL << 0) 220b617cfc8SThomas Gleixner # define PR_SPEC_ENABLE (1UL << 1) 221b617cfc8SThomas Gleixner # define PR_SPEC_DISABLE (1UL << 2) 222356e4bffSThomas Gleixner # define PR_SPEC_FORCE_DISABLE (1UL << 3) 22371368af9SWaiman Long # define PR_SPEC_DISABLE_NOEXEC (1UL << 4) 224b617cfc8SThomas Gleixner 225ba830885SKristina Martsenko /* Reset arm64 pointer authentication keys */ 226ba830885SKristina Martsenko #define PR_PAC_RESET_KEYS 54 227ba830885SKristina Martsenko # define PR_PAC_APIAKEY (1UL << 0) 228ba830885SKristina Martsenko # define PR_PAC_APIBKEY (1UL << 1) 229ba830885SKristina Martsenko # define PR_PAC_APDAKEY (1UL << 2) 230ba830885SKristina Martsenko # define PR_PAC_APDBKEY (1UL << 3) 231ba830885SKristina Martsenko # define PR_PAC_APGAKEY (1UL << 4) 232ba830885SKristina Martsenko 23363f0c603SCatalin Marinas /* Tagged user address controls for arm64 */ 23463f0c603SCatalin Marinas #define PR_SET_TAGGED_ADDR_CTRL 55 23563f0c603SCatalin Marinas #define PR_GET_TAGGED_ADDR_CTRL 56 23663f0c603SCatalin Marinas # define PR_TAGGED_ADDR_ENABLE (1UL << 0) 2371c101da8SCatalin Marinas /* MTE tag check fault modes */ 238aedad3e1SPeter Collingbourne # define PR_MTE_TCF_NONE 0UL 239433c38f4SPeter Collingbourne # define PR_MTE_TCF_SYNC (1UL << 1) 240433c38f4SPeter Collingbourne # define PR_MTE_TCF_ASYNC (1UL << 2) 241433c38f4SPeter Collingbourne # define PR_MTE_TCF_MASK (PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC) 242af5ce952SCatalin Marinas /* MTE tag inclusion mask */ 243af5ce952SCatalin Marinas # define PR_MTE_TAG_SHIFT 3 244af5ce952SCatalin Marinas # define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT) 245433c38f4SPeter Collingbourne /* Unused; kept only for source compatibility */ 246433c38f4SPeter Collingbourne # define PR_MTE_TCF_SHIFT 1 24763f0c603SCatalin Marinas 2488d19f1c8SMike Christie /* Control reclaim behavior when allocating memory */ 2498d19f1c8SMike Christie #define PR_SET_IO_FLUSHER 57 2508d19f1c8SMike Christie #define PR_GET_IO_FLUSHER 58 2518d19f1c8SMike Christie 2521446e1dfSGabriel Krisman Bertazi /* Dispatch syscalls to a userspace handler */ 2531446e1dfSGabriel Krisman Bertazi #define PR_SET_SYSCALL_USER_DISPATCH 59 2541446e1dfSGabriel Krisman Bertazi # define PR_SYS_DISPATCH_OFF 0 2551446e1dfSGabriel Krisman Bertazi # define PR_SYS_DISPATCH_ON 1 25636a6c843SGabriel Krisman Bertazi /* The control values for the user space selector when dispatch is enabled */ 25736a6c843SGabriel Krisman Bertazi # define SYSCALL_DISPATCH_FILTER_ALLOW 0 25836a6c843SGabriel Krisman Bertazi # define SYSCALL_DISPATCH_FILTER_BLOCK 1 2591446e1dfSGabriel Krisman Bertazi 26020169862SPeter Collingbourne /* Set/get enabled arm64 pointer authentication keys */ 26120169862SPeter Collingbourne #define PR_PAC_SET_ENABLED_KEYS 60 26220169862SPeter Collingbourne #define PR_PAC_GET_ENABLED_KEYS 61 26320169862SPeter Collingbourne 2647ac592aaSChris Hyser /* Request the scheduler to share a core */ 2657ac592aaSChris Hyser #define PR_SCHED_CORE 62 2667ac592aaSChris Hyser # define PR_SCHED_CORE_GET 0 2677ac592aaSChris Hyser # define PR_SCHED_CORE_CREATE 1 /* create unique core_sched cookie */ 2687ac592aaSChris Hyser # define PR_SCHED_CORE_SHARE_TO 2 /* push core_sched cookie to pid */ 2697ac592aaSChris Hyser # define PR_SCHED_CORE_SHARE_FROM 3 /* pull core_sched cookie to pid */ 2707ac592aaSChris Hyser # define PR_SCHED_CORE_MAX 4 27161bc346cSEugene Syromiatnikov # define PR_SCHED_CORE_SCOPE_THREAD 0 27261bc346cSEugene Syromiatnikov # define PR_SCHED_CORE_SCOPE_THREAD_GROUP 1 27361bc346cSEugene Syromiatnikov # define PR_SCHED_CORE_SCOPE_PROCESS_GROUP 2 2747ac592aaSChris Hyser 2759e4ab6c8SMark Brown /* arm64 Scalable Matrix Extension controls */ 2769e4ab6c8SMark Brown /* Flag values must be in sync with SVE versions */ 2779e4ab6c8SMark Brown #define PR_SME_SET_VL 63 /* set task vector length */ 2789e4ab6c8SMark Brown # define PR_SME_SET_VL_ONEXEC (1 << 18) /* defer effect until exec */ 2799e4ab6c8SMark Brown #define PR_SME_GET_VL 64 /* get task vector length */ 2809e4ab6c8SMark Brown /* Bits common to PR_SME_SET_VL and PR_SME_GET_VL */ 2819e4ab6c8SMark Brown # define PR_SME_VL_LEN_MASK 0xffff 2829e4ab6c8SMark Brown # define PR_SME_VL_INHERIT (1 << 17) /* inherit across exec */ 2839e4ab6c8SMark Brown 284b507808eSJoey Gouly /* Memory deny write / execute */ 285b507808eSJoey Gouly #define PR_SET_MDWE 65 2860da66833SFlorent Revest # define PR_MDWE_REFUSE_EXEC_GAIN (1UL << 0) 287*24e41bf8SFlorent Revest # define PR_MDWE_NO_INHERIT (1UL << 1) 288b507808eSJoey Gouly 289b507808eSJoey Gouly #define PR_GET_MDWE 66 290b507808eSJoey Gouly 2919a10064fSColin Cross #define PR_SET_VMA 0x53564d41 2929a10064fSColin Cross # define PR_SET_VMA_ANON_NAME 0 2939a10064fSColin Cross 294ddc65971SJosh Triplett #define PR_GET_AUXV 0x41555856 295ddc65971SJosh Triplett 296d7597f59SStefan Roesch #define PR_SET_MEMORY_MERGE 67 297d7597f59SStefan Roesch #define PR_GET_MEMORY_MERGE 68 2981fd96a3eSAndy Chiu 2991fd96a3eSAndy Chiu #define PR_RISCV_V_SET_CONTROL 69 3001fd96a3eSAndy Chiu #define PR_RISCV_V_GET_CONTROL 70 3011fd96a3eSAndy Chiu # define PR_RISCV_V_VSTATE_CTRL_DEFAULT 0 3021fd96a3eSAndy Chiu # define PR_RISCV_V_VSTATE_CTRL_OFF 1 3031fd96a3eSAndy Chiu # define PR_RISCV_V_VSTATE_CTRL_ON 2 3041fd96a3eSAndy Chiu # define PR_RISCV_V_VSTATE_CTRL_INHERIT (1 << 4) 3051fd96a3eSAndy Chiu # define PR_RISCV_V_VSTATE_CTRL_CUR_MASK 0x3 3061fd96a3eSAndy Chiu # define PR_RISCV_V_VSTATE_CTRL_NEXT_MASK 0xc 3071fd96a3eSAndy Chiu # define PR_RISCV_V_VSTATE_CTRL_MASK 0x1f 3081fd96a3eSAndy Chiu 309607ca46eSDavid Howells #endif /* _LINUX_PRCTL_H */ 310