security/integrity/evm/evm_main.c
Source file repositories/reference/linux-study-clean/security/integrity/evm/evm_main.c
File Facts
- System
- Linux kernel
- Corpus path
security/integrity/evm/evm_main.c- Extension
.c- Size
- 33477 bytes
- Lines
- 1237
- Domain
- Core OS
- Bucket
- Security And Isolation
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/audit.hlinux/xattr.hlinux/integrity.hlinux/evm.hlinux/magic.hlinux/posix_acl_xattr.hlinux/lsm_hooks.hcrypto/hash.hcrypto/hash_info.hcrypto/utils.hevm.h
Detected Declarations
function evm_set_fixmodefunction evm_init_configfunction evm_key_loadedfunction evm_hmac_disabledfunction evm_sigv3_requiredfunction evm_find_protected_xattrsfunction list_for_each_entry_locklessfunction is_unsupported_hmac_fsfunction evm_verify_hmacfunction evm_protected_xattr_commonfunction evm_protected_xattrfunction evm_protected_xattr_if_enabledfunction namesfunction list_for_each_entry_locklessfunction evm_verifyxattrfunction evm_verify_current_integrityfunction evm_xattr_changefunction evm_protect_xattrfunction evm_inode_setxattrfunction evm_inode_removexattrfunction evm_inode_set_acl_changefunction evm_inode_set_acl_changefunction evm_inode_set_aclfunction evm_inode_remove_aclfunction evm_reset_statusfunction evm_metadata_changedfunction evm_verifyxattrfunction evm_fix_hmacfunction __vfs_setxattr_nopermfunction evm_inode_post_set_aclfunction vfs_removexattrfunction evm_inode_post_remove_aclfunction evm_attr_changefunction evm_inode_setattrfunction notify_changefunction evm_inode_copy_up_xattrfunction evm_inode_init_securityfunction evm_inode_alloc_securityfunction evm_file_releasefunction evm_post_path_mknodfunction evm_load_x509function init_evmfunction init_evm_lsmexport evm_verifyxattrexport evm_inode_init_security
Annotated Snippet
if (arch_get_secureboot()) {
pr_info("Secure boot enabled: ignoring evm=fix");
return;
}
evm_fixmode = 1;
} else {
pr_err("invalid \"%s\" mode", evm_cmdline);
}
}
static void __init evm_init_config(void)
{
int i, xattrs;
xattrs = ARRAY_SIZE(evm_config_default_xattrnames);
pr_info("Initialising EVM extended attributes:\n");
for (i = 0; i < xattrs; i++) {
pr_info("%s%s\n", evm_config_default_xattrnames[i].name,
!evm_config_default_xattrnames[i].enabled ?
" (disabled)" : "");
list_add_tail(&evm_config_default_xattrnames[i].list,
&evm_config_xattrnames);
}
#ifdef CONFIG_EVM_ATTR_FSUUID
evm_hmac_attrs |= EVM_ATTR_FSUUID;
#endif
pr_info("HMAC attrs: 0x%x\n", evm_hmac_attrs);
}
static bool evm_key_loaded(void)
{
return (bool)(evm_initialized & EVM_KEY_MASK);
}
/*
* This function determines whether or not it is safe to ignore verification
* errors, based on the ability of EVM to calculate HMACs. If the HMAC key
* is not loaded, and it cannot be loaded in the future due to the
* EVM_SETUP_COMPLETE initialization flag, allowing an operation despite the
* attrs/xattrs being found invalid will not make them valid.
*/
static bool evm_hmac_disabled(void)
{
if (evm_initialized & EVM_INIT_HMAC)
return false;
if (!(evm_initialized & EVM_SETUP_COMPLETE))
return false;
return true;
}
static bool evm_sigv3_required(void)
{
if (evm_initialized & EVM_SIGV3_REQUIRED)
return true;
return false;
}
static int evm_find_protected_xattrs(struct dentry *dentry)
{
struct inode *inode = d_backing_inode(dentry);
struct xattr_list *xattr;
int error;
int count = 0;
if (!(inode->i_opflags & IOP_XATTR))
return -EOPNOTSUPP;
list_for_each_entry_lockless(xattr, &evm_config_xattrnames, list) {
error = __vfs_getxattr(dentry, inode, xattr->name, NULL, 0);
if (error < 0) {
if (error == -ENODATA)
continue;
return error;
}
count++;
}
return count;
}
static int is_unsupported_hmac_fs(struct dentry *dentry)
{
struct inode *inode = d_backing_inode(dentry);
if (inode->i_sb->s_iflags & SB_I_EVM_HMAC_UNSUPPORTED) {
Annotation
- Immediate include surface: `linux/init.h`, `linux/audit.h`, `linux/xattr.h`, `linux/integrity.h`, `linux/evm.h`, `linux/magic.h`, `linux/posix_acl_xattr.h`, `linux/lsm_hooks.h`.
- Detected declarations: `function evm_set_fixmode`, `function evm_init_config`, `function evm_key_loaded`, `function evm_hmac_disabled`, `function evm_sigv3_required`, `function evm_find_protected_xattrs`, `function list_for_each_entry_lockless`, `function is_unsupported_hmac_fs`, `function evm_verify_hmac`, `function evm_protected_xattr_common`.
- Atlas domain: Core OS / Security And Isolation.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.