ptrace: Move setting/clearing ptrace_message into ptrace_stop
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 27 Jan 2022 18:15:32 +0000 (12:15 -0600)
committerEric W. Biederman <ebiederm@xmission.com>
Fri, 18 Mar 2022 14:44:19 +0000 (09:44 -0500)
commit336d4b814bf078fa698488632c19beca47308896
tree9e757560447836890ef250488bfc899e55da1423
parent355f841a3f8ca980c9682937a5257d3a1f6fc09d
ptrace: Move setting/clearing ptrace_message into ptrace_stop

Today ptrace_message is easy to overlook as it not a core part of
ptrace_stop.  It has been overlooked so much that there are places
that set ptrace_message and don't clear it, and places that never set
it.  So if you get an unlucky sequence of events the ptracer may be
able to read a ptrace_message that does not apply to the current
ptrace stop.

Move setting of ptrace_message into ptrace_stop so that it always gets
set before the stop, and always gets cleared after the stop.  This
prevents non-sense from being reported to userspace and makes
ptrace_message more visible in the ptrace helper functions so that
kernel developers can see it.

Link: https://lkml.kernel.org/r/87bky67qfv.fsf_-_@email.froward.int.ebiederm.org
Acked-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
include/linux/ptrace.h
include/uapi/linux/ptrace.h
kernel/signal.c