Commit be79d7fa authored by John Johansen's avatar John Johansen Committed by Greg Kroah-Hartman

apparmor: fix change_hat not finding hat after policy replacement

commit 3d40658c upstream.

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: 01e2b670 (failure to find hat)
Fixes: 898127c3 (stale policy being applied)
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1000287Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Signed-off-by: default avatarJames Morris <james.l.morris@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8316338a
...@@ -623,8 +623,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest) ...@@ -623,8 +623,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest)
/* released below */ /* released below */
cred = get_current_cred(); cred = get_current_cred();
cxt = cred_cxt(cred); cxt = cred_cxt(cred);
profile = aa_cred_profile(cred); profile = aa_get_newest_profile(aa_cred_profile(cred));
previous_profile = cxt->previous; previous_profile = aa_get_newest_profile(cxt->previous);
if (unconfined(profile)) { if (unconfined(profile)) {
info = "unconfined"; info = "unconfined";
...@@ -720,6 +720,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest) ...@@ -720,6 +720,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest)
out: out:
aa_put_profile(hat); aa_put_profile(hat);
kfree(name); kfree(name);
aa_put_profile(profile);
aa_put_profile(previous_profile);
put_cred(cred); put_cred(cred);
return error; return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment