Commit 90aa9a75 authored by Linus Torvalds's avatar Linus Torvalds Committed by Greg Kroah-Hartman

Revert "exec: load_script: don't blindly truncate shebang string"

commit cb5b020a upstream.

This reverts commit 8099b047.

It turns out that people do actually depend on the shebang string being
truncated, and on the fact that an interpreter (like perl) will often
just re-interpret it entirely to get the full argument list.
Reported-by: Samuel Dionne-Riel's avatarSamuel Dionne-Riel <>
Acked-by: default avatarKees Cook <>
Cc: Oleg Nesterov <>
Signed-off-by: default avatarLinus Torvalds <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 03feb1ee
......@@ -42,14 +42,10 @@ static int load_script(struct linux_binprm *bprm)
bprm->file = NULL;
for (cp = bprm->buf+2;; cp++) {
if (cp >= bprm->buf + BINPRM_BUF_SIZE)
return -ENOEXEC;
if (!*cp || (*cp == '\n'))
bprm->buf[BINPRM_BUF_SIZE - 1] = '\0';
if ((cp = strchr(bprm->buf, '\n')) == NULL)
cp = bprm->buf+BINPRM_BUF_SIZE-1;
*cp = '\0';
while (cp > bprm->buf) {
if ((*cp == ' ') || (*cp == '\t'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment