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