aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2016-09-01 00:10:06 -0400
committerJames Morris <james.l.morris@oracle.com>2016-11-21 02:01:28 -0500
commit3d40658c977769ce2138f286cf131537bf68bdfe (patch)
treea4413e2582ba4d840edb2e21e030e85d679f1b67
parent9c763584b7c8911106bb77af7e648bef09af9d80 (diff)
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: 01e2b670aa898a39259bc85c78e3d74820f4d3b6 (failure to find hat) Fixes: 898127c34ec03291c86f4ff3856d79e9e18952bc (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>
-rw-r--r--security/apparmor/domain.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
index fc3036b34e51..a4d90aa1045a 100644
--- a/security/apparmor/domain.c
+++ b/security/apparmor/domain.c
@@ -621,8 +621,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest)
621 /* released below */ 621 /* released below */
622 cred = get_current_cred(); 622 cred = get_current_cred();
623 cxt = cred_cxt(cred); 623 cxt = cred_cxt(cred);
624 profile = aa_cred_profile(cred); 624 profile = aa_get_newest_profile(aa_cred_profile(cred));
625 previous_profile = cxt->previous; 625 previous_profile = aa_get_newest_profile(cxt->previous);
626 626
627 if (unconfined(profile)) { 627 if (unconfined(profile)) {
628 info = "unconfined"; 628 info = "unconfined";
@@ -718,6 +718,8 @@ audit:
718out: 718out:
719 aa_put_profile(hat); 719 aa_put_profile(hat);
720 kfree(name); 720 kfree(name);
721 aa_put_profile(profile);
722 aa_put_profile(previous_profile);
721 put_cred(cred); 723 put_cred(cred);
722 724
723 return error; 725 return error;