include/linux/capability.h
Source file repositories/reference/linux-study-clean/include/linux/capability.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/capability.h- Extension
.h- Size
- 6463 bytes
- Lines
- 221
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
uapi/linux/capability.hlinux/uidgid.hlinux/bits.h
Detected Declarations
struct cpu_vfs_cap_datastruct filestruct inodestruct dentrystruct task_structstruct user_namespacestruct mnt_idmapfunction cap_combinefunction cap_intersectfunction cap_dropfunction cap_isclearfunction cap_isidenticalfunction cap_issubsetfunction cap_drop_fs_setfunction cap_raise_fs_setfunction cap_drop_nfsd_setfunction cap_raise_nfsd_setfunction has_ns_capabilityfunction has_capability_noauditfunction has_ns_capability_noauditfunction capablefunction ns_capablefunction ns_capable_noauditfunction ns_capable_setidfunction perfmon_capablefunction bpf_capablefunction checkpoint_restore_ns_capablefunction checkpoint_restore_ns_capable_noaudit
Annotated Snippet
struct cpu_vfs_cap_data {
__u32 magic_etc;
kuid_t rootid;
kernel_cap_t permitted;
kernel_cap_t inheritable;
};
#define _USER_CAP_HEADER_SIZE (sizeof(struct __user_cap_header_struct))
#define _KERNEL_CAP_T_SIZE (sizeof(kernel_cap_t))
struct file;
struct inode;
struct dentry;
struct task_struct;
struct user_namespace;
struct mnt_idmap;
/*
* CAP_FS_MASK and CAP_NFSD_MASKS:
*
* The fs mask is all the privileges that fsuid==0 historically meant.
* At one time in the past, that included CAP_MKNOD and CAP_LINUX_IMMUTABLE.
*
* It has never meant setting security.* and trusted.* xattrs.
*
* We could also define fsmask as follows:
* 1. CAP_FS_MASK is the privilege to bypass all fs-related DAC permissions
* 2. The security.* and trusted.* xattrs are fs-related MAC permissions
*/
# define CAP_FS_MASK (BIT_ULL(CAP_CHOWN) \
| BIT_ULL(CAP_MKNOD) \
| BIT_ULL(CAP_DAC_OVERRIDE) \
| BIT_ULL(CAP_DAC_READ_SEARCH) \
| BIT_ULL(CAP_FOWNER) \
| BIT_ULL(CAP_FSETID) \
| BIT_ULL(CAP_MAC_OVERRIDE))
#define CAP_VALID_MASK (BIT_ULL(CAP_LAST_CAP+1)-1)
# define CAP_EMPTY_SET ((kernel_cap_t) { 0 })
# define CAP_FULL_SET ((kernel_cap_t) { CAP_VALID_MASK })
# define CAP_FS_SET ((kernel_cap_t) { CAP_FS_MASK | BIT_ULL(CAP_LINUX_IMMUTABLE) })
# define CAP_NFSD_SET ((kernel_cap_t) { CAP_FS_MASK | BIT_ULL(CAP_SYS_RESOURCE) })
# define cap_clear(c) do { (c).val = 0; } while (0)
#define cap_raise(c, flag) ((c).val |= BIT_ULL(flag))
#define cap_lower(c, flag) ((c).val &= ~BIT_ULL(flag))
#define cap_raised(c, flag) (((c).val & BIT_ULL(flag)) != 0)
static inline kernel_cap_t cap_combine(const kernel_cap_t a,
const kernel_cap_t b)
{
return (kernel_cap_t) { a.val | b.val };
}
static inline kernel_cap_t cap_intersect(const kernel_cap_t a,
const kernel_cap_t b)
{
return (kernel_cap_t) { a.val & b.val };
}
static inline kernel_cap_t cap_drop(const kernel_cap_t a,
const kernel_cap_t drop)
{
return (kernel_cap_t) { a.val &~ drop.val };
}
static inline bool cap_isclear(const kernel_cap_t a)
{
return !a.val;
}
static inline bool cap_isidentical(const kernel_cap_t a, const kernel_cap_t b)
{
return a.val == b.val;
}
/*
* Check if "a" is a subset of "set".
* return true if ALL of the capabilities in "a" are also in "set"
* cap_issubset(0101, 1111) will return true
* return false if ANY of the capabilities in "a" are not in "set"
* cap_issubset(1111, 0101) will return false
*/
static inline bool cap_issubset(const kernel_cap_t a, const kernel_cap_t set)
{
return !(a.val & ~set.val);
}
Annotation
- Immediate include surface: `uapi/linux/capability.h`, `linux/uidgid.h`, `linux/bits.h`.
- Detected declarations: `struct cpu_vfs_cap_data`, `struct file`, `struct inode`, `struct dentry`, `struct task_struct`, `struct user_namespace`, `struct mnt_idmap`, `function cap_combine`, `function cap_intersect`, `function cap_drop`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.