prctl.h 6.9 KB

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