security/apparmor/mount.c
Source file repositories/reference/linux-study-clean/security/apparmor/mount.c
File Facts
- System
- Linux kernel
- Corpus path
security/apparmor/mount.c- Extension
.c- Size
- 19776 bytes
- Lines
- 770
- Domain
- Core OS
- Bucket
- Security And Isolation
- 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
linux/fs.hlinux/mount.hlinux/namei.huapi/linux/mount.hinclude/apparmor.hinclude/audit.hinclude/cred.hinclude/domain.hinclude/file.hinclude/match.hinclude/mount.hinclude/path.hinclude/policy.h
Detected Declarations
function Copyrightfunction audit_cbfunction audit_mountfunction match_mnt_flagsfunction do_match_mntfunction path_flagsfunction match_mnt_path_strfunction match_mntfunction aa_remountfunction aa_bind_mountfunction aa_mount_change_typefunction aa_move_mountfunction aa_move_mount_oldfunction aa_new_mountfunction profile_umountfunction aa_umountfunction aa_pivotroot
Annotated Snippet
if (requires_dev) {
if (!dev_name || !*dev_name)
return -ENOENT;
error = kern_path(dev_name, LOOKUP_FOLLOW, &tmp_path);
if (error)
return error;
dev_path = &tmp_path;
}
}
buffer = aa_get_buffer(false);
if (!buffer) {
error = -ENOMEM;
goto out;
}
if (dev_path) {
dev_buffer = aa_get_buffer(false);
if (!dev_buffer) {
error = -ENOMEM;
goto out;
}
error = fn_for_each_confined(label, profile,
match_mnt(subj_cred, profile, path, buffer,
dev_path, dev_buffer,
type, flags, data, binary));
} else {
error = fn_for_each_confined(label, profile,
match_mnt_path_str(subj_cred, profile, path,
buffer, dev_name,
type, flags, data, binary, NULL));
}
out:
aa_put_buffer(buffer);
aa_put_buffer(dev_buffer);
if (dev_path)
path_put(dev_path);
return error;
}
static int profile_umount(const struct cred *subj_cred,
struct aa_profile *profile, const struct path *path,
char *buffer)
{
struct aa_ruleset *rules = profile->label.rules[0];
struct aa_perms perms = { };
const char *name = NULL, *info = NULL;
aa_state_t state;
int error;
AA_BUG(!profile);
AA_BUG(!path);
if (!RULE_MEDIATES(rules, AA_CLASS_MOUNT))
return 0;
error = aa_path_name(path, path_flags(profile, path), buffer, &name,
&info, profile->disconnected);
if (error)
goto audit;
state = aa_dfa_match(rules->policy->dfa,
rules->policy->start[AA_CLASS_MOUNT],
name);
perms = *aa_lookup_perms(rules->policy, state);
if (AA_MAY_UMOUNT & ~perms.allow)
error = -EACCES;
audit:
return audit_mount(subj_cred, profile, OP_UMOUNT, name, NULL, NULL,
NULL, 0, NULL,
AA_MAY_UMOUNT, &perms, info, error);
}
int aa_umount(const struct cred *subj_cred, struct aa_label *label,
struct vfsmount *mnt, int flags)
{
struct aa_profile *profile;
char *buffer = NULL;
int error;
struct path path = { .mnt = mnt, .dentry = mnt->mnt_root };
AA_BUG(!label);
AA_BUG(!mnt);
buffer = aa_get_buffer(false);
if (!buffer)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/fs.h`, `linux/mount.h`, `linux/namei.h`, `uapi/linux/mount.h`, `include/apparmor.h`, `include/audit.h`, `include/cred.h`, `include/domain.h`.
- Detected declarations: `function Copyright`, `function audit_cb`, `function audit_mount`, `function match_mnt_flags`, `function do_match_mnt`, `function path_flags`, `function match_mnt_path_str`, `function match_mnt`, `function aa_remount`, `function aa_bind_mount`.
- Atlas domain: Core OS / Security And Isolation.
- 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.