apparmor: free rawdata as soon as possible

profiles can be pinned by file and other references, and can live long
after they have been replaced/removed. The rawdata however is no longer
needed, and can be freed earlier than the rest of the profile.

Reviewed-by: Georgia Garcia <georgia.garcia@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen 2026-03-01 12:29:06 -08:00
parent 32e92764d6
commit b9b864fc72

View File

@ -232,6 +232,13 @@ static void __remove_profile(struct aa_profile *profile)
aa_label_remove(&profile->label);
__aafs_profile_rmdir(profile);
__list_remove_profile(profile);
/* rawdata is only ever referenced by fs lookup, that is no
* longer possible here, so put the reference to it. This will
* enable the rawdata to be freed if for some reason the profile
* is pinned and going to live for a while.
*/
aa_put_profile_loaddata(profile->rawdata);
profile->rawdata = NULL;
}
/**