[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202203171210.1239C9CDA@keescook>
Date: Thu, 17 Mar 2022 12:13:09 -0700
From: Kees Cook <keescook@...omium.org>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: linux-kernel@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Alexey Gladkov <legion@...nel.org>,
Kyle Huey <me@...ehuey.com>, Oleg Nesterov <oleg@...hat.com>,
Al Viro <viro@...iv.linux.org.uk>, linux-api@...r.kernel.org,
Jens Axboe <axboe@...nel.dk>
Subject: Re: [PATCH 2/2] ptrace: Return the signal to continue with from
ptrace_stop
On Tue, Mar 15, 2022 at 06:22:26PM -0500, Eric W. Biederman wrote:
>
> The signal a task should continue with after a ptrace stop is
> inconsistently read, cleared, and sent. Solve this by reading and
> clearing the signal to be sent in ptrace_stop.
>
> In an ideal world everything except ptrace_signal would share a common
> implementation of continuing with the signal, so ptracers could count
> on the signal they ask to continue with actually being delivered. For
> now retain bug compatibility and just return with the signal number
> the ptracer requested the code continue with.
>
> Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.com>
> ---
> include/linux/ptrace.h | 12 ++++++------
> kernel/signal.c | 31 ++++++++++++++++++-------------
> 2 files changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
> index 3e6b46e2b7be..15b3d176b6b4 100644
> --- a/include/linux/ptrace.h
> +++ b/include/linux/ptrace.h
> @@ -60,7 +60,7 @@ extern int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned
> extern void ptrace_disable(struct task_struct *);
> extern int ptrace_request(struct task_struct *child, long request,
> unsigned long addr, unsigned long data);
> -extern void ptrace_notify(int exit_code, unsigned long message);
> +extern int ptrace_notify(int exit_code, unsigned long message);
> [...]
> -static void ptrace_stop(int exit_code, int why, int clear_code,
> +static int ptrace_stop(int exit_code, int why, int clear_code,
> unsigned long message, kernel_siginfo_t *info)
> [...]
> -static void ptrace_do_notify(int signr, int exit_code, int why, unsigned long message)
> +static int ptrace_do_notify(int signr, int exit_code, int why, unsigned long message)
> [...]
> -void ptrace_notify(int exit_code, unsigned long message)
> +int ptrace_notify(int exit_code, unsigned long message)
Just for robustness, how about marking the functions that have switched
from void to int return as __must_check (or at least just ptrace_notify)?
With that and the style nit Oleg already mentioned, yeah, this looks
good too.
Reviewed-by: Kees Cook <keescook@...omium.org>
--
Kees Cook
Powered by blists - more mailing lists