prctl.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _LINUX_PRCTL_H
  3. #define _LINUX_PRCTL_H
  4. #include <linux/types.h>
  5. /* Values to pass as first argument to prctl() */
  6. #define PR_SET_PDEATHSIG 1 /* Second arg is a signal */
  7. #define PR_GET_PDEATHSIG 2 /* Second arg is a ptr to return the signal */
  8. /* Get/set current->mm->dumpable */
  9. #define PR_GET_DUMPABLE 3
  10. #define PR_SET_DUMPABLE 4
  11. /* Get/set unaligned access control bits (if meaningful) */
  12. #define PR_GET_UNALIGN 5
  13. #define PR_SET_UNALIGN 6
  14. # define PR_UNALIGN_NOPRINT 1 /* silently fix up unaligned user accesses */
  15. # define PR_UNALIGN_SIGBUS 2 /* generate SIGBUS on unaligned user access */
  16. /* Get/set whether or not to drop capabilities on setuid() away from
  17. * uid 0 (as per security/commoncap.c) */
  18. #define PR_GET_KEEPCAPS 7
  19. #define PR_SET_KEEPCAPS 8
  20. /* Get/set floating-point emulation control bits (if meaningful) */
  21. #define PR_GET_FPEMU 9
  22. #define PR_SET_FPEMU 10
  23. # define PR_FPEMU_NOPRINT 1 /* silently emulate fp operations accesses */
  24. # define PR_FPEMU_SIGFPE 2 /* don't emulate fp operations, send SIGFPE instead */
  25. /* Get/set floating-point exception mode (if meaningful) */
  26. #define PR_GET_FPEXC 11
  27. #define PR_SET_FPEXC 12
  28. # define PR_FP_EXC_SW_ENABLE 0x80 /* Use FPEXC for FP exception enables */
  29. # define PR_FP_EXC_DIV 0x010000 /* floating point divide by zero */
  30. # define PR_FP_EXC_OVF 0x020000 /* floating point overflow */
  31. # define PR_FP_EXC_UND 0x040000 /* floating point underflow */
  32. # define PR_FP_EXC_RES 0x080000 /* floating point inexact result */
  33. # define PR_FP_EXC_INV 0x100000 /* floating point invalid operation */
  34. # define PR_FP_EXC_DISABLED 0 /* FP exceptions disabled */
  35. # define PR_FP_EXC_NONRECOV 1 /* async non-recoverable exc. mode */
  36. # define PR_FP_EXC_ASYNC 2 /* async recoverable exception mode */
  37. # define PR_FP_EXC_PRECISE 3 /* precise exception mode */
  38. /* Get/set whether we use statistical process timing or accurate timestamp
  39. * based process timing */
  40. #define PR_GET_TIMING 13
  41. #define PR_SET_TIMING 14
  42. # define PR_TIMING_STATISTICAL 0 /* Normal, traditional,
  43. statistical process timing */
  44. # define PR_TIMING_TIMESTAMP 1 /* Accurate timestamp based
  45. process timing */
  46. #define PR_SET_NAME 15 /* Set process name */
  47. #define PR_GET_NAME 16 /* Get process name */
  48. /* Get/set process endian */
  49. #define PR_GET_ENDIAN 19
  50. #define PR_SET_ENDIAN 20
  51. # define PR_ENDIAN_BIG 0
  52. # define PR_ENDIAN_LITTLE 1 /* True little endian mode */
  53. # define PR_ENDIAN_PPC_LITTLE 2 /* "PowerPC" pseudo little endian */
  54. /* Get/set process seccomp mode */
  55. #define PR_GET_SECCOMP 21
  56. #define PR_SET_SECCOMP 22
  57. /* Get/set the capability bounding set (as per security/commoncap.c) */
  58. #define PR_CAPBSET_READ 23
  59. #define PR_CAPBSET_DROP 24
  60. /* Get/set the process' ability to use the timestamp counter instruction */
  61. #define PR_GET_TSC 25
  62. #define PR_SET_TSC 26
  63. # define PR_TSC_ENABLE 1 /* allow the use of the timestamp counter */
  64. # define PR_TSC_SIGSEGV 2 /* throw a SIGSEGV instead of reading the TSC */
  65. /* Get/set securebits (as per security/commoncap.c) */
  66. #define PR_GET_SECUREBITS 27
  67. #define PR_SET_SECUREBITS 28
  68. /*
  69. * Get/set the timerslack as used by poll/select/nanosleep
  70. * A value of 0 means "use default"
  71. */
  72. #define PR_SET_TIMERSLACK 29
  73. #define PR_GET_TIMERSLACK 30
  74. #define PR_TASK_PERF_EVENTS_DISABLE 31
  75. #define PR_TASK_PERF_EVENTS_ENABLE 32
  76. /*
  77. * Set early/late kill mode for hwpoison memory corruption.
  78. * This influences when the process gets killed on a memory corruption.
  79. */
  80. #define PR_MCE_KILL 33
  81. # define PR_MCE_KILL_CLEAR 0
  82. # define PR_MCE_KILL_SET 1
  83. # define PR_MCE_KILL_LATE 0
  84. # define PR_MCE_KILL_EARLY 1
  85. # define PR_MCE_KILL_DEFAULT 2
  86. #define PR_MCE_KILL_GET 34
  87. /*
  88. * Tune up process memory map specifics.
  89. */
  90. #define PR_SET_MM 35
  91. # define PR_SET_MM_START_CODE 1
  92. # define PR_SET_MM_END_CODE 2
  93. # define PR_SET_MM_START_DATA 3
  94. # define PR_SET_MM_END_DATA 4
  95. # define PR_SET_MM_START_STACK 5
  96. # define PR_SET_MM_START_BRK 6
  97. # define PR_SET_MM_BRK 7
  98. # define PR_SET_MM_ARG_START 8
  99. # define PR_SET_MM_ARG_END 9
  100. # define PR_SET_MM_ENV_START 10
  101. # define PR_SET_MM_ENV_END 11
  102. # define PR_SET_MM_AUXV 12
  103. # define PR_SET_MM_EXE_FILE 13
  104. # define PR_SET_MM_MAP 14
  105. # define PR_SET_MM_MAP_SIZE 15
  106. /*
  107. * This structure provides new memory descriptor
  108. * map which mostly modifies /proc/pid/stat[m]
  109. * output for a task. This mostly done in a
  110. * sake of checkpoint/restore functionality.
  111. */
  112. struct prctl_mm_map {
  113. __u64 start_code; /* code section bounds */
  114. __u64 end_code;
  115. __u64 start_data; /* data section bounds */
  116. __u64 end_data;
  117. __u64 start_brk; /* heap for brk() syscall */
  118. __u64 brk;
  119. __u64 start_stack; /* stack starts at */
  120. __u64 arg_start; /* command line arguments bounds */
  121. __u64 arg_end;
  122. __u64 env_start; /* environment variables bounds */
  123. __u64 env_end;
  124. __u64 *auxv; /* auxiliary vector */
  125. __u32 auxv_size; /* vector size */
  126. __u32 exe_fd; /* /proc/$pid/exe link file */
  127. };
  128. /*
  129. * Set specific pid that is allowed to ptrace the current task.
  130. * A value of 0 mean "no process".
  131. */
  132. #define PR_SET_PTRACER 0x59616d61
  133. # define PR_SET_PTRACER_ANY ((unsigned long)-1)
  134. #define PR_SET_CHILD_SUBREAPER 36
  135. #define PR_GET_CHILD_SUBREAPER 37
  136. /*
  137. * If no_new_privs is set, then operations that grant new privileges (i.e.
  138. * execve) will either fail or not grant them. This affects suid/sgid,
  139. * file capabilities, and LSMs.
  140. *
  141. * Operations that merely manipulate or drop existing privileges (setresuid,
  142. * capset, etc.) will still work. Drop those privileges if you want them gone.
  143. *
  144. * Changing LSM security domain is considered a new privilege. So, for example,
  145. * asking selinux for a specific new context (e.g. with runcon) will result
  146. * in execve returning -EPERM.
  147. *
  148. * See Documentation/userspace-api/no_new_privs.rst for more details.
  149. */
  150. #define PR_SET_NO_NEW_PRIVS 38
  151. #define PR_GET_NO_NEW_PRIVS 39
  152. #define PR_GET_TID_ADDRESS 40
  153. #define PR_SET_THP_DISABLE 41
  154. #define PR_GET_THP_DISABLE 42
  155. /*
  156. * Tell the kernel to start/stop helping userspace manage bounds tables.
  157. */
  158. #define PR_MPX_ENABLE_MANAGEMENT 43
  159. #define PR_MPX_DISABLE_MANAGEMENT 44
  160. #define PR_SET_FP_MODE 45
  161. #define PR_GET_FP_MODE 46
  162. # define PR_FP_MODE_FR (1 << 0) /* 64b FP registers */
  163. # define PR_FP_MODE_FRE (1 << 1) /* 32b compatibility */
  164. /* Control the ambient capability set */
  165. #define PR_CAP_AMBIENT 47
  166. # define PR_CAP_AMBIENT_IS_SET 1
  167. # define PR_CAP_AMBIENT_RAISE 2
  168. # define PR_CAP_AMBIENT_LOWER 3
  169. # define PR_CAP_AMBIENT_CLEAR_ALL 4
  170. /* arm64 Scalable Vector Extension controls */
  171. /* Flag values must be kept in sync with ptrace NT_ARM_SVE interface */
  172. #define PR_SVE_SET_VL 50 /* set task vector length */
  173. # define PR_SVE_SET_VL_ONEXEC (1 << 18) /* defer effect until exec */
  174. #define PR_SVE_GET_VL 51 /* get task vector length */
  175. /* Bits common to PR_SVE_SET_VL and PR_SVE_GET_VL */
  176. # define PR_SVE_VL_LEN_MASK 0xffff
  177. # define PR_SVE_VL_INHERIT (1 << 17) /* inherit across exec */
  178. /* Per task speculation control */
  179. #define PR_GET_SPECULATION_CTRL 52
  180. #define PR_SET_SPECULATION_CTRL 53
  181. /* Speculation control variants */
  182. # define PR_SPEC_STORE_BYPASS 0
  183. # define PR_SPEC_INDIRECT_BRANCH 1
  184. /* Return and control values for PR_SET/GET_SPECULATION_CTRL */
  185. # define PR_SPEC_NOT_AFFECTED 0
  186. # define PR_SPEC_PRCTL (1UL << 0)
  187. # define PR_SPEC_ENABLE (1UL << 1)
  188. # define PR_SPEC_DISABLE (1UL << 2)
  189. # define PR_SPEC_FORCE_DISABLE (1UL << 3)
  190. #endif /* _LINUX_PRCTL_H */