Skip to content

Commit

Permalink
apparmor: don't try to replace stale label in ptraceme check
Browse files Browse the repository at this point in the history
begin_current_label_crit_section() must run in sleepable context because
when label_is_stale() is true, aa_replace_current_label() runs, which uses
prepare_creds(), which can sleep.

Until now, the ptraceme access check (which runs with tasklist_lock held)
violated this rule.

Fixes: b2d09ae ("apparmor: move ptrace checks to using labels")
Reported-by: Cyrill Gorcunov <[email protected]>
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Jann Horn <[email protected]>
Signed-off-by: John Johansen <[email protected]>
  • Loading branch information
thejh authored and John Johansen committed Oct 3, 2018
1 parent 0fb871c commit ca3fde5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions security/apparmor/lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ static int apparmor_ptrace_traceme(struct task_struct *parent)
struct aa_label *tracer, *tracee;
int error;

tracee = begin_current_label_crit_section();
tracee = __begin_current_label_crit_section();
tracer = aa_get_task_label(parent);
error = aa_may_ptrace(tracer, tracee, AA_PTRACE_TRACE);
aa_put_label(tracer);
end_current_label_crit_section(tracee);
__end_current_label_crit_section(tracee);

return error;
}
Expand Down

0 comments on commit ca3fde5

Please sign in to comment.