@@ -35,9 +35,6 @@ static int load_binary(struct linux_binprm *bprm)
bprm->file = file;
bprm->loader = loader;
- retval = prepare_binprm(bprm);
- if (retval < 0)
- return retval;
return 1; /* Search for the interpreter */
}
@@ -90,11 +90,6 @@ static int load_em86(struct linux_binprm *bprm)
return PTR_ERR(file);
bprm->file = file;
-
- retval = prepare_binprm(bprm);
- if (retval < 0)
- return retval;
-
return 1; /* Search for the interpreter */
}
@@ -221,10 +221,6 @@ static int load_misc_binary(struct linux_binprm *bprm)
if (fmt->flags & MISC_FMT_CREDENTIALS)
bprm->preserve_creds = 1;
- retval = prepare_binprm(bprm);
- if (retval < 0)
- goto error;
-
retval = 1; /* Search for the interpreter */
ret:
dput(fmt->dentry);
@@ -143,9 +143,6 @@ static int load_script(struct linux_binprm *bprm)
return PTR_ERR(file);
bprm->file = file;
- retval = prepare_binprm(bprm);
- if (retval < 0)
- return retval;
return 1; /* Search for the interpreter */
}
@@ -1628,7 +1628,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;
@@ -1647,8 +1647,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
@@ -1700,6 +1698,10 @@ static int search_binary_handler(struct linux_binprm *bprm)
struct linux_binfmt *fmt;
int retval;
+ retval = prepare_binprm(bprm);
+ if (retval < 0)
+ return retval;
+
retval = security_bprm_check(bprm);
if (retval)
return retval;
@@ -1859,10 +1861,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;
@@ -117,7 +117,6 @@ static inline void insert_binfmt(struct linux_binfmt *fmt)
extern void unregister_binfmt(struct linux_binfmt *);
-extern int prepare_binprm(struct linux_binprm *);
extern int __must_check remove_arg_zero(struct linux_binprm *);
extern int begin_new_exec(struct linux_binprm * bprm);
extern void setup_new_exec(struct linux_binprm * bprm);
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. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> --- arch/alpha/kernel/binfmt_loader.c | 3 --- fs/binfmt_em86.c | 5 ----- fs/binfmt_misc.c | 4 ---- fs/binfmt_script.c | 3 --- fs/exec.c | 12 +++++------- include/linux/binfmts.h | 1 - 6 files changed, 5 insertions(+), 23 deletions(-)