[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231102151723.GB9680@redhat.com>
Date: Thu, 2 Nov 2023 16:17:24 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Linus Torvalds <torvalds@...uxfoundation.org>, x86@...nel.org,
linux-kernel@...r.kernel.org, Jonathan Cameron <jic23@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Eric Biederman <ebiederm@...ssion.com>
Subject: Re: [PATCH 2/2] ptrace: Convert ptrace_attach() to use lock guards
On 11/02, Peter Zijlstra wrote:
>
> Created as testing for the conditional guard infrastructure.
This patch scares me ;) I need to get used to guard/etc.
But looks correct.
Reviewed-by: Oleg Nesterov <oleg@...hat.com>
> + /* SEIZE doesn't trap tracee on attach */
> + if (!seize)
> + send_sig_info(SIGSTOP, SEND_SIG_PRIV, task);
This is offtopic, but with or without this patch it is a bit
ugly to drop ->siglock and take it again right after that.
We can do (later) a minor cleanup on top of this change.
--- x/kernel/ptrace.c 2023-11-02 16:03:37.646838530 +0100
+++ x/kernel/ptrace.c 2023-11-02 16:05:52.171052506 +0100
@@ -386,10 +386,14 @@
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
@@ -470,11 +474,6 @@
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);
}
}
Powered by blists - more mailing lists