aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2020-05-13 22:25:20 -0500
committerEric W. Biederman <ebiederm@xmission.com>2020-05-21 10:16:57 -0500
commit8b72ca9004ed35104deb80b07990da5503bc5252 (patch)
tree302fcaec6e95e41a23ca31981e693dbcfd58af3f /fs/exec.c
parenta16b3357b2b8e910bb614254d8a7e84d2bd59b4c (diff)
downloadlinux-8b72ca9004ed35104deb80b07990da5503bc5252.tar.gz
exec: Move the call of prepare_binprm into search_binary_handler
The code in prepare_binary_handler needs to be run every time search_binary_handler is called so move the call into search_binary_handler itself to make the code simpler and easier to understand. Link: https://lkml.kernel.org/r/87d070zrvx.fsf_-_@x220.int.ebiederm.org Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: James Morris <jamorris@linux.microsoft.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 028e0e323af53..5fc458460e443 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1629,7 +1629,7 @@ static void bprm_fill_uid(struct linux_binprm *bprm)
*
* This may be called multiple times for binary chains (scripts for example).
*/
-int prepare_binprm(struct linux_binprm *bprm)
+static int prepare_binprm(struct linux_binprm *bprm)
{
loff_t pos = 0;
@@ -1650,8 +1650,6 @@ int prepare_binprm(struct linux_binprm *bprm)
return kernel_read(bprm->file, bprm->buf, BINPRM_BUF_SIZE, &pos);
}
-EXPORT_SYMBOL(prepare_binprm);
-
/*
* Arguments are '\0' separated strings found at the location bprm->p
* points to; chop off the first by relocating brpm->p to right after
@@ -1707,6 +1705,10 @@ int search_binary_handler(struct linux_binprm *bprm)
if (bprm->recursion_depth > 5)
return -ELOOP;
+ retval = prepare_binprm(bprm);
+ if (retval < 0)
+ return retval;
+
retval = security_bprm_check(bprm);
if (retval)
return retval;
@@ -1864,10 +1866,6 @@ static int __do_execve_file(int fd, struct filename *filename,
if (retval)
goto out;
- retval = prepare_binprm(bprm);
- if (retval < 0)
- goto out;
-
retval = copy_strings_kernel(1, &bprm->filename, bprm);
if (retval < 0)
goto out;