Skip to content

Commit

Permalink
apparmor: fix change_hat not finding hat after policy replacement
Browse files Browse the repository at this point in the history
commit 3d40658 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: 01e2b67 (failure to find hat)
Fixes: 898127c (stale policy being applied)
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1000287
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
  • Loading branch information
John Johansen authored and Jiri Slaby committed Dec 12, 2016
1 parent e525af5 commit 6d7bc8a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions security/apparmor/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest)
/* released below */
cred = get_current_cred();
cxt = cred_cxt(cred);
profile = aa_cred_profile(cred);
previous_profile = cxt->previous;
profile = aa_get_newest_profile(aa_cred_profile(cred));
previous_profile = aa_get_newest_profile(cxt->previous);

if (unconfined(profile)) {
info = "unconfined";
Expand Down Expand Up @@ -726,6 +726,8 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest)
out:
aa_put_profile(hat);
kfree(name);
aa_put_profile(profile);
aa_put_profile(previous_profile);
put_cred(cred);

return error;
Expand Down

0 comments on commit 6d7bc8a

Please sign in to comment.