* [PATCH] ptrace_attach: shift send(SIGSTOP) into ptrace_set_stopped()
@ 2024-01-22 17:16 Oleg Nesterov
0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2024-01-22 17:16 UTC (permalink / raw)
To: Andrew Morton; +Cc: Eric W. Biederman, linux-kernel
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().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/ptrace.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 2fabd497d659..d5f89f9ef29f 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -375,10 +375,13 @@ static int check_ptrace_options(unsigned long data)
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);
+ /* 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
* 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,
return -EPERM;
task->ptrace = flags;
-
ptrace_link(task, current);
-
- /* SEIZE doesn't trap tracee on attach */
- if (!seize)
- send_sig_info(SIGSTOP, SEND_SIG_PRIV, task);
-
- ptrace_set_stopped(task);
+ ptrace_set_stopped(task, seize);
}
}
--
2.25.1.362.g51ebf55
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-22 17:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22 17:16 [PATCH] ptrace_attach: shift send(SIGSTOP) into ptrace_set_stopped() Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox