[PATCH v3 01/13] fs: binfmt_elf_efpic: add architecture hook elf_arch_finalize_exec
Hajime Tazaki
thehajime at gmail.com
Mon Dec 2 20:23:00 PST 2024
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 at zeniv.linux.org.uk>
Cc: Christian Brauner <brauner at kernel.org>
Cc: Jan Kara <jack at suse.cz>
Cc: Eric Biederman <ebiederm at xmission.com>
Cc: Kees Cook <kees at kernel.org>
Cc: linux-fsdevel at vger.kernel.org
Cc: linux-mm at kvack.org
Signed-off-by: Hajime Tazaki <thehajime at gmail.com>
---
fs/binfmt_elf_fdpic.c | 10 ++++++++++
include/linux/elf-fdpic.h | 3 +++
2 files changed, 13 insertions(+)
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 4fe5bb9f1b1f..ab16fdf475b0 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -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
@@ -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;
diff --git a/include/linux/elf-fdpic.h b/include/linux/elf-fdpic.h
index e533f4513194..e7fd85a1d10f 100644
--- a/include/linux/elf-fdpic.h
+++ b/include/linux/elf-fdpic.h
@@ -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 */
--
2.43.0
More information about the linux-um
mailing list