Linux 权能综述

2023-05-16

为了执行权限检查,传统的 UNIX 实现区分两种类型的进程:特权进程(其有效用户 ID 为0,称为超级用户或 root),和非特权用户(其有效 UID 非0)。特权进程绕过所有的内核权限检查,而非特权进程受基于进程的认证信息(通常是:有效 UID,有效 GID,和补充组列表)的完整权限检查的支配。

自内核 2.2 版本开始,Linux 将传统上与超级用户关联的特权分为几个单元,称为 capabilities (权能),它们可以被独立的启用或禁用。权能是每个线程的属性。

权能列表

下面的列表展示了 Linux 上实现的权能,以及每种权能允许的操作或行为:

  • CAP_AUDIT_CONTROL(自 Linux 2.6.11)
    启用和禁用内核审计;修改审计过滤器规则;提取审计状态和过滤规则。
  • CAP_AUDIT_READ(自 Linux 3.16)
    允许通过一个多播 netlink socket 读取审计日志。
  • CAP_AUDIT_WRITE(自 Linux 2.6.11)
    向内核审计日志写记录。
  • CAP_BLOCK_SUSPEND(自 Linux 3.5)
    可以阻塞系统挂起(epoll(7) EPOLLWAKEUP/proc/sys/wake_lock)的特性。
  • CAP_CHOWN
    对文件的 UIDs 和 GIDs 做任意的修改(参考 chown(2))。
  • CAP_DAC_OVERRIDE
    绕过文件的读,写,和执行权限检查。(DAC 是 "discretionary access control" 的缩写。)
  • CAP_DAC_READ_SEARCH
    • 绕过文件的读权限检查和目录的读和执行权限检查;
    • 调用 open_by_handle_at(2)。
  • CAP_FOWNER
    • 对于通常要求进程的文件系统 UID 与文件的 UID 匹配的操作,绕过权限检查 (比如,chmod(2),utime(2)),除了那些包含在 CAP_DAC_OVERRIDECAP_DAC_READ_SEARCH 中的操作;
    • 为任意文件设置扩展文件属性(参考 chattr(1));
    • 为任意文件设置访问控制表(ACLs);
    • 对文件删除操作忽略目录的 sticky 位;
    • open(2) 和 fcntl(2) 任意文件时设置 O_NOATIME
  • CAP_FSETID
    当文件修改时不清除 set-user-ID 和 set-group-ID 模式位;为文件 GID 与调用进程的文件系统或补充 GIDs 不匹配的文件设置 set-group-ID 位。
  • CAP_IPC_LOCK
    锁定内存 (mlock(2),mlockall(2),mmap(2),shmctl(2))。
  • CAP_IPC_OWNER
    绕过对 System V IPC 对象的操作的权限检查。
  • CAP_KILL
    绕过发送信号 (参考 kill(2)) 时的权限检查。这包括使用 ioctl(2) KDSIGACCEPT 操作。
  • CAP_LEASE(自 Linux 2.4)
    为任意文件建立租约 (参考 fcntl(2))。
  • CAP_LINUX_IMMUTABLE
    设置FS_APPEND_FLFS_IMMUTABLE_FL inode 标记 (参考 chattr(1))。
  • CAP_MAC_ADMIN(自 Linux 2.6.25)
    覆盖强制访问控制 (Mandatory Access Control (MAC)). 为 Smack Linux 安全模块(Linux Security Module (LSM)) 而实现。
  • CAP_MAC_OVERRIDE(自 Linux 2.6.25)
    允许 MAC 配置或状态改变。为 Smack LSM 而实现。
  • CAP_MKNOD(自 Linux 2.4)
    使用 mknod(2) 创建特殊文件。
  • CAP_NET_ADMIN
    执行多种网络有关的操作:
    • 接口配置;
    • IP 防火墙,地址伪装,和账单管理;
    • 修改路由表;
    • 为透明代理绑定任何地址;
    • 设置服务类性 (type-of-service (TOS));
    • 清理驱动统计资料;
    • 设置混杂模式;
    • 启用组播;
    • 使用 setsockopt(2) 设置下列 socket 选项:SO_DEBUGSO_MARKSO_PRIORITY (在0到6范围之外的优先级),SO_RCVBUFFORCE,和 SO_SNDBUFFORCE
  • CAP_NET_BIND_SERVICE
    将一个 socket 绑定到一个互联网域特权端口 (端口号小于 1024)。
  • CAP_NET_BROADCAST
    (未使用) 使 socket 发送组播,并监听组播。
  • CAP_NET_RAW
    • 使用 RAW 和 PACKET sockets;
    • 为透明代理绑定任何地址。
  • CAP_SETGID
    执行任意的进程 GIDs 和补充 GID 列表管理;当通过 UNIX 域 sockets 传递 socket 认证信息时伪造 GID;在一个用户命名空间 (参考 user_namespaces(7)) 中写入组 ID 映射。
  • CAP_SYS_ADMIN
    • 执行一系列系统管理操作,包括:quotactl(2),mount(2),umount(2),swapon(2),swapoff(2),sethostname(2),和 setdomainname(2);
    • 执行特权 syslog(2) 操作 (自 Linux 2.6.37 开始,应该使用 CAP_SYSLOG 来允许这一操作);
    • 执行 VM86_REQUEST_IRQ vm86(2) 命令;
    • 对任意 System V IPC 对象执行 IPC_SET 和 IPC_RMID 操作;
    • 覆盖 RLIMIT_NPROC 资源限制;
    • 执行 trusted 和 security Extended Attributes (see xattr(7)) 操作;
    • 使用 lookup_dcookie(2);
    • 使用 ioprio_set(2) 来分配 IOPRIO_CLASS_RT 和 (Linux 2.6.25 之前) IOPRIO_CLASS_IDLE I/O 调度类别;
    • 当通过 UNIX 域 sockets 传递 socket 认证信息时伪装 PID;
    • 在系统调用打开文件 (比如,accept(2),execve(2),open(2),pipe(2)) 时,超出 /proc/sys/fs/file-max,系统范围内打开文件数的限制;
    • 通过 clone(2) 和 unshare(2) 使用 CLONE_* 标记创建新的命名空间(但是,自从 Linux 3.8 开始,创建命名空间不需要任何权能);
    • 调用 perf_event_open(2);
    • 访问特权 perf 事件信息;
    • 调用 setns(2) (在目标命名空间中需要 CAP_SYS_ADMIN);
    • 调用 fanotify_init(2);
    • 调用 bpf(2);
    • 执行 KEYCTL_CHOWNKEYCTL_SETPERM keyctl(2) 操作;
    • 执行 madvise(2) MADV_HWPOISON 操作;
    • 使用 TIOCSTI ioctl(2) 向一个终端的输入队列中插入字符,而不是调用者的控制终端;
    • 使用废弃的 nfsservctl (2) 系统调用;
    • 使用废弃的 bdflush (2) 系统调用;
    • 执行各种特权的块设备 ioctl(2) 操作;
    • 执行各种特权的文件系统 ioctl(2) 操作;
    • 对许多设备驱动执行管理操作。
  • CAP_SYS_BOOT
    使用 reboot(2) 和 kexec_load(2)。
  • CAP_SYS_CHROOT
    使用 chroot(2)。
  • CAP_SYS_MODULE
    加载和卸载内核模块(参考 init_module(2) 和 delete_module(2));在 2.6.25 之前的内核中:从系统范围内的权能边界集合中丢弃权能。
  • CAP_SYS_NICE
    • 触发进程 nice 值 (nice(2),setpriority(2)) 和为任意进程改变 nice 值;
    • 为调用进程设置实时调度策略,及为任意进程设置调度策略和优先级 (sched_setscheduler(2),sched_setparam(2),shed_setattr(2));
    • 为任意进程设置 CPU affinity (sched_setaffinity(2));
    • 为任意进程设置 I/O 调度类别和优先级 (ioprio_set(2));
    • 对任意进程应用 migrate_pages(2) 并允许进程被迁移到任意节点;
    • 对任意进程应用 move_pages(2);
    • mbind(2) 和 move_pages(2) 中使用 MPOL_MF_MOVE_ALL 标记。
  • CAP_SYS_PACCT
    使用 acct(2)。
  • CAP_SYS_PTRACE
    • 使用 ptrace(2) 追踪任意进程;
    • 对任意进程应用 get_robust_list(2);
    • 使用 process_vm_readv(2) 和 process_vm_writev(2) 同任意进程的内存传输数据;
    • 使用 kcmp(2) 检查进程。
  • CAP_SYS_RAWIO
    • 执行 I/O 端口操作 (iopl(2) 和 ioperm(2));
    • 访问 /proc/kcore;
    • 使用 FIBMAP ioctl(2) 操作;
    • 打开设备访问 x86 模式特有寄存器 (MSRs,参考 msr(4));
    • 更新 /proc/sys/vm/mmap_min_addr;
    • 在地址低于 /proc/sys/vm/mmap_min_addr 的位置创建内存映射;
    • 在 /proc/bus/pci 中映射文件;
    • 打开 /dev/mem 和 /dev/kmem;
    • 执行各种 SCSI 设备命令;
    • hpsa(4) 和 cciss(4) 设备上执行某一操作;
    • 在其它设备上执行一系列设备特有操作。
  • CAP_SYS_RESOURCE
    • 使用 ext2 文件系统上的预留空间;
    • 执行 ioctl(2) 调用控制 ext3 日志;
    • 覆盖磁盘配额限制;
    • 增加资源限制 (参考 setrlimit(2));
    • 覆盖 RLIMIT_NPROC 资源限制;
    • 在终端分配上覆盖最大的终端数;
    • 覆盖最大的 keymaps 个数;
    • 允许实时时钟中断大于64 hz;
    • 触发一个 System V 消息队列的 msg_qbytes 限制超过 /proc/sys/kernel/msgmnb 中的限制 (参考 msgop(2) 和 msgctl(2));
    • 当使用 F_SETPIPE_SZ fcntl(2) 命令设置一个管道的容量时覆盖 /proc/sys/fs/pipe-size-max 的限制;
    • 使用 F_SETPIPE_SZ 增加管道的容量超出 /proc/sys/fs/pipe-max-size 指定的限制;
    • 当创建 POSIX 消息队列 (参考 mq_overview(7)) 时覆盖 /proc/sys/fs/mqueue/queues_max 的限制;
    • 使用 prctl(2) PR_SET_MM 操作;
    • 设置 /proc/PID/oom_score_adj 为一个小于由一个具有 CAP_SYS_RESOURCE 的进程最近设置的值的值。
  • CAP_SYS_TIME
    设置系统时钟 (settimeofday(2),stime(2),adjtimex(2));设置实时 (硬件) 时钟。
  • CAP_SYS_TTY_CONFIG
    使用 vhangup(2);对虚拟终端使用各种特权 ioctl(2) 操作。
  • CAP_SYSLOG (自 Linux 2.6.37)
    • 执行特权 syslog(2) 操作。参考 syslog(2) 来获取哪些操作需要特权的信息;
    • 当 /proc/sys/kernel/kptr_restrict 值为 1 时,查看通过 /proc 和其它接口暴露
      的内核地址。(参考 proc(5) 中 kptr_restrict 的讨论。)
  • CAP_WAKE_ALARM (自 Linux 3.0)
    触发将唤醒系统的东西 (设置 CLOCK_REALTIME_ALARM 和 CLOCK_BOOTTIME_ALARM 定时器)。

过去和当前的实现

权能的完整实现需要:

  1. 对于所有的特权操作,内核必须检查线程是否在其有效集合中具有要求的权能。
  2. 内核必须提供系统调用以允许设置和提取一个线程的权能。
  3. 文件系统必须支持为一个可执行文件附接权能,以使文件被执行时进程获得那些权能。

在内核 2.6.24 之前,只有前两个要求能够满足;自内核 2.6.24 开始,所有三个要求都能满足。

线程权能集合

每个线程具有三个包含零个或多个上面的权能的权能集合:

  • 被允许的 (Permitted):
    这是线程可以承担的有效权能的限制性超集。这也是在线程的有效集合中不包含 CAP_SETPCAP 权能时,可以被线程添加进可继承的集合的权能的限制性超集。

    如果一个线程从它的被允许集合中丢弃了一个权能,则它将永远无法重新获取该权能 (除非它 execve(2)s 一个 set-user-ID-root 程序,或一个关联的文件权能获取了该权能授权的程序)。

  • 可继承的 (Inheritable):
    这是跨越一个 execve(2) 保留的权能的集合。当执行任何程序时可继承的权能保持可继承,且当执行一个在文件的可继承集合中设置了对应位的程序时可继承权能被添加进被允许的集合。

    由于可继承的权能在以非 root 用户运行时通常不跨 execve(2) 保留,希望以抬高的权能运行辅助程序的应用应该考虑使用外界的权能,在下面描述。

  • 有效地 (Effective):
    这是内核用来为线程执行权限检查的权能集合。

  • 外界的 (Ambient) (自 Linux 4.3):
    这是一个为非特权程序的跨 execve(2) 保留的权能集合。外界的权能集合服从不可变性,如果权能既不是被允许的也不是可继承的,则它也从不可能是外界的。

    外界的权能集合可以直接使用 prctl(2) 修改。如果对应的被允许的或可继承的权能被降低,外界的权能将自动地降低。

    执行一个由于 set-user-ID 或 set-group-ID 位而修改 UID 或 GID 的程序,或执行一个具有任何文件权能集合的程序将清除外界的集合。在调用 execve(2) 时外界的权能被添加进被允许的集合,并被赋值给有效集合。

A child created via fork(2) inherits copies of its parent's capability sets. See below for a discussion of the treatment of capabilities during execve(2).

Using capset(2), a thread may manipulate its own capability sets (see below).

Since Linux 3.2, the file /proc/sys/kernel/cap_last_cap exposes the numerical value of the highest capability supported by the running kernel; this can be used to determine the highest bit that may be set in a capability set.

文件权能

Since kernel 2.6.24, the kernel supports associating capability sets with an executable file using setcap(8). The file capability sets are stored in an extended attribute (see setxattr(2)) named security.capability. Writing to this extended attribute requires the CAP_SETFCAP capability. The file capability sets, in conjunction with the capability sets of the thread, determine the capabilities of a thread after an execve(2).

The three file capability sets are:

  • Permitted (formerly known as forced):
    These capabilities are automatically permitted to the thread, regardless of the thread's inheritable capabilities.

  • Inheritable (formerly known as allowed):
    This set is ANDed with the thread's inheritable set to determine which inheritable capabilities are enabled in the permitted set of the thread after the execve(2).

  • Effective:
    This is not a set, but rather just a single bit. If this bit is set, then during an execve(2) all of the new permitted capabilities for the thread are also raised in the effective set. If this bit is not set, then after an execve(2), none of the new permitted capabilities is in the new effective set.

    Enabling the file effective capability bit implies that any file permitted or inheritable capability that causes a thread to acquire the corresponding permitted capability during an execve(2) (see the transformation rules described below) will also acquire that capability in its effective set. Therefore, when assigning capabilities to a file (setcap(8), cap_set_file(3), cap_set_fd(3)), if we specify the effective flag as being enabled for any capability, then the effective flag must also be specified as enabled for all other capabilities for which the corresponding permitted or inheritable flags is enabled.

execve() 期间的权能转换

During an execve(2), the kernel calculates the new capabilities of the process using the following algorithm:

  • P'(ambient) = (file is privileged) ? 0 : P(ambient)

  • P'(permitted) = (P(inheritable) & F(inheritable)) | (F(permitted) & cap_bset) | P'(ambient)

  • P'(effective) = F(effective) ? P'(permitted) : P'(ambient)

  • P'(inheritable) = P(inheritable) [i.e., unchanged]

其中:

  • P denotes the value of a thread capability set before the execve(2)

  • P' denotes the value of a capability set after the execve(2)

  • F denotes a file capability set

  • cap_bset is the value of the capability bounding set (described below).

A privileged file is one that has capabilities or has the set-user-ID or set-group-ID bit set.

root 的程序的权能和执行

In order to provide an all-powerful root using capability sets, during an execve(2):

  1. If a set-user-ID-root program is being executed, or the real user ID of the process is 0 (root) then the file inheritable and permitted sets are defined to be all ones (i.e., all capabilities enabled).

  2. If a set-user-ID-root program is being executed, then the file effective bit is defined to be one (enabled).

The upshot of the above rules, combined with the capabilities transformations described above, is that when a process execve(2)s a set-user-ID-root program, or when a process with an effective UID of 0 execve(2)s a program, it gains all capabilities in its permitted and effective capability sets, except those masked out by the capability bounding set. This provides semantics that are the same as those provided by traditional UNIX systems.

权能边界集合

The capability bounding set is a security mechanism that can be used to limit the capabilities that can be gained during an execve(2). The bounding set is used in the following ways:

  • During an execve(2), the capability bounding set is ANDed with the file permitted capability set, and the result of this operation is assigned to the thread's permitted capability set. The capability bounding set thus places a limit on the permitted capabilities that may be granted by an executable file.

  • (Since Linux 2.6.25) The capability bounding set acts as a limiting superset for the capabilities that a thread can add to its inheritable set using capset(2). This means that if a capability is not in the bounding set, then a thread can't add this capability to its inheritable set, even if it was in its permitted capabilities, and thereby cannot have this capability preserved in its permitted set when it execve(2)s a file that has the capability in its inheritable set.

Note that the bounding set masks the file permitted capabilities, but not the inherited capabilities. If a thread maintains a capability in its inherited set that is not in its bounding set, then it can still gain that capability in its permitted set by executing a file that has the capability in its inherited set.

Depending on the kernel version, the capability bounding set is either a system-wide attribute, or a per-process attribute.

Linux 2.6.25 之前的权能边界集合

In kernels before 2.6.25, the capability bounding set is a system-wide attribute that affects all threads on the system. The bounding set is accessible via the file /proc/sys/kernel/cap-bound. (Confusingly, this bit mask parameter is expressed as a signed decimal number in /proc/sys/kernel/capbound.)

Only the init process may set capabilities in the capability bounding set; other than that, the superuser (more precisely: programs with the CAP_SYS_MODULE capability) may only clear capabilities from this set.

On a standard system the capability bounding set always masks out the CAP_SETPCAP capability. To remove this restriction (dangerous!), modify the definition of CAP_INIT_EFF_SET in include/linux/capability.h and rebuild the kernel.

The system-wide capability bounding set feature was added to Linux starting with kernel version 2.2.11.

Linux 2.6.25 之后的权能边界集合

From Linux 2.6.25, the capability bounding set is a per-thread attribute. (There is no longer a systemwide capability bounding set.)

The bounding set is inherited at fork(2) from the thread's parent, and is preserved across an execve(2).

A thread may remove capabilities from its capability bounding set using the prctl(2) PR_CAPBSET_DROP operation, provided it has the CAP_SETPCAP capability. Once a capability has been dropped from the bounding set, it cannot be restored to that set. A thread can determine if a capability is in its bounding set using the prctl(2) PR_CAPBSET_READ operation.

Removing capabilities from the bounding set is supported only if file capabilities are compiled into the kernel. In kernels before Linux 2.6.33, file capabilities were an optional feature configurable via the CONFIG_SECURITY_FILE_CAPABILITIES option. Since Linux 2.6.33, the configuration option has been removed and file capabilities are always part of the kernel. When file capabilities are compiled into the kernel, the init process (the ancestor of all processes) begins with a full bounding set. If file capabilities are not compiled into the kernel, then init begins with a full bounding set minus CAP_SETPCAP, because this capability has a different meaning when there are no file capabilities.

Removing a capability from the bounding set does not remove it from the thread's inherited set. However it does prevent the capability from being added back into the thread's inherited set in the future.

Effect of user ID changes on capabilities

To preserve the traditional semantics for transitions between 0 and nonzero user IDs, the kernel makes the following changes to a thread's capability sets on changes to the thread's real, effective, saved set, and filesystem user IDs (using setuid(2), setresuid(2), or similar):

  1. If one or more of the real, effective or saved set user IDs was previously 0, and as a result of the UID changes all of these IDs have a nonzero value, then all capabilities are cleared from the permitted and effective capability sets.

  2. If the effective user ID is changed from 0 to nonzero, then all capabilities are cleared from the effective set.

  3. If the effective user ID is changed from nonzero to 0, then the permitted set is copied to the effective set.

  4. If the filesystem user ID is changed from 0 to nonzero (see setfsuid(2)), then the following capabilities are cleared from the effective set: CAP_CHOWN, CAP_DAC_OVERRIDE, CAP_DAC_READ_SEARCH, CAP_FOWNER, CAP_FSETID, CAP_LINUX_IMMUTABLE (since Linux 2.6.30), CAP_MAC_OVERRIDE, and CAP_MKNOD (since Linux 2.6.30). If the filesystem UID is changed from nonzero to 0, then any of these capabilities that are enabled in the permitted set are enabled in the effective set.

If a thread that has a 0 value for one or more of its user IDs wants to prevent its permitted capability set being cleared when it resets all of its user IDs to nonzero values, it can do so using the prctl(2) PR_SET_KEEPCAPS operation or the SECBIT_KEEP_CAPS securebits flag described below.

以编程方式调整权能集合

A thread can retrieve and change its capability sets using the capget(2) and capset(2) system calls. However, the use of cap_get_proc(3) and cap_set_proc(3), both provided in the libcap package, is preferred for this purpose. The following rules govern changes to the thread capability sets:

  1. If the caller does not have the CAP_SETPCAP capability, the new inheritable set must be a subset of the combination of the existing inheritable and permitted sets.

  2. (Since Linux 2.6.25) The new inheritable set must be a subset of the combination of the existing inheritable set and the capability bounding set.

  3. The new permitted set must be a subset of the existing permitted set (i.e., it is not possible to acquire permitted capabilities that the thread does not currently have).

  4. The new effective set must be a subset of the new permitted set.

securebits 标志:建立一个仅限权能的环境

Starting with kernel 2.6.26, and with a kernel in which file capabilities are enabled, Linux implements a set of per-thread securebits flags that can be used to disable special handling of capabilities for UID 0 (root). These flags are as follows:

  • SECBIT_KEEP_CAPS
    Setting this flag allows a thread that has one or more 0 UIDs to retain its capabilities when it switches all of its UIDs to a nonzero value. If this flag is not set, then such a UID switch causes the thread to lose all capabilities. This flag is always cleared on an execve(2). (This flag provides the same functionality as the older prctl(2) PR_SET_KEEPCAPS operation.)

  • SECBIT_NO_SETUID_FIXUP
    Setting this flag stops the kernel from adjusting capability sets when the threads's effective and filesystem UIDs are switched between zero and nonzero values. (See the subsection Effect of User ID Changes on Capabilities.)

  • SECBIT_NOROOT
    If this bit is set, then the kernel does not grant capabilities when a set-user-ID-root program is executed, or when a process with an effective or real UID of 0 calls execve(2). (See the subsection Capabilities and execution of programs by root.)

  • SECBIT_NO_CAP_AMBIENT_RAISE
    Setting this flag disallows raising ambient capabilities via the prctl(2) PR_CAP_AMBIENT_RAISE operation.

Each of the above "base" flags has a companion "locked" flag. Setting any of the "locked" flags is irreversible, and has the effect of preventing further changes to the corresponding "base" flag. The locked flags are: SECBIT_KEEP_CAPS_LOCKED, SECBIT_NO_SETUID_FIXUP_LOCKED, SECBIT_NOROOT_LOCKED, and SECBIT_NO_CAP_AMBIENT_RAISE.

The securebits flags can be modified and retrieved using the prctl(2) PR_SET_SECUREBITS and PR_GET_SECUREBITS operations. The CAP_SETPCAP capability is required to modify the flags.

The securebits flags are inherited by child processes. During an execve(2), all of the flags are preserved, except SECBIT_KEEP_CAPS which is always cleared.

An application can use the following call to lock itself, and all of its descendants, into an environment where the only way of gaining capabilities is by executing a program with associated file capabilities:

           prctl(PR_SET_SECUREBITS,
                   SECBIT_KEEP_CAPS_LOCKED |
                   SECBIT_NO_SETUID_FIXUP |
                   SECBIT_NO_SETUID_FIXUP_LOCKED |
                   SECBIT_NOROOT |
                   SECBIT_NOROOT_LOCKED);

与用户命名空间交互

For a discussion of the interaction of capabilities and user namespaces, see user_namespaces(7).

标准参考

No standards govern capabilities, but the Linux capability implementation is based on the withdrawn POSIX.1e draft standard; see ⟨http://wt.tuxomania.net/publications/posix.1e/⟩.

备注

From kernel 2.5.27 to kernel 2.6.26, capabilities were an optional kernel component, and can be enabled/disabled via the CONFIG_SECURITY_CAPABILITIES kernel configuration option.

The /proc/PID/task/TID/status file can be used to view the capability sets of a thread. The /proc/PID/status file shows the capability sets of a process's main thread. Before Linux 3.8, nonexistent capabilities were shown as being enabled (1) in these sets. Since Linux 3.8, all nonexistent capabilities (above CAP_LAST_CAP) are shown as disabled (0).

The libcap package provides a suite of routines for setting and getting capabilities that is more comfortable and less likely to change than the interface provided by capset(2) and capget(2). This package also provides the setcap(8) and getcap(8) programs. It can be found at ⟨http://www.kernel.org/pub/linux/libs/security/linux-privs⟩.

Before kernel 2.6.24, and from kernel 2.6.24 to kernel 2.6.32 if file capabilities are not enabled, a thread with the CAP_SETPCAP capability can manipulate the capabilities of threads other than itself. However, this is only theoretically possible, since no thread ever has CAP_SETPCAP in either of these cases:

  • In the pre-2.6.25 implementation the system-wide capability bounding set, /proc/sys/kernel/cap-bound, always masks out this capability, and this can not be changed without modifying the kernel source and rebuilding.

  • If file capabilities are disabled in the current implementation, then init starts out with this capability removed from its per-process bounding set, and that bounding set is inherited by all other processes created on the system.

另请参阅

capsh(1), setpriv(1), prctl(2), setfsuid(2), cap_clear(3), cap_copy_ext(3), cap_from_text(3), cap_get_file(3), cap_get_proc(3), cap_init(3), capgetp(3), capsetp(3), libcap(3), credentials(7), user_namespaces(7), pthreads(7), getcap(8), setcap(8)

include/linux/capability.h in the Linux kernel source tree

版本记录

This page is part of release 4.04 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at http://www.kernel.org/doc/man-pages/.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Linux 权能综述 的相关文章

  • 如何在两个不同帐户之间设置无密码身份验证

    我们可以在两台机器的两种不同用途之间设置无密码身份验证吗 例如 计算机A有用户A 计算机B有用户B 我们可以设置密码 ssh 以便计算机 A 上的用户 A 使用其用户帐户 A 登录计算机 B 谢谢你 如果我理解你的问题 你能设置一下吗ssh
  • 是否有可能在linux中找到包含特定文本的文件?

    考虑这种情况 我在文件夹 Example 下有很多文件 如果我需要找到一个包含特定短语 如 Class Example 的文件 我该如何使用 Linux shell 来做到这一点 linux中有类似 定位 的函数可以做到这一点吗 Thank
  • linux下如何获取昨天和前天?

    我想在变量中获取 sysdate 1 和 sysdate 2 并回显它 我正在使用下面的查询 它将今天的日期作为输出 bin bash tm date Y d m echo tm 如何获取昨天和前天的日期 这是另一种方法 对于昨天来说 da
  • Gradle 1.3:build.gradle 不构建类

    这里有一个新问题 我有一个 build gradle 文件apply plugin java在其中 并与 java 项目 包关联 当我跑步时gradle build从命令行我得到 compileJava UP TO DATE process
  • 为什么 ld 无法从 /etc/ld.so.conf 中的路径找到库?

    我想添加 opt vertica lib64进入系统库路径 所以我执行以下步骤 1 添加 opt vertica lib64 into etc ld so conf 然后运行ldconfig 2 检查 bash ldconfig p gre
  • Linux、ARM:为什么仅当启动时存在 I2C GPIO 扩展器时才创建 gpiochip

    在 imx6sx 硬件平台 NXP 嵌入式 ARM 上使用 Linux 3 14 52 问题是设备树中指定的 PCF8575 I2C GPIO 扩展器不会实例化为 sys class gpio 结构中的设备 除非它们在内核启动期间存在 这些
  • 错误:NVIDIA-SMI 失败,因为无法与 NVIDIA 驱动程序通信

    NVIDIA SMI 抛出此错误 NVIDIA SMI 失败 因为无法与 NVIDIA 通信 司机 确保安装了最新的 NVIDIA 驱动程序并且 跑步 我清除了 NVIDIA 并按照提到的步骤重新安装了它here https askubun
  • Linux命令列出所有可用命令和别名

    是否有一个 Linux 命令可以列出该终端会话的所有可用命令和别名 就好像您输入 a 并按下 Tab 键一样 但针对的是字母表中的每个字母 或者运行 别名 但也返回命令 为什么 我想运行以下命令并查看命令是否可用 ListAllComman
  • 如何从类似于 eclipse 的命令行创建可运行的 jar 文件

    我知道 eclipse 会生成一个可运行的 jar 文件 其中提取并包含在该 jar 文件中的所有库 jar 文件 从命令提示符手动创建 jar 文件时如何执行类似的操作 我需要将所有 lib jar 解压到类文件夹中吗 目前我正在使用 j
  • 为 Linux 安装 R 包时出错

    我试图在 R 3 3 上安装一个名为 rgeos 的包 但是当我输入 install packages rgeos 但它返回给我以下错误 其他包也会发生同样的情况 但不是所有包 gt installing source package rg
  • Scrapy FakeUserAgentError:获取浏览器时发生错误

    我使用 Scrapy FakeUserAgent 并在我的 Linux 服务器上不断收到此错误 Traceback most recent call last File usr local lib64 python2 7 site pack
  • 如何调用位于其他目录的Makefile?

    我正在尝试这样做 我想打电话给 make Makefile存在于其他目录中 abc可以使用位于不同目录中的 shell 脚本的路径 我该怎么做呢 由于 shell 脚本不允许我cd进入Makefile目录并执行make 我怎样才能编写she
  • 如何查明 Ubuntu 上安装了哪个版本的 GTK+?

    我需要确定 Ubuntu 上安装了哪个版本的 GTK 男人似乎不帮忙 这个建议 https stackoverflow com a 126145 会告诉您安装了哪个 2 0 的次要版本 不同的主要版本将具有不同的包名称 因为它们可以在系统上
  • numpy 未定义符号:PyFPE_jbuf

    我正在尝试使用一百万首歌曲数据集 为此我必须安装 python 表 numpy cython hdf5 numexpr 等 昨天我设法安装了我需要的所有内容 在使用 hdf5 遇到一些麻烦之后 我下载了预编译的二进制包并将它们保存在我的 b
  • 如何让 clangd 转向 c++20

    当没有其他信息时 如何让 clangd 回退到 c 20 例如 在第一次构建之前 cmake 可以生成一个 这是在带有最新 LLVM 的 Arch Linux 上 这是通过 Emacs LSP 运行的 但这应该没有什么区别 你可以加 Com
  • 构建 makefile 依赖/继承树

    如果我解释得不好或者问了一些明显的问题 我很抱歉 但我是 Linux 内核的新手 而且有点深入 我们有一个嵌入式 Linux 系统 它附带一个 文档非常糟糕的 SDK 其中包含数百个文件夹stuff 大多数文件夹包含rules make m
  • 无法执行'x86_64-conda_cos6-linux-gnu-gcc':没有这样的文件或目录(pysam安装)

    我正在尝试安装 pysam 执行后 python path to pysam master setup py build 这个错误的产生是 unable to execute x86 64 conda cos6 linux gnu gcc
  • Linux shell 脚本:十六进制数字到二进制字符串

    我正在 shell 脚本中寻找一些简单的方法来将十六进制数字转换为 0 和 1 字符的序列 Example 5F gt 01011111 是否有任何命令或简单的方法来完成它 或者我应该为其编写一些开关 echo ibase 16 obase
  • 劫持系统调用

    我正在编写一个内核模块 我需要劫持 包装一些系统调用 我正在暴力破解 sys call table 地址 并使用 cr0 来禁用 启用页面保护 到目前为止一切顺利 一旦完成 我将公开整个代码 因此如果有人愿意 我可以更新这个问题 无论如何
  • 为什么 Linux 对目录使用 getdents() 而不是 read()?

    我浏览 K R C 时注意到 为了读取目录中的条目 他们使用了 while read dp gt fd char dirbuf sizeof dirbuf sizeof dirbuf code Where dirbuf是系统特定的目录结构

随机推荐

  • gnu binutils

    The GNU Binutils are a collection of binary tools The main ones are ld the GNU linker as the GNU assembler But they also
  • android wakelock

    1 android休眠控制锁 powermanager acquir 获取控制锁 powermanager release 释放控制锁 2 在powerManagerService中 xff0c 有检测当前framework层中的wakel
  • 产品经理常用术语

    产品经理常用术语 长尾理论 网络时代兴起的一种新理论 xff0c 由于成本和效率的因素 xff0c 当商品储存流通展示的场地和渠道足够宽广 xff0c 商品生产成本急剧下降以至于个人都可以进行生产 xff0c 并且商品的销售成本急剧降低时
  • 传统CD车机面板操作说明

    转自http bbs hifidiy net thread 675597 1 1 html 一般CD车机带USB SD卡的面板操作说明 1 1 控制面板外观图 2 0 基本 共同 功能操作说明 2 1 开启和关闭电源 静音开关 按 钮为开启
  • 汽车总线系统通信协议

    天合汽车零部件 xff08 上海 xff09 有限公司 上海交通大学区域光纤通信网与新型光通信系统国家重点实验室 xff08 上网时间 xff1a 2006 11 xff09 摘要 xff1a 本文主要针对汽车电子控制系统和车载多媒体系统
  • 算法——连续性后处理(把26邻域连续的变成6邻域连续的)

    文章目录 1 概念 1 1 6邻域连续 1 2 18邻域连续 1 3 26邻域连续 1 4 总结 2 目标 3 严格一点的 3 1 原理描述 3 1 1 18邻域连续补充 3 1 2 26邻域连续补充 3 2 代码实现 C 4 宽松一点的
  • RedHat Linux下安装JDK1.7报错Permission denied

    在RedHat Linux5 中安装JDK1 7时 xff0c 当我解压jdk xff0c 并且配置好了环境变量 xff0c 测试的时候 xff0c 报以下错误 root 64 jingfeng01 java version Error d
  • 几种压缩算法的压缩和速度比较

    Quick Benchmark Gzip vs Bzip2 vs LZMA vs XZ vs LZ4 vs LZO EDIT Add zstd Contents hide 1 Selected archives2 Test conditio
  • DDR低功耗模式

    DDR规格 xff1a DDR工作状态图 xff1a DDR 刷新描述 xff1a 电特性 xff1a 工作模式简介 xff1a 1 1 自刷新模式 xff08 Self Refresh Mode xff09 DDR4 SDRAM中自刷新超
  • 嵌入式Linux的低功耗策略

    引 言 由于Linux系统具备嵌入式操作系统需要的很多特色 xff0c 如适应于多种CPU和多种硬件平台 性能稳定 可裁剪性很好 源码开放 研发和使用简单等 现在 xff0c 基于Linux应用的嵌入式设备日益增多 xff0c Linux正
  • libevent实现的HTTP Server

    在使用C语言编码时 有时候需要实现一个HTTP接口 我们可以选择使用libevent库来实现 以下代码演示了使用libevent 并同时支持多线程处理HTTP的请求 头文件 引入的头文件 span class token macro pro
  • Python爬虫完整案例 - 爬取百度百科词条信息

    概述 一个完整的爬虫 xff0c 一般由以下5个组件构成 1 URL管理器 负责维护待爬取URL队列 和已爬取URL队列 xff0c 必须拥有去重功能 2 HTML下载器 负责根据调度器从URL管理器中取出的url xff0c 下载html
  • android apk 签名(平台和普通签名)

    因为做了太多的终端项目 xff0c 客户总会有自己的apk提供 xff0c 这时候各种签名问题就来了 xff0c 最近整理了一下相关知识 xff0c 分享给大家 签名的用处 xff1a 1 应用程序升级 xff1a 如果你希望用户无缝升级到
  • scikit-learn介绍

    在机器学习和数据挖掘的应用中 xff0c scikit learn是一个功能强大的python包 在数据量不是过大的情况下 xff0c 可以解决大部分问题 学习使用scikit learn的过程中 xff0c 我自己也在补充着机器学习和数据
  • 【JUC】CompletableFuture超时处理 配置线程池

    CompletableFuture 简介使用方法代码 简介 xff1a 项目中一个统计的业务场景 xff0c 使用原生的CompletableFuture异步多个任务查询mysql数据 xff0c 少量请求无问题 xff0c 但是测试过程中
  • 使用mysql命令行导出导入MariaDB库数据中文乱码问题解决

    问题 xff1a 到MariaDB bin目录下 xff0c 使用shit 43 右键打开powershell xff0c 执行mysqldump命令导出ems2库数据为sql文件 xff0c 命令中设置字符集为utf8 xff0c 则生成
  • :app:checkDebugDuplicateClasses Execute taskAction

    今天把AS从2 3 3升为3 4 2后 xff0c 导入项后发现报这个 app checkDebugDuplicateClasses的错 xff1a 然后查看了日志 xff0c 真是长篇大论 xff0c 一头雾水 org gradle ap
  • 3D Slicer/ITK-SNAP常见使用

    不是医生 是程序员 使用侧重点不一定相同 文章目录 1 3D Slicer使用 1 0 常见快捷键 1 1 三视图联动 1 2 在model视图查看三视图 1 3 最大化某个视图 1 4 改segment的标号 label 1 5 常见插件
  • 某些.csh .sh脚本无法在shell下执行的问题解决

    背景 最近换了一个环境 xff0c 登录后执行一个环境相关配置的 csh脚本时发现某些执行字段无法识别 xff0c 这种一般就是不同bash支持的脚本语言的差异问题 解决 查询当前shell的bash xff1a echo SHELL 当前
  • Linux 权能综述

    为了执行权限检查 xff0c 传统的 UNIX 实现区分两种类型的进程 xff1a 特权进程 xff08 其有效用户 ID 为0 xff0c 称为超级用户或 root xff09 xff0c 和非特权用户 xff08 其有效 UID 非0