mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 15:27:29 +00:00
apparmor: use common fn to clear task_context for domain transitions
Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Steve Beattie <sbeattie@ubuntu.com>
This commit is contained in:
parent
0ca554b9fc
commit
7a2871b566
3 changed files with 20 additions and 16 deletions
|
@ -105,16 +105,12 @@ int aa_replace_current_profile(struct aa_profile *profile)
|
|||
return -ENOMEM;
|
||||
|
||||
cxt = new->security;
|
||||
if (unconfined(profile) || (cxt->profile->ns != profile->ns)) {
|
||||
if (unconfined(profile) || (cxt->profile->ns != profile->ns))
|
||||
/* if switching to unconfined or a different profile namespace
|
||||
* clear out context state
|
||||
*/
|
||||
aa_put_profile(cxt->previous);
|
||||
aa_put_profile(cxt->onexec);
|
||||
cxt->previous = NULL;
|
||||
cxt->onexec = NULL;
|
||||
cxt->token = 0;
|
||||
}
|
||||
aa_clear_task_cxt_trans(cxt);
|
||||
|
||||
/* be careful switching cxt->profile, when racing replacement it
|
||||
* is possible that cxt->profile->replacedby is the reference keeping
|
||||
* @profile valid, so make sure to get its reference before dropping
|
||||
|
@ -222,11 +218,10 @@ int aa_restore_previous_profile(u64 token)
|
|||
aa_get_profile(cxt->profile);
|
||||
aa_put_profile(cxt->previous);
|
||||
}
|
||||
/* clear exec && prev information when restoring to previous context */
|
||||
/* ref has been transfered so avoid putting ref in clear_task_cxt */
|
||||
cxt->previous = NULL;
|
||||
cxt->token = 0;
|
||||
aa_put_profile(cxt->onexec);
|
||||
cxt->onexec = NULL;
|
||||
/* clear exec && prev information when restoring to previous context */
|
||||
aa_clear_task_cxt_trans(cxt);
|
||||
|
||||
commit_creds(new);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue