Skip to content

Commit 7d613f9

Browse files
committed
signal: Remove the bogus sigkill_pending in ptrace_stop
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>
1 parent 6880fa6 commit 7d613f9

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
@@ -2182,15 +2182,6 @@ static inline bool may_ptrace_stop(void)
21822182
return true;
21832183
}
21842184

2185-
/*
2186-
* Return non-zero if there is a SIGKILL that should be waking us up.
2187-
* Called with the siglock held.
2188-
*/
2189-
static bool sigkill_pending(struct task_struct *tsk)
2190-
{
2191-
return sigismember(&tsk->pending.signal, SIGKILL) ||
2192-
sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
2193-
}
21942185

21952186
/*
21962187
* This must be called with current->sighand->siglock held.
@@ -2217,17 +2208,16 @@ static void ptrace_stop(int exit_code, int why, int clear_code, kernel_siginfo_t
22172208
* calling arch_ptrace_stop, so we must release it now.
22182209
* To preserve proper semantics, we must do this before
22192210
* any signal bookkeeping like checking group_stop_count.
2220-
* Meanwhile, a SIGKILL could come in before we retake the
2221-
* siglock. That must prevent us from sleeping in TASK_TRACED.
2222-
* So after regaining the lock, we must check for SIGKILL.
22232211
*/
22242212
spin_unlock_irq(&current->sighand->siglock);
22252213
arch_ptrace_stop(exit_code, info);
22262214
spin_lock_irq(&current->sighand->siglock);
2227-
if (sigkill_pending(current))
2228-
return;
22292215
}
22302216

2217+
/*
2218+
* schedule() will not sleep if there is a pending signal that
2219+
* can awaken the task.
2220+
*/
22312221
set_special_state(TASK_TRACED);
22322222

22332223
/*

0 commit comments

Comments
 (0)