]> git.baikalelectronics.ru Git - kernel.git/commit
exec: Move would_dump into flush_old_exec
authorEric W. Biederman <ebiederm@xmission.com>
Sat, 16 May 2020 21:29:20 +0000 (16:29 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Sun, 17 May 2020 15:48:24 +0000 (10:48 -0500)
commit553dc72bb98ca5e0a2010fb330702cfd226f2d69
treeec4f5055c1e068be108d1f00d7e4125d8e5a1288
parenta3c98f842c1888b4df27e091ed5a315b6f7c1aa9
exec: Move would_dump into flush_old_exec

I goofed when I added mm->user_ns support to would_dump.  I missed the
fact that in the case of binfmt_loader, binfmt_em86, binfmt_misc, and
binfmt_script bprm->file is reassigned.  Which made the move of
would_dump from setup_new_exec to __do_execve_file before exec_binprm
incorrect as it can result in would_dump running on the script instead
of the interpreter of the script.

The net result is that the code stopped making unreadable interpreters
undumpable.  Which allows them to be ptraced and written to disk
without special permissions.  Oops.

The move was necessary because the call in set_new_exec was after
bprm->mm was no longer valid.

To correct this mistake move the misplaced would_dump from
__do_execve_file into flos_old_exec, before exec_mmap is called.

I tested and confirmed that without this fix I can attach with gdb to
a script with an unreadable interpreter, and with this fix I can not.

Cc: stable@vger.kernel.org
Fixes: 4f8177954708 ("exec: Ensure mm->user_ns contains the execed files")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
fs/exec.c