Skip to content

Commit

Permalink
ptrace: PTRACE_LISTEN forgets to unlock ->siglock
Browse files Browse the repository at this point in the history
If PTRACE_LISTEN fails after lock_task_sighand() it doesn't drop ->siglock.

Reported-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
oleg-nesterov authored and torvalds committed Sep 25, 2011
1 parent b172e38 commit f9d81f6
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,20 +744,17 @@ int ptrace_request(struct task_struct *child, long request,
break;

si = child->last_siginfo;
if (unlikely(!si || si->si_code >> 8 != PTRACE_EVENT_STOP))
break;

child->jobctl |= JOBCTL_LISTENING;

/*
* If NOTIFY is set, it means event happened between start
* of this trap and now. Trigger re-trap immediately.
*/
if (child->jobctl & JOBCTL_TRAP_NOTIFY)
signal_wake_up(child, true);

if (likely(si && (si->si_code >> 8) == PTRACE_EVENT_STOP)) {
child->jobctl |= JOBCTL_LISTENING;
/*
* If NOTIFY is set, it means event happened between
* start of this trap and now. Trigger re-trap.
*/
if (child->jobctl & JOBCTL_TRAP_NOTIFY)
signal_wake_up(child, true);
ret = 0;
}
unlock_task_sighand(child, &flags);
ret = 0;
break;

case PTRACE_DETACH: /* detach a process that was attached. */
Expand Down

0 comments on commit f9d81f6

Please sign in to comment.