security/apparmor/policy.c
Source file repositories/reference/linux-study-clean/security/apparmor/policy.c
File Facts
- System
- Linux kernel
- Corpus path
security/apparmor/policy.c- Extension
.c- Size
- 40608 bytes
- Lines
- 1493
- 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.
- 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/slab.hlinux/spinlock.hlinux/string.hlinux/cred.hlinux/rculist.hlinux/user_namespace.hinclude/apparmor.hinclude/capability.hinclude/cred.hinclude/file.hinclude/ipc.hinclude/match.hinclude/path.hinclude/policy.hinclude/policy_ns.hinclude/policy_unpack.hinclude/resource.h
Detected Declarations
function aa_destroy_tagsfunction aa_free_pdbfunction aa_pdb_free_kreffunction __add_profilefunction __list_remove_profilefunction __remove_profilefunction __aa_profile_list_releasefunction aa_free_datafunction free_attachmentfunction free_rulesetfunction aa_free_profilefunction ANY_RULE_MEDIATESfunction aa_compute_profile_mediatesfunction replacement_allowedfunction audit_cbfunction audit_policyfunction policy_ns_capablefunction aa_policy_view_capablefunction aa_policy_admin_capablefunction aa_current_policy_view_capablefunction aa_current_policy_admin_capablefunction is_subset_of_obj_privilegefunction aa_may_manage_policyfunction list_for_each_entryfunction __replace_profilefunction list_for_each_entry_safefunction __lookup_replacefunction share_namefunction aa_replace_profilesfunction list_for_each_entryfunction aa_remove_profiles
Annotated Snippet
while (curr != profile) {
while (!list_empty(&curr->base.profiles))
curr = list_first_entry(&curr->base.profiles,
struct aa_profile, base.list);
to_remove = curr;
if (!list_is_last(&to_remove->base.list,
&aa_deref_parent(curr)->base.profiles))
curr = list_next_entry(to_remove, base.list);
else
curr = aa_deref_parent(curr);
/* released by free_profile */
aa_label_remove(&to_remove->label);
__aafs_profile_rmdir(to_remove);
__list_remove_profile(to_remove);
}
}
/* released by free_profile */
aa_label_remove(&profile->label);
__aafs_profile_rmdir(profile);
__list_remove_profile(profile);
}
/**
* __aa_profile_list_release - remove all profiles on the list and put refs
* @head: list of profiles (NOT NULL)
*
* Requires: namespace lock be held
*/
void __aa_profile_list_release(struct list_head *head)
{
struct aa_profile *profile, *tmp;
list_for_each_entry_safe(profile, tmp, head, base.list)
__remove_profile(profile);
}
/**
* aa_free_data - free a data blob
* @ptr: data to free
* @arg: unused
*/
static void aa_free_data(void *ptr, void *arg)
{
struct aa_data *data = ptr;
if (!ptr)
return;
kvfree_sensitive(data->data, data->size);
kfree_sensitive(data->key);
kfree_sensitive(data);
}
static void free_attachment(struct aa_attachment *attach)
{
int i;
if (!attach)
return;
for (i = 0; i < attach->xattr_count; i++)
kfree_sensitive(attach->xattrs[i]);
kfree_sensitive(attach->xattrs);
aa_put_pdb(attach->xmatch);
}
static void free_ruleset(struct aa_ruleset *rules)
{
int i;
if (!rules)
return;
aa_put_pdb(rules->file);
aa_put_pdb(rules->policy);
aa_free_cap_rules(&rules->caps);
aa_free_rlimit_rules(&rules->rlimits);
for (i = 0; i < rules->secmark_count; i++)
kfree_sensitive(rules->secmark[i].label);
kfree_sensitive(rules->secmark);
kfree_sensitive(rules);
}
struct aa_ruleset *aa_alloc_ruleset(gfp_t gfp)
{
struct aa_ruleset *rules;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/spinlock.h`, `linux/string.h`, `linux/cred.h`, `linux/rculist.h`, `linux/user_namespace.h`, `include/apparmor.h`, `include/capability.h`.
- Detected declarations: `function aa_destroy_tags`, `function aa_free_pdb`, `function aa_pdb_free_kref`, `function __add_profile`, `function __list_remove_profile`, `function __remove_profile`, `function __aa_profile_list_release`, `function aa_free_data`, `function free_attachment`, `function free_ruleset`.
- Atlas domain: Core OS / Security And Isolation.
- Implementation status: source 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.