1 /* 2 * This is <linux/capability.h> 3 * 4 * Andrew G. Morgan <morgan (at) kernel.org> 5 * Alexander Kjeldaas <astor (at) guardian.no> 6 * with help from Aleph1, Roland Buresund and Andrew Main. 7 * 8 * See here for the libcap library ("POSIX draft" compliance): 9 * 10 * ftp://linux.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.6/ 11 */ 12 13 #ifndef _LINUX_CAPABILITY_H 14 #define _LINUX_CAPABILITY_H 15 16 #include <linux/types.h> 17 18 struct task_struct; 19 20 /* User-level do most of the mapping between kernel and user 21 capabilities based on the version tag given by the kernel. The 22 kernel might be somewhat backwards compatible, but don't bet on 23 it. */ 24 25 /* XXX - Note, cap_t, is defined by POSIX to be an "opaque" pointer to 26 a set of three capability sets. The transposition of 3*the 27 following structure to such a composite is better handled in a user 28 library since the draft standard requires the use of malloc/free 29 etc.. */ 30 31 #define _LINUX_CAPABILITY_VERSION 0x19980330 32 33 typedef struct __user_cap_header_struct { 34 __u32 version; 35 int pid; 36 } *cap_user_header_t; 37 38 typedef struct __user_cap_data_struct { 39 __u32 effective; 40 __u32 permitted; 41 __u32 inheritable; 42 } *cap_user_data_t; 43 44 #define XATTR_CAPS_SUFFIX "capability" 45 #define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX 46 47 #define XATTR_CAPS_SZ (3*sizeof(__le32)) 48 #define VFS_CAP_REVISION_MASK 0xFF000000 49 #define VFS_CAP_REVISION_1 0x01000000 50 51 #define VFS_CAP_REVISION VFS_CAP_REVISION_1 52 53 #define VFS_CAP_FLAGS_MASK ~VFS_CAP_REVISION_MASK 54 #define VFS_CAP_FLAGS_EFFECTIVE 0x000001 55 56 struct vfs_cap_data { 57 __u32 magic_etc; /* Little endian */ 58 __u32 permitted; /* Little endian */ 59 __u32 inheritable; /* Little endian */ 60 }; 61 62 63 64 /** 65 ** POSIX-draft defined capabilities. 66 **/ 67 68 /* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this 69 overrides the restriction of changing file ownership and group 70 ownership. */ 71 72 #define CAP_CHOWN 0 73 74 /* Override all DAC access, including ACL execute access if 75 [_POSIX_ACL] is defined. Excluding DAC access covered by 76 CAP_LINUX_IMMUTABLE. */ 77 78 #define CAP_DAC_OVERRIDE 1 79 80 /* Overrides all DAC restrictions regarding read and search on files 81 and directories, including ACL restrictions if [_POSIX_ACL] is 82 defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */ 83 84 #define CAP_DAC_READ_SEARCH 2 85 86 /* Overrides all restrictions about allowed operations on files, where 87 file owner ID must be equal to the user ID, except where CAP_FSETID 88 is applicable. It doesn't override MAC and DAC restrictions. */ 89 90 #define CAP_FOWNER 3 91 92 /* Overrides the following restrictions that the effective user ID 93 shall match the file owner ID when setting the S_ISUID and S_ISGID 94 bits on that file; that the effective group ID (or one of the 95 supplementary group IDs) shall match the file owner ID when setting 96 the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are 97 cleared on successful return from chown(2) (not implemented). */ 98 99 #define CAP_FSETID 4 100 101 /* Used to decide between falling back on the old suser() or fsuser(). */ 102 103 #define CAP_FS_MASK 0x1f 104 105 /* Overrides the restriction that the real or effective user ID of a 106 process sending a signal must match the real or effective user ID 107 of the process receiving the signal. */ 108 109 #define CAP_KILL 5 110 111 /* Allows setgid(2) manipulation */ 112 /* Allows setgroups(2) */ 113 /* Allows forged gids on socket credentials passing. */ 114 115 #define CAP_SETGID 6 116 117 /* Allows set*uid(2) manipulation (including fsuid). */ 118 /* Allows forged pids on socket credentials passing. */ 119 120 #define CAP_SETUID 7 121 122 123 /** 124 ** Linux-specific capabilities 125 **/ 126 127 /* Transfer any capability in your permitted set to any pid, 128 remove any capability in your permitted set from any pid */ 129 130 #define CAP_SETPCAP 8 131 132 /* Allow modification of S_IMMUTABLE and S_APPEND file attributes */ 133 134 #define CAP_LINUX_IMMUTABLE 9 135 136 /* Allows binding to TCP/UDP sockets below 1024 */ 137 /* Allows binding to ATM VCIs below 32 */ 138 139 #define CAP_NET_BIND_SERVICE 10 140 141 /* Allow broadcasting, listen to multicast */ 142 143 #define CAP_NET_BROADCAST 11 144 145 /* Allow interface configuration */ 146 /* Allow administration of IP firewall, masquerading and accounting */ 147 /* Allow setting debug option on sockets */ 148 /* Allow modification of routing tables */ 149 /* Allow setting arbitrary process / process group ownership on 150 sockets */ 151 /* Allow binding to any address for transparent proxying */ 152 /* Allow setting TOS (type of service) */ 153 /* Allow setting promiscuous mode */ 154 /* Allow clearing driver statistics */ 155 /* Allow multicasting */ 156 /* Allow read/write of device-specific registers */ 157 /* Allow activation of ATM control sockets */ 158 159 #define CAP_NET_ADMIN 12 160 161 /* Allow use of RAW sockets */ 162 /* Allow use of PACKET sockets */ 163 164 #define CAP_NET_RAW 13 165 166 /* Allow locking of shared memory segments */ 167 /* Allow mlock and mlockall (which doesn't really have anything to do 168 with IPC) */ 169 170 #define CAP_IPC_LOCK 14 171 172 /* Override IPC ownership checks */ 173 174 #define CAP_IPC_OWNER 15 175 176 /* Insert and remove kernel modules - modify kernel without limit */ 177 /* Modify cap_bset */ 178 #define CAP_SYS_MODULE 16 179 180 /* Allow ioperm/iopl access */ 181 /* Allow sending USB messages to any device via /proc/bus/usb */ 182 183 #define CAP_SYS_RAWIO 17 184 185 /* Allow use of chroot() */ 186 187 #define CAP_SYS_CHROOT 18 188 189 /* Allow ptrace() of any process */ 190 191 #define CAP_SYS_PTRACE 19 192 193 /* Allow configuration of process accounting */ 194 195 #define CAP_SYS_PACCT 20 196 197 /* Allow configuration of the secure attention key */ 198 /* Allow administration of the random device */ 199 /* Allow examination and configuration of disk quotas */ 200 /* Allow configuring the kernel's syslog (printk behaviour) */ 201 /* Allow setting the domainname */ 202 /* Allow setting the hostname */ 203 /* Allow calling bdflush() */ 204 /* Allow mount() and umount(), setting up new smb connection */ 205 /* Allow some autofs root ioctls */ 206 /* Allow nfsservctl */ 207 /* Allow VM86_REQUEST_IRQ */ 208 /* Allow to read/write pci config on alpha */ 209 /* Allow irix_prctl on mips (setstacksize) */ 210 /* Allow flushing all cache on m68k (sys_cacheflush) */ 211 /* Allow removing semaphores */ 212 /* Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores 213 and shared memory */ 214 /* Allow locking/unlocking of shared memory segment */ 215 /* Allow turning swap on/off */ 216 /* Allow forged pids on socket credentials passing */ 217 /* Allow setting readahead and flushing buffers on block devices */ 218 /* Allow setting geometry in floppy driver */ 219 /* Allow turning DMA on/off in xd driver */ 220 /* Allow administration of md devices (mostly the above, but some 221 extra ioctls) */ 222 /* Allow tuning the ide driver */ 223 /* Allow access to the nvram device */ 224 /* Allow administration of apm_bios, serial and bttv (TV) device */ 225 /* Allow manufacturer commands in isdn CAPI support driver */ 226 /* Allow reading non-standardized portions of pci configuration space */ 227 /* Allow DDI debug ioctl on sbpcd driver */ 228 /* Allow setting up serial ports */ 229 /* Allow sending raw qic-117 commands */ 230 /* Allow enabling/disabling tagged queuing on SCSI controllers and sending 231 arbitrary SCSI commands */ 232 /* Allow setting encryption key on loopback filesystem */ 233 /* Allow setting zone reclaim policy */ 234 235 #define CAP_SYS_ADMIN 21 236 237 /* Allow use of reboot() */ 238 239 #define CAP_SYS_BOOT 22 240 241 /* Allow raising priority and setting priority on other (different 242 UID) processes */ 243 /* Allow use of FIFO and round-robin (realtime) scheduling on own 244 processes and setting the scheduling algorithm used by another 245 process. */ 246 /* Allow setting cpu affinity on other processes */ 247 248 #define CAP_SYS_NICE 23 249 250 /* Override resource limits. Set resource limits. */ 251 /* Override quota limits. */ 252 /* Override reserved space on ext2 filesystem */ 253 /* Modify data journaling mode on ext3 filesystem (uses journaling 254 resources) */ 255 /* NOTE: ext2 honors fsuid when checking for resource overrides, so 256 you can override using fsuid too */ 257 /* Override size restrictions on IPC message queues */ 258 /* Allow more than 64hz interrupts from the real-time clock */ 259 /* Override max number of consoles on console allocation */ 260 /* Override max number of keymaps */ 261 262 #define CAP_SYS_RESOURCE 24 263 264 /* Allow manipulation of system clock */ 265 /* Allow irix_stime on mips */ 266 /* Allow setting the real-time clock */ 267 268 #define CAP_SYS_TIME 25 269 270 /* Allow configuration of tty devices */ 271 /* Allow vhangup() of tty */ 272 273 #define CAP_SYS_TTY_CONFIG 26 274 275 /* Allow the privileged aspects of mknod() */ 276 277 #define CAP_MKNOD 27 278 279 /* Allow taking of leases on files */ 280 281 #define CAP_LEASE 28 282 283 #define CAP_AUDIT_WRITE 29 284 285 #define CAP_AUDIT_CONTROL 30 286 287 #define CAP_SETFCAP 31 288 289 290 #endif /* !_LINUX_CAPABILITY_H */ 291