Skip to content

Commit 5b4197c

Browse files
committed
ptrace: Always take siglock in ptrace_resume
Make code analysis simpler and future changes easier by always taking siglock in ptrace_resume. Tested-by: Kees Cook <[email protected]> Reviewed-by: Oleg Nesterov <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 2500ad1 commit 5b4197c

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

kernel/ptrace.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,6 @@ static long ptrace_get_rseq_configuration(struct task_struct *task,
837837
static int ptrace_resume(struct task_struct *child, long request,
838838
unsigned long data)
839839
{
840-
bool need_siglock;
841-
842840
if (!valid_signal(data))
843841
return -EIO;
844842

@@ -874,18 +872,11 @@ static int ptrace_resume(struct task_struct *child, long request,
874872
* Note that we need siglock even if ->exit_code == data and/or this
875873
* status was not reported yet, the new status must not be cleared by
876874
* wait_task_stopped() after resume.
877-
*
878-
* If data == 0 we do not care if wait_task_stopped() reports the old
879-
* status and clears the code too; this can't race with the tracee, it
880-
* takes siglock after resume.
881875
*/
882-
need_siglock = data && !thread_group_empty(current);
883-
if (need_siglock)
884-
spin_lock_irq(&child->sighand->siglock);
876+
spin_lock_irq(&child->sighand->siglock);
885877
child->exit_code = data;
886878
wake_up_state(child, __TASK_TRACED);
887-
if (need_siglock)
888-
spin_unlock_irq(&child->sighand->siglock);
879+
spin_unlock_irq(&child->sighand->siglock);
889880

890881
return 0;
891882
}

0 commit comments

Comments
 (0)