一 capability集:
能力 作用 危险
CAP_AUDIT_CONTROL: Control kernel auditing
CAP_AUDIT_READ: Read the audit log via a multicast netlink socket
CAP_AUDIT_WRITE: Write records to kernel audit log
CAP_BLOCK_SUSPEND: Can prevent the system from suspending
CAP_CHOWN: Change file user and group Yes
CAP_DAC_OVERRIDE: Bypass file permission checks Yes
CAP_DAC_READ_SEARCH: Read all files and directories Yes
CAP_FOWNER: Perform operations on files owned by other users such as chmod, chattr or utime Yes
CAP_FSETID: Keep suid and guid permissions when modifying a file Yes
CAP_IPC_LOCK: Lock memory (mlock, mlockall, mmap, shmctl)
CAP_IPC_OWNER: Bypass shared memory permission checks Yes
CAP_KILL: Send signals to any process
CAP_LEASE: Establish leases on any file
CAP_LINUX_IMMUTABLE: Make files immutable and remove ability append to file using chattr
CAP_MAC_ADMIN: Perform MAC administration (for Smack LSM) Yes
CAP_MAC_OVERRIDE: Override MAC (for Smack LSM) Yes
CAP_MKNOD: Create files using mknod()
CAP_NET_ADMIN: Perform network administration such as configuring interfaces or routing tables Yes
CAP_NET_BIND_SERVICE: Bind socket to privileged port (< 1024)
CAP_NET_BROADCAST: Make socket broadcasts and listen to multicasts
CAP_NET_RAW: Use RAW and PACKET sockets
CAP_SETGID: Change to any Group ID
CAP_SETFCAP: Set file capabilities Yes
CAP_SETPCAP: Set capabilities if file capabilities not present
CAP_SETUID: Change to any User ID
CAP_SYS_ADMIN: Perform privileged system administration operations such as mount, swapon, sethostname and keyctl.This capability in particular, can be used in multiple ways to gain additional privileges. Yes
CAP_SYS_BOOT: Can reboot and kexec_load
CAP_SYS_CHROOT: Can chroot
CAP_SYS_MODULE: Can load and unload kernel modules
CAP_SYS_NICE: Change process priority levels and scheduling class (e.g. to real-time)
CAP_SYS_PACCT: Can use acct
CAP_SYS_PTRACE: ptrace any process Yes
CAP_SYS_RAWIO: Perform I/O port operations and access /proc/kcore. Override zero mmap restrictions.
CAP_SYS_RESOURCE: Set or override resource limits
CAP_SYS_TIME: Can set the system clock and real-time hardware clock
CAP_SYS_TTY_CONFIG: Can hang up the current tty
CAP_SYSLOG: Can configure the behavior of printk() to affect the kernel’s syslog
CAP_WAKE_ALARM: Can trigger something to wake the system
注意:不能版本内核可能会有些差异,有些是后面才增加的。
二 能力的传递
通过fork或clone创建的子进程:
通过exec启动的进程:
* pP' = (X & fP) | (pI & fI)
*/
new->cap_permitted.cap[i] =
(new->cap_bset.cap[i] & permitted) |
(new->cap_inheritable.cap[i] & inheritable);
new->cap_effective = new->cap_permitted;
else
cap_clear(new->cap_effective);
/* pP' = (cap_bset & ~0) | (pI & ~0) */
new->cap_permitted = cap_combine(old->cap_bset,
old->cap_inheritable);
}