Commit 08701813 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Andrew Morton

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/20240122171631.GA29844@redhat.comSigned-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent d6bbab8f
...@@ -375,10 +375,13 @@ static int check_ptrace_options(unsigned long data) ...@@ -375,10 +375,13 @@ static int check_ptrace_options(unsigned long data)
return 0; return 0;
} }
static inline void ptrace_set_stopped(struct task_struct *task) static inline void ptrace_set_stopped(struct task_struct *task, bool seize)
{ {
guard(spinlock)(&task->sighand->siglock); guard(spinlock)(&task->sighand->siglock);
/* SEIZE doesn't trap tracee on attach */
if (!seize)
send_signal_locked(SIGSTOP, SEND_SIG_PRIV, task, PIDTYPE_PID);
/* /*
* If the task is already STOPPED, set JOBCTL_TRAP_STOP and * If the task is already STOPPED, set JOBCTL_TRAP_STOP and
* TRAPPING, and kick it so that it transits to TRACED. TRAPPING * 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, ...@@ -457,14 +460,8 @@ static int ptrace_attach(struct task_struct *task, long request,
return -EPERM; return -EPERM;
task->ptrace = flags; task->ptrace = flags;
ptrace_link(task, current); ptrace_link(task, current);
ptrace_set_stopped(task, seize);
/* SEIZE doesn't trap tracee on attach */
if (!seize)
send_sig_info(SIGSTOP, SEND_SIG_PRIV, task);
ptrace_set_stopped(task);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment