![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 0002 /* 0003 * This is <linux/capability.h> 0004 * 0005 * Andrew G. Morgan <morgan@kernel.org> 0006 * Alexander Kjeldaas <astor@guardian.no> 0007 * with help from Aleph1, Roland Buresund and Andrew Main. 0008 * 0009 * See here for the libcap library ("POSIX draft" compliance): 0010 * 0011 * ftp://www.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.6/ 0012 */ 0013 0014 #ifndef _UAPI_LINUX_CAPABILITY_H 0015 #define _UAPI_LINUX_CAPABILITY_H 0016 0017 #include <linux/types.h> 0018 0019 /* User-level do most of the mapping between kernel and user 0020 capabilities based on the version tag given by the kernel. The 0021 kernel might be somewhat backwards compatible, but don't bet on 0022 it. */ 0023 0024 /* Note, cap_t, is defined by POSIX (draft) to be an "opaque" pointer to 0025 a set of three capability sets. The transposition of 3*the 0026 following structure to such a composite is better handled in a user 0027 library since the draft standard requires the use of malloc/free 0028 etc.. */ 0029 0030 #define _LINUX_CAPABILITY_VERSION_1 0x19980330 0031 #define _LINUX_CAPABILITY_U32S_1 1 0032 0033 #define _LINUX_CAPABILITY_VERSION_2 0x20071026 /* deprecated - use v3 */ 0034 #define _LINUX_CAPABILITY_U32S_2 2 0035 0036 #define _LINUX_CAPABILITY_VERSION_3 0x20080522 0037 #define _LINUX_CAPABILITY_U32S_3 2 0038 0039 typedef struct __user_cap_header_struct { 0040 __u32 version; 0041 int pid; 0042 } __user *cap_user_header_t; 0043 0044 typedef struct __user_cap_data_struct { 0045 __u32 effective; 0046 __u32 permitted; 0047 __u32 inheritable; 0048 } __user *cap_user_data_t; 0049 0050 0051 #define VFS_CAP_REVISION_MASK 0xFF000000 0052 #define VFS_CAP_REVISION_SHIFT 24 0053 #define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK 0054 #define VFS_CAP_FLAGS_EFFECTIVE 0x000001 0055 0056 #define VFS_CAP_REVISION_1 0x01000000 0057 #define VFS_CAP_U32_1 1 0058 #define XATTR_CAPS_SZ_1 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_1)) 0059 0060 #define VFS_CAP_REVISION_2 0x02000000 0061 #define VFS_CAP_U32_2 2 0062 #define XATTR_CAPS_SZ_2 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_2)) 0063 0064 #define VFS_CAP_REVISION_3 0x03000000 0065 #define VFS_CAP_U32_3 2 0066 #define XATTR_CAPS_SZ_3 (sizeof(__le32)*(2 + 2*VFS_CAP_U32_3)) 0067 0068 #define XATTR_CAPS_SZ XATTR_CAPS_SZ_3 0069 #define VFS_CAP_U32 VFS_CAP_U32_3 0070 #define VFS_CAP_REVISION VFS_CAP_REVISION_3 0071 0072 struct vfs_cap_data { 0073 __le32 magic_etc; /* Little endian */ 0074 struct { 0075 __le32 permitted; /* Little endian */ 0076 __le32 inheritable; /* Little endian */ 0077 } data[VFS_CAP_U32]; 0078 }; 0079 0080 /* 0081 * same as vfs_cap_data but with a rootid at the end 0082 */ 0083 struct vfs_ns_cap_data { 0084 __le32 magic_etc; 0085 struct { 0086 __le32 permitted; /* Little endian */ 0087 __le32 inheritable; /* Little endian */ 0088 } data[VFS_CAP_U32]; 0089 __le32 rootid; 0090 }; 0091 0092 #ifndef __KERNEL__ 0093 0094 /* 0095 * Backwardly compatible definition for source code - trapped in a 0096 * 32-bit world. If you find you need this, please consider using 0097 * libcap to untrap yourself... 0098 */ 0099 #define _LINUX_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_1 0100 #define _LINUX_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_1 0101 0102 #endif 0103 0104 0105 /** 0106 ** POSIX-draft defined capabilities. 0107 **/ 0108 0109 /* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this 0110 overrides the restriction of changing file ownership and group 0111 ownership. */ 0112 0113 #define CAP_CHOWN 0 0114 0115 /* Override all DAC access, including ACL execute access if 0116 [_POSIX_ACL] is defined. Excluding DAC access covered by 0117 CAP_LINUX_IMMUTABLE. */ 0118 0119 #define CAP_DAC_OVERRIDE 1 0120 0121 /* Overrides all DAC restrictions regarding read and search on files 0122 and directories, including ACL restrictions if [_POSIX_ACL] is 0123 defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */ 0124 0125 #define CAP_DAC_READ_SEARCH 2 0126 0127 /* Overrides all restrictions about allowed operations on files, where 0128 file owner ID must be equal to the user ID, except where CAP_FSETID 0129 is applicable. It doesn't override MAC and DAC restrictions. */ 0130 0131 #define CAP_FOWNER 3 0132 0133 /* Overrides the following restrictions that the effective user ID 0134 shall match the file owner ID when setting the S_ISUID and S_ISGID 0135 bits on that file; that the effective group ID (or one of the 0136 supplementary group IDs) shall match the file owner ID when setting 0137 the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are 0138 cleared on successful return from chown(2) (not implemented). */ 0139 0140 #define CAP_FSETID 4 0141 0142 /* Overrides the restriction that the real or effective user ID of a 0143 process sending a signal must match the real or effective user ID 0144 of the process receiving the signal. */ 0145 0146 #define CAP_KILL 5 0147 0148 /* Allows setgid(2) manipulation */ 0149 /* Allows setgroups(2) */ 0150 /* Allows forged gids on socket credentials passing. */ 0151 0152 #define CAP_SETGID 6 0153 0154 /* Allows set*uid(2) manipulation (including fsuid). */ 0155 /* Allows forged pids on socket credentials passing. */ 0156 0157 #define CAP_SETUID 7 0158 0159 0160 /** 0161 ** Linux-specific capabilities 0162 **/ 0163 0164 /* Without VFS support for capabilities: 0165 * Transfer any capability in your permitted set to any pid, 0166 * remove any capability in your permitted set from any pid 0167 * With VFS support for capabilities (neither of above, but) 0168 * Add any capability from current's capability bounding set 0169 * to the current process' inheritable set 0170 * Allow taking bits out of capability bounding set 0171 * Allow modification of the securebits for a process 0172 */ 0173 0174 #define CAP_SETPCAP 8 0175 0176 /* Allow modification of S_IMMUTABLE and S_APPEND file attributes */ 0177 0178 #define CAP_LINUX_IMMUTABLE 9 0179 0180 /* Allows binding to TCP/UDP sockets below 1024 */ 0181 /* Allows binding to ATM VCIs below 32 */ 0182 0183 #define CAP_NET_BIND_SERVICE 10 0184 0185 /* Allow broadcasting, listen to multicast */ 0186 0187 #define CAP_NET_BROADCAST 11 0188 0189 /* Allow interface configuration */ 0190 /* Allow administration of IP firewall, masquerading and accounting */ 0191 /* Allow setting debug option on sockets */ 0192 /* Allow modification of routing tables */ 0193 /* Allow setting arbitrary process / process group ownership on 0194 sockets */ 0195 /* Allow binding to any address for transparent proxying (also via NET_RAW) */ 0196 /* Allow setting TOS (type of service) */ 0197 /* Allow setting promiscuous mode */ 0198 /* Allow clearing driver statistics */ 0199 /* Allow multicasting */ 0200 /* Allow read/write of device-specific registers */ 0201 /* Allow activation of ATM control sockets */ 0202 0203 #define CAP_NET_ADMIN 12 0204 0205 /* Allow use of RAW sockets */ 0206 /* Allow use of PACKET sockets */ 0207 /* Allow binding to any address for transparent proxying (also via NET_ADMIN) */ 0208 0209 #define CAP_NET_RAW 13 0210 0211 /* Allow locking of shared memory segments */ 0212 /* Allow mlock and mlockall (which doesn't really have anything to do 0213 with IPC) */ 0214 0215 #define CAP_IPC_LOCK 14 0216 0217 /* Override IPC ownership checks */ 0218 0219 #define CAP_IPC_OWNER 15 0220 0221 /* Insert and remove kernel modules - modify kernel without limit */ 0222 #define CAP_SYS_MODULE 16 0223 0224 /* Allow ioperm/iopl access */ 0225 /* Allow sending USB messages to any device via /dev/bus/usb */ 0226 0227 #define CAP_SYS_RAWIO 17 0228 0229 /* Allow use of chroot() */ 0230 0231 #define CAP_SYS_CHROOT 18 0232 0233 /* Allow ptrace() of any process */ 0234 0235 #define CAP_SYS_PTRACE 19 0236 0237 /* Allow configuration of process accounting */ 0238 0239 #define CAP_SYS_PACCT 20 0240 0241 /* Allow configuration of the secure attention key */ 0242 /* Allow administration of the random device */ 0243 /* Allow examination and configuration of disk quotas */ 0244 /* Allow setting the domainname */ 0245 /* Allow setting the hostname */ 0246 /* Allow mount() and umount(), setting up new smb connection */ 0247 /* Allow some autofs root ioctls */ 0248 /* Allow nfsservctl */ 0249 /* Allow VM86_REQUEST_IRQ */ 0250 /* Allow to read/write pci config on alpha */ 0251 /* Allow irix_prctl on mips (setstacksize) */ 0252 /* Allow flushing all cache on m68k (sys_cacheflush) */ 0253 /* Allow removing semaphores */ 0254 /* Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores 0255 and shared memory */ 0256 /* Allow locking/unlocking of shared memory segment */ 0257 /* Allow turning swap on/off */ 0258 /* Allow forged pids on socket credentials passing */ 0259 /* Allow setting readahead and flushing buffers on block devices */ 0260 /* Allow setting geometry in floppy driver */ 0261 /* Allow turning DMA on/off in xd driver */ 0262 /* Allow administration of md devices (mostly the above, but some 0263 extra ioctls) */ 0264 /* Allow tuning the ide driver */ 0265 /* Allow access to the nvram device */ 0266 /* Allow administration of apm_bios, serial and bttv (TV) device */ 0267 /* Allow manufacturer commands in isdn CAPI support driver */ 0268 /* Allow reading non-standardized portions of pci configuration space */ 0269 /* Allow DDI debug ioctl on sbpcd driver */ 0270 /* Allow setting up serial ports */ 0271 /* Allow sending raw qic-117 commands */ 0272 /* Allow enabling/disabling tagged queuing on SCSI controllers and sending 0273 arbitrary SCSI commands */ 0274 /* Allow setting encryption key on loopback filesystem */ 0275 /* Allow setting zone reclaim policy */ 0276 /* Allow everything under CAP_BPF and CAP_PERFMON for backward compatibility */ 0277 0278 #define CAP_SYS_ADMIN 21 0279 0280 /* Allow use of reboot() */ 0281 0282 #define CAP_SYS_BOOT 22 0283 0284 /* Allow raising priority and setting priority on other (different 0285 UID) processes */ 0286 /* Allow use of FIFO and round-robin (realtime) scheduling on own 0287 processes and setting the scheduling algorithm used by another 0288 process. */ 0289 /* Allow setting cpu affinity on other processes */ 0290 /* Allow setting realtime ioprio class */ 0291 /* Allow setting ioprio class on other processes */ 0292 0293 #define CAP_SYS_NICE 23 0294 0295 /* Override resource limits. Set resource limits. */ 0296 /* Override quota limits. */ 0297 /* Override reserved space on ext2 filesystem */ 0298 /* Modify data journaling mode on ext3 filesystem (uses journaling 0299 resources) */ 0300 /* NOTE: ext2 honors fsuid when checking for resource overrides, so 0301 you can override using fsuid too */ 0302 /* Override size restrictions on IPC message queues */ 0303 /* Allow more than 64hz interrupts from the real-time clock */ 0304 /* Override max number of consoles on console allocation */ 0305 /* Override max number of keymaps */ 0306 /* Control memory reclaim behavior */ 0307 0308 #define CAP_SYS_RESOURCE 24 0309 0310 /* Allow manipulation of system clock */ 0311 /* Allow irix_stime on mips */ 0312 /* Allow setting the real-time clock */ 0313 0314 #define CAP_SYS_TIME 25 0315 0316 /* Allow configuration of tty devices */ 0317 /* Allow vhangup() of tty */ 0318 0319 #define CAP_SYS_TTY_CONFIG 26 0320 0321 /* Allow the privileged aspects of mknod() */ 0322 0323 #define CAP_MKNOD 27 0324 0325 /* Allow taking of leases on files */ 0326 0327 #define CAP_LEASE 28 0328 0329 /* Allow writing the audit log via unicast netlink socket */ 0330 0331 #define CAP_AUDIT_WRITE 29 0332 0333 /* Allow configuration of audit via unicast netlink socket */ 0334 0335 #define CAP_AUDIT_CONTROL 30 0336 0337 /* Set or remove capabilities on files. 0338 Map uid=0 into a child user namespace. */ 0339 0340 #define CAP_SETFCAP 31 0341 0342 /* Override MAC access. 0343 The base kernel enforces no MAC policy. 0344 An LSM may enforce a MAC policy, and if it does and it chooses 0345 to implement capability based overrides of that policy, this is 0346 the capability it should use to do so. */ 0347 0348 #define CAP_MAC_OVERRIDE 32 0349 0350 /* Allow MAC configuration or state changes. 0351 The base kernel requires no MAC configuration. 0352 An LSM may enforce a MAC policy, and if it does and it chooses 0353 to implement capability based checks on modifications to that 0354 policy or the data required to maintain it, this is the 0355 capability it should use to do so. */ 0356 0357 #define CAP_MAC_ADMIN 33 0358 0359 /* Allow configuring the kernel's syslog (printk behaviour) */ 0360 0361 #define CAP_SYSLOG 34 0362 0363 /* Allow triggering something that will wake the system */ 0364 0365 #define CAP_WAKE_ALARM 35 0366 0367 /* Allow preventing system suspends */ 0368 0369 #define CAP_BLOCK_SUSPEND 36 0370 0371 /* Allow reading the audit log via multicast netlink socket */ 0372 0373 #define CAP_AUDIT_READ 37 0374 0375 /* 0376 * Allow system performance and observability privileged operations 0377 * using perf_events, i915_perf and other kernel subsystems 0378 */ 0379 0380 #define CAP_PERFMON 38 0381 0382 /* 0383 * CAP_BPF allows the following BPF operations: 0384 * - Creating all types of BPF maps 0385 * - Advanced verifier features 0386 * - Indirect variable access 0387 * - Bounded loops 0388 * - BPF to BPF function calls 0389 * - Scalar precision tracking 0390 * - Larger complexity limits 0391 * - Dead code elimination 0392 * - And potentially other features 0393 * - Loading BPF Type Format (BTF) data 0394 * - Retrieve xlated and JITed code of BPF programs 0395 * - Use bpf_spin_lock() helper 0396 * 0397 * CAP_PERFMON relaxes the verifier checks further: 0398 * - BPF progs can use of pointer-to-integer conversions 0399 * - speculation attack hardening measures are bypassed 0400 * - bpf_probe_read to read arbitrary kernel memory is allowed 0401 * - bpf_trace_printk to print kernel memory is allowed 0402 * 0403 * CAP_SYS_ADMIN is required to use bpf_probe_write_user. 0404 * 0405 * CAP_SYS_ADMIN is required to iterate system wide loaded 0406 * programs, maps, links, BTFs and convert their IDs to file descriptors. 0407 * 0408 * CAP_PERFMON and CAP_BPF are required to load tracing programs. 0409 * CAP_NET_ADMIN and CAP_BPF are required to load networking programs. 0410 */ 0411 #define CAP_BPF 39 0412 0413 0414 /* Allow checkpoint/restore related operations */ 0415 /* Allow PID selection during clone3() */ 0416 /* Allow writing to ns_last_pid */ 0417 0418 #define CAP_CHECKPOINT_RESTORE 40 0419 0420 #define CAP_LAST_CAP CAP_CHECKPOINT_RESTORE 0421 0422 #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP) 0423 0424 /* 0425 * Bit location of each capability (used by user-space library and kernel) 0426 */ 0427 0428 #define CAP_TO_INDEX(x) ((x) >> 5) /* 1 << 5 == bits in __u32 */ 0429 #define CAP_TO_MASK(x) (1 << ((x) & 31)) /* mask for indexed __u32 */ 0430 0431 0432 #endif /* _UAPI_LINUX_CAPABILITY_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |