security/loadpin/loadpin.c
Source file repositories/reference/linux-study-clean/security/loadpin/loadpin.c
File Facts
- System
- Linux kernel
- Corpus path
security/loadpin/loadpin.c- Extension
.c- Size
- 11026 bytes
- Lines
- 443
- Domain
- Core OS
- Bucket
- Security And Isolation
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/module.hlinux/fs.hlinux/hex.hlinux/kernel_read_file.hlinux/lsm_hooks.hlinux/mount.hlinux/blkdev.hlinux/path.hlinux/sched.hlinux/string_helpers.hlinux/dm-verity-loadpin.huapi/linux/loadpin.huapi/linux/lsm.h
Detected Declarations
enum loadpin_securityfs_interface_indexfunction report_loadfunction proc_handler_loadpinfunction report_writablefunction sb_is_writablefunction loadpin_sb_free_securityfunction loadpin_checkfunction loadpin_read_filefunction loadpin_load_datafunction parse_excludefunction loadpin_initfunction read_trusted_verity_root_digestsfunction list_for_each_entry_safefunction dm_verity_ioctlfunction loadpin_init
Annotated Snippet
static const struct file_operations loadpin_dm_verity_ops = {
.unlocked_ioctl = dm_verity_ioctl,
.compat_ioctl = compat_ptr_ioctl,
};
/**
* init_loadpin_securityfs - create the securityfs directory for LoadPin
*
* We can not put this method normally under the loadpin_init() code path since
* the security subsystem gets initialized before the vfs caches.
*
* Returns 0 if the securityfs directory creation was successful.
*/
static int __init init_loadpin_securityfs(void)
{
struct dentry *loadpin_dir, *dentry;
loadpin_dir = securityfs_create_dir("loadpin", NULL);
if (IS_ERR(loadpin_dir)) {
pr_err("LoadPin: could not create securityfs dir: %ld\n",
PTR_ERR(loadpin_dir));
return PTR_ERR(loadpin_dir);
}
dentry = securityfs_create_file("dm-verity", 0600, loadpin_dir,
(void *)LOADPIN_DM_VERITY, &loadpin_dm_verity_ops);
if (IS_ERR(dentry)) {
pr_err("LoadPin: could not create securityfs entry 'dm-verity': %ld\n",
PTR_ERR(dentry));
return PTR_ERR(dentry);
}
return 0;
}
#endif /* CONFIG_SECURITY_LOADPIN_VERITY */
DEFINE_LSM(loadpin) = {
.id = &loadpin_lsmid,
.init = loadpin_init,
#ifdef CONFIG_SECURITY_LOADPIN_VERITY
.initcall_fs = init_loadpin_securityfs,
#endif /* CONFIG_SECURITY_LOADPIN_VERITY */
};
/* Should not be mutable after boot, so not listed in sysfs (perm == 0). */
module_param(enforce, int, 0);
MODULE_PARM_DESC(enforce, "Enforce module/firmware pinning");
module_param_array_named(exclude, exclude_read_files, charp, NULL, 0);
MODULE_PARM_DESC(exclude, "Exclude pinning specific read file types");
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/hex.h`, `linux/kernel_read_file.h`, `linux/lsm_hooks.h`, `linux/mount.h`, `linux/blkdev.h`, `linux/path.h`.
- Detected declarations: `enum loadpin_securityfs_interface_index`, `function report_load`, `function proc_handler_loadpin`, `function report_writable`, `function sb_is_writable`, `function loadpin_sb_free_security`, `function loadpin_check`, `function loadpin_read_file`, `function loadpin_load_data`, `function parse_exclude`.
- Atlas domain: Core OS / Security And Isolation.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.