Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9d81f61 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds
Browse files

ptrace: PTRACE_LISTEN forgets to unlock ->siglock



If PTRACE_LISTEN fails after lock_task_sighand() it doesn't drop ->siglock.

Reported-by: default avatarMatt Fleming <matt.fleming@intel.com>
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b172e38e
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -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;

		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 immediately.
			 * 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);

		unlock_task_sighand(child, &flags);
			ret = 0;
		}
		unlock_task_sighand(child, &flags);
		break;

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