OSDN Git Service

exec: Move exec_mmap right after de_thread in flush_old_exec
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 25 Mar 2020 15:03:21 +0000 (10:03 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 25 Mar 2020 15:03:21 +0000 (10:03 -0500)
commitccf0fa6be02687868006fa0c85af32c40cae6fb6
treec38ce8b52b70a91f372669cb36a5c7e4374e8abb
parent153ffb6ba49fd80dc607a9f230415af02b728d70
exec: Move exec_mmap right after de_thread in flush_old_exec

I have read through the code in exec_mmap and I do not see anything
that depends on sighand or the sighand lock, or on signals in anyway
so this should be safe.

This rearrangement of code has two significant benefits.  It makes
the determination of passing the point of no return by testing bprm->mm
accurate.  All failures prior to that point in flush_old_exec are
either truly recoverable or they are fatal.

Further this consolidates all of the possible indefinite waits for
userspace together at the top of flush_old_exec.  The possible wait
for a ptracer on PTRACE_EVENT_EXIT, the possible wait for a page fault
to be resolved in clear_child_tid, and the possible wait for a page
fault in exit_robust_list.

This consolidation allows the creation of a mutex to replace
cred_guard_mutex that is not held over possible indefinite userspace
waits.  Which will allow removing deadlock scenarios from the kernel.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
fs/exec.c