From: Oleg Nesterov <oleg@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linuxfoundation.org>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Jonathan Cameron <jic23@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Eric Biederman <ebiederm@xmission.com>
Subject: Re: [PATCH 2/2] ptrace: Convert ptrace_attach() to use lock guards
Date: Thu, 2 Nov 2023 16:17:24 +0100 [thread overview]
Message-ID: <20231102151723.GB9680@redhat.com> (raw)
In-Reply-To: <20231102110706.568467727@infradead.org>
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@redhat.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);
}
}
next prev parent reply other threads:[~2023-11-02 15:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-02 10:44 [PATCH 0/2] cleanup: Conditional locking support Peter Zijlstra
2023-11-02 10:44 ` [PATCH 1/2] cleanup: Add conditional guard support Peter Zijlstra
2023-11-02 14:40 ` Oleg Nesterov
2023-11-02 15:55 ` Oleg Nesterov
2023-11-03 9:30 ` Peter Zijlstra
2023-11-03 18:17 ` Linus Torvalds
2023-11-03 18:51 ` Oleg Nesterov
2023-11-02 10:44 ` [PATCH 2/2] ptrace: Convert ptrace_attach() to use lock guards Peter Zijlstra
2023-11-02 15:17 ` Oleg Nesterov [this message]
2023-11-02 15:34 ` [PATCH 0/2] cleanup: Conditional locking support Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231102151723.GB9680@redhat.com \
--to=oleg@redhat.com \
--cc=ebiederm@xmission.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linuxfoundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox