Skip to content

Commit 4fbeceb

Browse files
ebiedermgregkh
authored andcommitted
signal: Remove the bogus sigkill_pending in ptrace_stop
commit 7d613f9 upstream. The existence of sigkill_pending is a little silly as it is functionally a duplicate of fatal_signal_pending that is used in exactly one place. Checking for pending fatal signals and returning early in ptrace_stop is actively harmful. It casues the ptrace_stop called by ptrace_signal to return early before setting current->exit_code. Later when ptrace_signal reads the signal number from current->exit_code is undefined, making it unpredictable what will happen. Instead rely on the fact that schedule will not sleep if there is a pending signal that can awaken a task. Removing the explict sigkill_pending test fixes fixes ptrace_signal when ptrace_stop does not stop because current->exit_code is always set to to signr. Cc: stable@vger.kernel.org Fixes: 3d749b9 ("ptrace: simplify ptrace_stop()->sigkill_pending() path") Fixes: 1a669c2 ("Add arch_ptrace_stop") Link: https://lkml.kernel.org/r/87pmsyx29t.fsf@disp2133 Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5c6fedc commit 4fbeceb

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

‎kernel/signal.c‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,15 +2097,6 @@ static inline bool may_ptrace_stop(void)
20972097
return true;
20982098
}
20992099

2100-
/*
2101-
* Return non-zero if there is a SIGKILL that should be waking us up.
2102-
* Called with the siglock held.
2103-
*/
2104-
static bool sigkill_pending(struct task_struct *tsk)
2105-
{
2106-
return sigismember(&tsk->pending.signal, SIGKILL) ||
2107-
sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
2108-
}
21092100

21102101
/*
21112102
* This must be called with current->sighand->siglock held.
@@ -2132,17 +2123,16 @@ static void ptrace_stop(int exit_code, int why, int clear_code, kernel_siginfo_t
21322123
* calling arch_ptrace_stop, so we must release it now.
21332124
* To preserve proper semantics, we must do this before
21342125
* any signal bookkeeping like checking group_stop_count.
2135-
* Meanwhile, a SIGKILL could come in before we retake the
2136-
* siglock. That must prevent us from sleeping in TASK_TRACED.
2137-
* So after regaining the lock, we must check for SIGKILL.
21382126
*/
21392127
spin_unlock_irq(&current->sighand->siglock);
21402128
arch_ptrace_stop(exit_code, info);
21412129
spin_lock_irq(&current->sighand->siglock);
2142-
if (sigkill_pending(current))
2143-
return;
21442130
}
21452131

2132+
/*
2133+
* schedule() will not sleep if there is a pending signal that
2134+
* can awaken the task.
2135+
*/
21462136
set_special_state(TASK_TRACED);
21472137

21482138
/*

0 commit comments

Comments
 (0)