Skip to content

Commit 3d40658

Browse files
jrjohansenJames Morris
authored andcommitted
apparmor: fix change_hat not finding hat after policy replacement
After a policy replacement, the task cred may be out of date and need to be updated. However change_hat is using the stale profiles from the out of date cred resulting in either: a stale profile being applied or, incorrect failure when searching for a hat profile as it has been migrated to the new parent profile. Fixes: 01e2b67 (failure to find hat) Fixes: 898127c (stale policy being applied) Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1000287 Cc: stable@vger.kernel.org Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: James Morris <james.l.morris@oracle.com>
1 parent 9c76358 commit 3d40658

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎security/apparmor/domain.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest)
621621
/* released below */
622622
cred = get_current_cred();
623623
cxt = cred_cxt(cred);
624-
profile = aa_cred_profile(cred);
625-
previous_profile = cxt->previous;
624+
profile = aa_get_newest_profile(aa_cred_profile(cred));
625+
previous_profile = aa_get_newest_profile(cxt->previous);
626626

627627
if (unconfined(profile)) {
628628
info = "unconfined";
@@ -718,6 +718,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest)
718718
out:
719719
aa_put_profile(hat);
720720
kfree(name);
721+
aa_put_profile(profile);
722+
aa_put_profile(previous_profile);
721723
put_cred(cred);
722724

723725
return error;

0 commit comments

Comments
 (0)