Linux/linux b5372fefs binfmt_script.c

exec: load_script: Do not exec truncated interpreter path

Commit 8099b047ecc4 ("exec: load_script: don't blindly truncate
shebang string") was trying to protect against a confused exec of a
truncated interpreter path. However, it was overeager and also refused
to truncate arguments as well, which broke userspace, and it was
reverted. This attempts the protection again, but allows arguments to
remain truncated. In an effort to improve readability, helper functions
and comments have been added.

Co-developed-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Kees Cook <keescook at chromium.org>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: Oleg Nesterov <oleg at redhat.com>
Cc: Samuel Dionne-Riel <samuel at dionne-riel.com>
Cc: Richard Weinberger <richard.weinberger at gmail.com>
Cc: Graham Christensen <graham at grahamc.com>
Cc: Michal Hocko <mhocko at suse.com>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
DeltaFile
+48-9fs/binfmt_script.c
+48-91 files

UnifiedSplitRaw