File: /Users/paulross/dev/linux/linux-3.13/include/uapi/linux/capability.h

Green shading in the line number column means the source is part of the translation unit, red means it is conditionally excluded. Highlighted line numbers link to the translation unit page. Highlighted macros link to the macro page.

       1: /*
       2:  * This is <linux/capability.h>
       3:  *
       4:  * Andrew G. Morgan <morgan@kernel.org>
       5:  * Alexander Kjeldaas <astor@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://www.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.6/
      11:  */
      12: 
      13: #ifndef _UAPI_LINUX_CAPABILITY_H
      14: #define _UAPI_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: /* Note, cap_t, is defined by POSIX (draft) 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_1  0x19980330
      32: #define _LINUX_CAPABILITY_U32S_1     1
      33: 
      34: #define _LINUX_CAPABILITY_VERSION_2  0x20071026  /* deprecated - use v3 */
      35: #define _LINUX_CAPABILITY_U32S_2     2
      36: 
      37: #define _LINUX_CAPABILITY_VERSION_3  0x20080522
      38: #define _LINUX_CAPABILITY_U32S_3     2
      39: 
      40: typedef struct __user_cap_header_struct {
      41:     __u32 version;
      42:     int pid;
      43: } __user *cap_user_header_t;
      44: 
      45: typedef struct __user_cap_data_struct {
      46:         __u32 effective;
      47:         __u32 permitted;
      48:         __u32 inheritable;
      49: } __user *cap_user_data_t;
      50: 
      51: 
      52: #define VFS_CAP_REVISION_MASK    0xFF000000
      53: #define VFS_CAP_REVISION_SHIFT    24
      54: #define VFS_CAP_FLAGS_MASK    ~VFS_CAP_REVISION_MASK
      55: #define VFS_CAP_FLAGS_EFFECTIVE    0x000001
      56: 
      57: #define VFS_CAP_REVISION_1    0x01000000
      58: #define VFS_CAP_U32_1           1
      59: #define XATTR_CAPS_SZ_1         (sizeof(__le32)*(1 + 2*VFS_CAP_U32_1))
      60: 
      61: #define VFS_CAP_REVISION_2    0x02000000
      62: #define VFS_CAP_U32_2           2
      63: #define XATTR_CAPS_SZ_2         (sizeof(__le32)*(1 + 2*VFS_CAP_U32_2))
      64: 
      65: #define XATTR_CAPS_SZ           XATTR_CAPS_SZ_2
      66: #define VFS_CAP_U32             VFS_CAP_U32_2
      67: #define VFS_CAP_REVISION    VFS_CAP_REVISION_2
      68: 
      69: struct vfs_cap_data {
      70:     __le32 magic_etc;            /* Little endian */
      71:     struct {
      72:         __le32 permitted;    /* Little endian */
      73:         __le32 inheritable;  /* Little endian */
      74:     } data[VFS_CAP_U32];
      75: };
      76: 
      77: #ifndef __KERNEL__
      78: 
      79: /*
      80:  * Backwardly compatible definition for source code - trapped in a
      81:  * 32-bit world. If you find you need this, please consider using
      82:  * libcap to untrap yourself...
      83:  */
      84: #define _LINUX_CAPABILITY_VERSION  _LINUX_CAPABILITY_VERSION_1
      85: #define _LINUX_CAPABILITY_U32S     _LINUX_CAPABILITY_U32S_1
      86: 
      87: #endif
      88: 
      89: 
      90: /**
      91:  ** POSIX-draft defined capabilities.
      92:  **/
      93: 
      94: /* In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this
      95:    overrides the restriction of changing file ownership and group
      96:    ownership. */
      97: 
      98: #define CAP_CHOWN            0
      99: 
     100: /* Override all DAC access, including ACL execute access if
     101:    [_POSIX_ACL] is defined. Excluding DAC access covered by
     102:    CAP_LINUX_IMMUTABLE. */
     103: 
     104: #define CAP_DAC_OVERRIDE     1
     105: 
     106: /* Overrides all DAC restrictions regarding read and search on files
     107:    and directories, including ACL restrictions if [_POSIX_ACL] is
     108:    defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. */
     109: 
     110: #define CAP_DAC_READ_SEARCH  2
     111: 
     112: /* Overrides all restrictions about allowed operations on files, where
     113:    file owner ID must be equal to the user ID, except where CAP_FSETID
     114:    is applicable. It doesn't override MAC and DAC restrictions. */
     115: 
     116: #define CAP_FOWNER           3
     117: 
     118: /* Overrides the following restrictions that the effective user ID
     119:    shall match the file owner ID when setting the S_ISUID and S_ISGID
     120:    bits on that file; that the effective group ID (or one of the
     121:    supplementary group IDs) shall match the file owner ID when setting
     122:    the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are
     123:    cleared on successful return from chown(2) (not implemented). */
     124: 
     125: #define CAP_FSETID           4
     126: 
     127: /* Overrides the restriction that the real or effective user ID of a
     128:    process sending a signal must match the real or effective user ID
     129:    of the process receiving the signal. */
     130: 
     131: #define CAP_KILL             5
     132: 
     133: /* Allows setgid(2) manipulation */
     134: /* Allows setgroups(2) */
     135: /* Allows forged gids on socket credentials passing. */
     136: 
     137: #define CAP_SETGID           6
     138: 
     139: /* Allows set*uid(2) manipulation (including fsuid). */
     140: /* Allows forged pids on socket credentials passing. */
     141: 
     142: #define CAP_SETUID           7
     143: 
     144: 
     145: /**
     146:  ** Linux-specific capabilities
     147:  **/
     148: 
     149: /* Without VFS support for capabilities:
     150:  *   Transfer any capability in your permitted set to any pid,
     151:  *   remove any capability in your permitted set from any pid
     152:  * With VFS support for capabilities (neither of above, but)
     153:  *   Add any capability from current's capability bounding set
     154:  *       to the current process' inheritable set
     155:  *   Allow taking bits out of capability bounding set
     156:  *   Allow modification of the securebits for a process
     157:  */
     158: 
     159: #define CAP_SETPCAP          8
     160: 
     161: /* Allow modification of S_IMMUTABLE and S_APPEND file attributes */
     162: 
     163: #define CAP_LINUX_IMMUTABLE  9
     164: 
     165: /* Allows binding to TCP/UDP sockets below 1024 */
     166: /* Allows binding to ATM VCIs below 32 */
     167: 
     168: #define CAP_NET_BIND_SERVICE 10
     169: 
     170: /* Allow broadcasting, listen to multicast */
     171: 
     172: #define CAP_NET_BROADCAST    11
     173: 
     174: /* Allow interface configuration */
     175: /* Allow administration of IP firewall, masquerading and accounting */
     176: /* Allow setting debug option on sockets */
     177: /* Allow modification of routing tables */
     178: /* Allow setting arbitrary process / process group ownership on
     179:    sockets */
     180: /* Allow binding to any address for transparent proxying (also via NET_RAW) */
     181: /* Allow setting TOS (type of service) */
     182: /* Allow setting promiscuous mode */
     183: /* Allow clearing driver statistics */
     184: /* Allow multicasting */
     185: /* Allow read/write of device-specific registers */
     186: /* Allow activation of ATM control sockets */
     187: 
     188: #define CAP_NET_ADMIN        12
     189: 
     190: /* Allow use of RAW sockets */
     191: /* Allow use of PACKET sockets */
     192: /* Allow binding to any address for transparent proxying (also via NET_ADMIN) */
     193: 
     194: #define CAP_NET_RAW          13
     195: 
     196: /* Allow locking of shared memory segments */
     197: /* Allow mlock and mlockall (which doesn't really have anything to do
     198:    with IPC) */
     199: 
     200: #define CAP_IPC_LOCK         14
     201: 
     202: /* Override IPC ownership checks */
     203: 
     204: #define CAP_IPC_OWNER        15
     205: 
     206: /* Insert and remove kernel modules - modify kernel without limit */
     207: #define CAP_SYS_MODULE       16
     208: 
     209: /* Allow ioperm/iopl access */
     210: /* Allow sending USB messages to any device via /proc/bus/usb */
     211: 
     212: #define CAP_SYS_RAWIO        17
     213: 
     214: /* Allow use of chroot() */
     215: 
     216: #define CAP_SYS_CHROOT       18
     217: 
     218: /* Allow ptrace() of any process */
     219: 
     220: #define CAP_SYS_PTRACE       19
     221: 
     222: /* Allow configuration of process accounting */
     223: 
     224: #define CAP_SYS_PACCT        20
     225: 
     226: /* Allow configuration of the secure attention key */
     227: /* Allow administration of the random device */
     228: /* Allow examination and configuration of disk quotas */
     229: /* Allow setting the domainname */
     230: /* Allow setting the hostname */
     231: /* Allow calling bdflush() */
     232: /* Allow mount() and umount(), setting up new smb connection */
     233: /* Allow some autofs root ioctls */
     234: /* Allow nfsservctl */
     235: /* Allow VM86_REQUEST_IRQ */
     236: /* Allow to read/write pci config on alpha */
     237: /* Allow irix_prctl on mips (setstacksize) */
     238: /* Allow flushing all cache on m68k (sys_cacheflush) */
     239: /* Allow removing semaphores */
     240: /* Used instead of CAP_CHOWN to "chown" IPC message queues, semaphores
     241:    and shared memory */
     242: /* Allow locking/unlocking of shared memory segment */
     243: /* Allow turning swap on/off */
     244: /* Allow forged pids on socket credentials passing */
     245: /* Allow setting readahead and flushing buffers on block devices */
     246: /* Allow setting geometry in floppy driver */
     247: /* Allow turning DMA on/off in xd driver */
     248: /* Allow administration of md devices (mostly the above, but some
     249:    extra ioctls) */
     250: /* Allow tuning the ide driver */
     251: /* Allow access to the nvram device */
     252: /* Allow administration of apm_bios, serial and bttv (TV) device */
     253: /* Allow manufacturer commands in isdn CAPI support driver */
     254: /* Allow reading non-standardized portions of pci configuration space */
     255: /* Allow DDI debug ioctl on sbpcd driver */
     256: /* Allow setting up serial ports */
     257: /* Allow sending raw qic-117 commands */
     258: /* Allow enabling/disabling tagged queuing on SCSI controllers and sending
     259:    arbitrary SCSI commands */
     260: /* Allow setting encryption key on loopback filesystem */
     261: /* Allow setting zone reclaim policy */
     262: 
     263: #define CAP_SYS_ADMIN        21
     264: 
     265: /* Allow use of reboot() */
     266: 
     267: #define CAP_SYS_BOOT         22
     268: 
     269: /* Allow raising priority and setting priority on other (different
     270:    UID) processes */
     271: /* Allow use of FIFO and round-robin (realtime) scheduling on own
     272:    processes and setting the scheduling algorithm used by another
     273:    process. */
     274: /* Allow setting cpu affinity on other processes */
     275: 
     276: #define CAP_SYS_NICE         23
     277: 
     278: /* Override resource limits. Set resource limits. */
     279: /* Override quota limits. */
     280: /* Override reserved space on ext2 filesystem */
     281: /* Modify data journaling mode on ext3 filesystem (uses journaling
     282:    resources) */
     283: /* NOTE: ext2 honors fsuid when checking for resource overrides, so
     284:    you can override using fsuid too */
     285: /* Override size restrictions on IPC message queues */
     286: /* Allow more than 64hz interrupts from the real-time clock */
     287: /* Override max number of consoles on console allocation */
     288: /* Override max number of keymaps */
     289: 
     290: #define CAP_SYS_RESOURCE     24
     291: 
     292: /* Allow manipulation of system clock */
     293: /* Allow irix_stime on mips */
     294: /* Allow setting the real-time clock */
     295: 
     296: #define CAP_SYS_TIME         25
     297: 
     298: /* Allow configuration of tty devices */
     299: /* Allow vhangup() of tty */
     300: 
     301: #define CAP_SYS_TTY_CONFIG   26
     302: 
     303: /* Allow the privileged aspects of mknod() */
     304: 
     305: #define CAP_MKNOD            27
     306: 
     307: /* Allow taking of leases on files */
     308: 
     309: #define CAP_LEASE            28
     310: 
     311: #define CAP_AUDIT_WRITE      29
     312: 
     313: #define CAP_AUDIT_CONTROL    30
     314: 
     315: #define CAP_SETFCAP         31
     316: 
     317: /* Override MAC access.
     318:    The base kernel enforces no MAC policy.
     319:    An LSM may enforce a MAC policy, and if it does and it chooses
     320:    to implement capability based overrides of that policy, this is
     321:    the capability it should use to do so. */
     322: 
     323: #define CAP_MAC_OVERRIDE     32
     324: 
     325: /* Allow MAC configuration or state changes.
     326:    The base kernel requires no MAC configuration.
     327:    An LSM may enforce a MAC policy, and if it does and it chooses
     328:    to implement capability based checks on modifications to that
     329:    policy or the data required to maintain it, this is the
     330:    capability it should use to do so. */
     331: 
     332: #define CAP_MAC_ADMIN        33
     333: 
     334: /* Allow configuring the kernel's syslog (printk behaviour) */
     335: 
     336: #define CAP_SYSLOG           34
     337: 
     338: /* Allow triggering something that will wake the system */
     339: 
     340: #define CAP_WAKE_ALARM            35
     341: 
     342: /* Allow preventing system suspends */
     343: 
     344: #define CAP_BLOCK_SUSPEND    36
     345: 
     346: #define CAP_LAST_CAP         CAP_BLOCK_SUSPEND
     347: 
     348: #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
     349: 
     350: /*
     351:  * Bit location of each capability (used by user-space library and kernel)
     352:  */
     353: 
     354: #define CAP_TO_INDEX(x)     ((x) >> 5)        /* 1 << 5 == bits in __u32 */
     355: #define CAP_TO_MASK(x)      (1 << ((x) & 31)) /* mask for indexed __u32 */
     356: 
     357: 
     358: #endif /* _UAPI_LINUX_CAPABILITY_H */
     359: