Skip to content

Commit

Permalink
fs: binfmt_elf_efpic: add architecture hook elf_arch_finalize_exec
Browse files Browse the repository at this point in the history
FDPIC ELF loader adds an architecture hook at the end of loading
binaries to finalize the mapped memory before moving toward exec
function.  The hook is used by UML under !MMU when translating
syscall/sysenter instructions before calling execve.

Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Kees Cook <kees@kernel.org>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
  • Loading branch information
thehajime committed Dec 6, 2024
1 parent 5a5c738 commit 7b5ce77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fs/binfmt_elf_fdpic.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params,
return 0;
}

int __weak elf_arch_finalize_exec(struct elf_fdpic_params *exec_params,
struct elf_fdpic_params *interp_params)
{
return 0;
}

/*****************************************************************************/
/*
* load an fdpic binary into various bits of memory
Expand Down Expand Up @@ -457,6 +463,10 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
dynaddr);
#endif

retval = elf_arch_finalize_exec(&exec_params, &interp_params);
if (retval)
goto error;

finalize_exec(bprm);
/* everything is now ready... get the userspace context ready to roll */
entryaddr = interp_params.entry_addr ?: exec_params.entry_addr;
Expand Down
3 changes: 3 additions & 0 deletions include/linux/elf-fdpic.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ extern void elf_fdpic_arch_lay_out_mm(struct elf_fdpic_params *exec_params,
unsigned long *start_brk);
#endif

extern int elf_arch_finalize_exec(struct elf_fdpic_params *exec_params,
struct elf_fdpic_params *interp_params);

#endif /* _LINUX_ELF_FDPIC_H */

0 comments on commit 7b5ce77

Please sign in to comment.