We can simplify things a little in create_elf_tables() and load_elf_binary() by storing the final entry address for the executable and interpreter in their respective elf_load_info struct, replacing the e_entry variable/argument (executable entry address).
In PCuABI, this will be useful to create the PCC capability in create_elf_tables().
Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com --- fs/binfmt_elf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index c10ba610be50..f1d9b57d35af 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -163,12 +163,14 @@ struct elf_load_info { unsigned long end_elf_rx; unsigned long start_elf_rw; unsigned long end_elf_rw; + + unsigned long entry; };
static int create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec, unsigned long interp_load_addr, - unsigned long e_entry, unsigned long phdr_addr, + unsigned long phdr_addr, const struct elf_load_info *exec_load_info, const struct elf_load_info *interp_load_info) { @@ -273,7 +275,7 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec, if (bprm->interp_flags & BINPRM_FLAGS_PRESERVE_ARGV0) flags |= AT_FLAGS_PRESERVE_ARGV0; NEW_AUX_ENT(AT_FLAGS, flags); - NEW_AUX_ENT(AT_ENTRY, elf_uaddr_to_user_ptr(e_entry)); + NEW_AUX_ENT(AT_ENTRY, elf_uaddr_to_user_ptr(exec_load_info->entry)); NEW_AUX_ENT(AT_UID, from_kuid_munged(cred->user_ns, cred->uid)); NEW_AUX_ENT(AT_EUID, from_kuid_munged(cred->user_ns, cred->euid)); NEW_AUX_ENT(AT_GID, from_kgid_munged(cred->user_ns, cred->gid)); @@ -908,7 +910,6 @@ static int load_elf_binary(struct linux_binprm *bprm) unsigned long elf_brk; int retval, i; unsigned long elf_entry; - unsigned long e_entry; unsigned long interp_load_addr = 0; unsigned long start_code, end_code, start_data, end_data; unsigned long reloc_func_desc __maybe_unused = 0; @@ -1280,7 +1281,7 @@ static int load_elf_binary(struct linux_binprm *bprm) exec_load_info.end_elf_rx = max(k, exec_load_info.end_elf_rx); }
- e_entry = elf_ex->e_entry + load_bias; + exec_load_info.entry = elf_ex->e_entry + load_bias; phdr_addr += load_bias; elf_brk += load_bias; start_code += load_bias; @@ -1309,6 +1310,7 @@ static int load_elf_binary(struct linux_binprm *bprm) */ interp_load_addr = elf_entry; elf_entry += interp_elf_ex->e_entry; + interp_load_info.entry = elf_entry; } if (BAD_ADDR(elf_entry)) { retval = IS_ERR_VALUE(elf_entry) ? @@ -1323,7 +1325,7 @@ static int load_elf_binary(struct linux_binprm *bprm) kfree(interp_elf_ex); kfree(interp_elf_phdata); } else { - elf_entry = e_entry; + elf_entry = exec_load_info.entry; if (BAD_ADDR(elf_entry)) { retval = -EINVAL; goto out_free_dentry; @@ -1341,7 +1343,7 @@ static int load_elf_binary(struct linux_binprm *bprm) #endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */
retval = create_elf_tables(bprm, elf_ex, interp_load_addr, - e_entry, phdr_addr, + phdr_addr, &exec_load_info, &interp_load_info); if (retval < 0) goto out;