Skip to content

Commit 0870181

Browse files
oleg-nesterovakpm00
authored andcommitted
ptrace_attach: shift send(SIGSTOP) into ptrace_set_stopped()
Turn send_sig_info(SIGSTOP) into send_signal_locked(SIGSTOP) and move it from ptrace_attach() to ptrace_set_stopped(). This looks more logical and avoids lock(siglock) right after unlock(). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent d6bbab8 commit 0870181

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

kernel/ptrace.c

+5-8
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,13 @@ static int check_ptrace_options(unsigned long data)
375375
return 0;
376376
}
377377

378-
static inline void ptrace_set_stopped(struct task_struct *task)
378+
static inline void ptrace_set_stopped(struct task_struct *task, bool seize)
379379
{
380380
guard(spinlock)(&task->sighand->siglock);
381381

382+
/* SEIZE doesn't trap tracee on attach */
383+
if (!seize)
384+
send_signal_locked(SIGSTOP, SEND_SIG_PRIV, task, PIDTYPE_PID);
382385
/*
383386
* If the task is already STOPPED, set JOBCTL_TRAP_STOP and
384387
* TRAPPING, and kick it so that it transits to TRACED. TRAPPING
@@ -457,14 +460,8 @@ static int ptrace_attach(struct task_struct *task, long request,
457460
return -EPERM;
458461

459462
task->ptrace = flags;
460-
461463
ptrace_link(task, current);
462-
463-
/* SEIZE doesn't trap tracee on attach */
464-
if (!seize)
465-
send_sig_info(SIGSTOP, SEND_SIG_PRIV, task);
466-
467-
ptrace_set_stopped(task);
464+
ptrace_set_stopped(task, seize);
468465
}
469466
}
470467

0 commit comments

Comments
 (0)