Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI_LINUX_SECUREBITS_H
0003 #define _UAPI_LINUX_SECUREBITS_H
0004 
0005 /* Each securesetting is implemented using two bits. One bit specifies
0006    whether the setting is on or off. The other bit specify whether the
0007    setting is locked or not. A setting which is locked cannot be
0008    changed from user-level. */
0009 #define issecure_mask(X)    (1 << (X))
0010 
0011 #define SECUREBITS_DEFAULT 0x00000000
0012 
0013 /* When set UID 0 has no special privileges. When unset, we support
0014    inheritance of root-permissions and suid-root executable under
0015    compatibility mode. We raise the effective and inheritable bitmasks
0016    *of the executable file* if the effective uid of the new process is
0017    0. If the real uid is 0, we raise the effective (legacy) bit of the
0018    executable file. */
0019 #define SECURE_NOROOT           0
0020 #define SECURE_NOROOT_LOCKED        1  /* make bit-0 immutable */
0021 
0022 #define SECBIT_NOROOT       (issecure_mask(SECURE_NOROOT))
0023 #define SECBIT_NOROOT_LOCKED    (issecure_mask(SECURE_NOROOT_LOCKED))
0024 
0025 /* When set, setuid to/from uid 0 does not trigger capability-"fixup".
0026    When unset, to provide compatiblility with old programs relying on
0027    set*uid to gain/lose privilege, transitions to/from uid 0 cause
0028    capabilities to be gained/lost. */
0029 #define SECURE_NO_SETUID_FIXUP      2
0030 #define SECURE_NO_SETUID_FIXUP_LOCKED   3  /* make bit-2 immutable */
0031 
0032 #define SECBIT_NO_SETUID_FIXUP  (issecure_mask(SECURE_NO_SETUID_FIXUP))
0033 #define SECBIT_NO_SETUID_FIXUP_LOCKED \
0034             (issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED))
0035 
0036 /* When set, a process can retain its capabilities even after
0037    transitioning to a non-root user (the set-uid fixup suppressed by
0038    bit 2). Bit-4 is cleared when a process calls exec(); setting both
0039    bit 4 and 5 will create a barrier through exec that no exec()'d
0040    child can use this feature again. */
0041 #define SECURE_KEEP_CAPS        4
0042 #define SECURE_KEEP_CAPS_LOCKED     5  /* make bit-4 immutable */
0043 
0044 #define SECBIT_KEEP_CAPS    (issecure_mask(SECURE_KEEP_CAPS))
0045 #define SECBIT_KEEP_CAPS_LOCKED (issecure_mask(SECURE_KEEP_CAPS_LOCKED))
0046 
0047 /* When set, a process cannot add new capabilities to its ambient set. */
0048 #define SECURE_NO_CAP_AMBIENT_RAISE     6
0049 #define SECURE_NO_CAP_AMBIENT_RAISE_LOCKED  7  /* make bit-6 immutable */
0050 
0051 #define SECBIT_NO_CAP_AMBIENT_RAISE (issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE))
0052 #define SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED \
0053             (issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED))
0054 
0055 #define SECURE_ALL_BITS     (issecure_mask(SECURE_NOROOT) | \
0056                  issecure_mask(SECURE_NO_SETUID_FIXUP) | \
0057                  issecure_mask(SECURE_KEEP_CAPS) | \
0058                  issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE))
0059 #define SECURE_ALL_LOCKS    (SECURE_ALL_BITS << 1)
0060 
0061 #endif /* _UAPI_LINUX_SECUREBITS_H */