Commit c69bcc93 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

fs/binfmt_elf.c: delete "loc" variable

"loc" variable became just a wrapper for PT_INTERP ELF header after main
ELF header was moved to "bprm->buf".  Delete it.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20200219184847.GA4871@avx2Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent efcdd350
...@@ -699,15 +699,13 @@ static int load_elf_binary(struct linux_binprm *bprm) ...@@ -699,15 +699,13 @@ static int load_elf_binary(struct linux_binprm *bprm)
unsigned long reloc_func_desc __maybe_unused = 0; unsigned long reloc_func_desc __maybe_unused = 0;
int executable_stack = EXSTACK_DEFAULT; int executable_stack = EXSTACK_DEFAULT;
struct elfhdr *elf_ex = (struct elfhdr *)bprm->buf; struct elfhdr *elf_ex = (struct elfhdr *)bprm->buf;
struct { struct elfhdr *interp_elf_ex;
struct elfhdr interp_elf_ex;
} *loc;
struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE; struct arch_elf_state arch_state = INIT_ARCH_ELF_STATE;
struct mm_struct *mm; struct mm_struct *mm;
struct pt_regs *regs; struct pt_regs *regs;
loc = kmalloc(sizeof(*loc), GFP_KERNEL); interp_elf_ex = kmalloc(sizeof(*interp_elf_ex), GFP_KERNEL);
if (!loc) { if (!interp_elf_ex) {
retval = -ENOMEM; retval = -ENOMEM;
goto out_ret; goto out_ret;
} }
...@@ -772,8 +770,8 @@ static int load_elf_binary(struct linux_binprm *bprm) ...@@ -772,8 +770,8 @@ static int load_elf_binary(struct linux_binprm *bprm)
would_dump(bprm, interpreter); would_dump(bprm, interpreter);
/* Get the exec headers */ /* Get the exec headers */
retval = elf_read(interpreter, &loc->interp_elf_ex, retval = elf_read(interpreter, interp_elf_ex,
sizeof(loc->interp_elf_ex), 0); sizeof(*interp_elf_ex), 0);
if (retval < 0) if (retval < 0)
goto out_free_dentry; goto out_free_dentry;
...@@ -807,25 +805,25 @@ static int load_elf_binary(struct linux_binprm *bprm) ...@@ -807,25 +805,25 @@ static int load_elf_binary(struct linux_binprm *bprm)
if (interpreter) { if (interpreter) {
retval = -ELIBBAD; retval = -ELIBBAD;
/* Not an ELF interpreter */ /* Not an ELF interpreter */
if (memcmp(loc->interp_elf_ex.e_ident, ELFMAG, SELFMAG) != 0) if (memcmp(interp_elf_ex->e_ident, ELFMAG, SELFMAG) != 0)
goto out_free_dentry; goto out_free_dentry;
/* Verify the interpreter has a valid arch */ /* Verify the interpreter has a valid arch */
if (!elf_check_arch(&loc->interp_elf_ex) || if (!elf_check_arch(interp_elf_ex) ||
elf_check_fdpic(&loc->interp_elf_ex)) elf_check_fdpic(interp_elf_ex))
goto out_free_dentry; goto out_free_dentry;
/* Load the interpreter program headers */ /* Load the interpreter program headers */
interp_elf_phdata = load_elf_phdrs(&loc->interp_elf_ex, interp_elf_phdata = load_elf_phdrs(interp_elf_ex,
interpreter); interpreter);
if (!interp_elf_phdata) if (!interp_elf_phdata)
goto out_free_dentry; goto out_free_dentry;
/* Pass PT_LOPROC..PT_HIPROC headers to arch code */ /* Pass PT_LOPROC..PT_HIPROC headers to arch code */
elf_ppnt = interp_elf_phdata; elf_ppnt = interp_elf_phdata;
for (i = 0; i < loc->interp_elf_ex.e_phnum; i++, elf_ppnt++) for (i = 0; i < interp_elf_ex->e_phnum; i++, elf_ppnt++)
switch (elf_ppnt->p_type) { switch (elf_ppnt->p_type) {
case PT_LOPROC ... PT_HIPROC: case PT_LOPROC ... PT_HIPROC:
retval = arch_elf_pt_proc(&loc->interp_elf_ex, retval = arch_elf_pt_proc(interp_elf_ex,
elf_ppnt, interpreter, elf_ppnt, interpreter,
true, &arch_state); true, &arch_state);
if (retval) if (retval)
...@@ -840,7 +838,7 @@ static int load_elf_binary(struct linux_binprm *bprm) ...@@ -840,7 +838,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
* the exec syscall. * the exec syscall.
*/ */
retval = arch_check_elf(elf_ex, retval = arch_check_elf(elf_ex,
!!interpreter, &loc->interp_elf_ex, !!interpreter, interp_elf_ex,
&arch_state); &arch_state);
if (retval) if (retval)
goto out_free_dentry; goto out_free_dentry;
...@@ -1056,7 +1054,7 @@ static int load_elf_binary(struct linux_binprm *bprm) ...@@ -1056,7 +1054,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
} }
if (interpreter) { if (interpreter) {
elf_entry = load_elf_interp(&loc->interp_elf_ex, elf_entry = load_elf_interp(interp_elf_ex,
interpreter, interpreter,
load_bias, interp_elf_phdata); load_bias, interp_elf_phdata);
if (!IS_ERR((void *)elf_entry)) { if (!IS_ERR((void *)elf_entry)) {
...@@ -1065,7 +1063,7 @@ static int load_elf_binary(struct linux_binprm *bprm) ...@@ -1065,7 +1063,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
* adjustment * adjustment
*/ */
interp_load_addr = elf_entry; interp_load_addr = elf_entry;
elf_entry += loc->interp_elf_ex.e_entry; elf_entry += interp_elf_ex->e_entry;
} }
if (BAD_ADDR(elf_entry)) { if (BAD_ADDR(elf_entry)) {
retval = IS_ERR((void *)elf_entry) ? retval = IS_ERR((void *)elf_entry) ?
...@@ -1154,7 +1152,7 @@ static int load_elf_binary(struct linux_binprm *bprm) ...@@ -1154,7 +1152,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
start_thread(regs, elf_entry, bprm->p); start_thread(regs, elf_entry, bprm->p);
retval = 0; retval = 0;
out: out:
kfree(loc); kfree(interp_elf_ex);
out_ret: out_ret:
return retval; return retval;
......
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