diff options
| author | John Johansen <john.johansen@canonical.com> | 2026-10-29 08:13:55 -0700 |
|---|---|---|
| committer | John Johansen <john.johansen@canonical.com> | 2026-10-29 10:40:00 -0700 |
| commit | 97ba44a2aa4c7ab011a93ce94cb595200fe4ea4f (patch) | |
| tree | 8a4bdfc5b6beab9475860e464a6384a332a37927 | |
| parent | 6ec46f8f1977d218bf2494ce276152b2d01424af (diff) | |
apparmor: on failed load ensure profile files are removed before parent
The load interface does not guarantee the order profiles are loaded.
When a parent is loaded after its child, and the load fails, the
current code will issue a warning, and leak a dentry.
For the loaded set of profiles, ensure that on failure list is ordered
is traversed in reverse so any children processed after their parent
is freed first. We do not need to deal with the cases where the
children are processed before their parent, because either a parent
outside the list already exists or a dummy parent outside of the list
is created, and the list walk will not put those parents before their
children.
Fixes: 6ec46f8f1977d ("apparmor: remove fs entries created by a failed policy load")
Signed-off-by: John Johansen <john.johansen@canonical.com>
| -rw-r--r-- | security/apparmor/policy.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c index f6f7cdcb6212..bfe969b86957 100644 --- a/security/apparmor/policy.c +++ b/security/apparmor/policy.c @@ -1432,8 +1432,10 @@ fail_lock: * them yet, and leaving them behind would leak the new profiles * (their dents pin the proxy) and make the next load at the same, * unbumped ns revision fail with -EEXIST on its raw_data dir. + * ensure children (which are at the end of the list are removed + * before their parent */ - list_for_each_entry(tmp, &lh, list) { + list_for_each_entry_reverse(tmp, &lh, list) { if (!tmp->old) __aafs_profile_rmdir(tmp->new); } |
