[PATCH 5/8] ELF: Also pass any interpreter's file header to `arch_check_elf'

From: Maciej W. Rozycki
Date: Thu Nov 12 2015 - 19:47:55 EST


Also pass any interpreter's file header to `arch_check_elf' so that any
architecture handler can have a look at it if needed.

Signed-off-by: Maciej W. Rozycki <macro@xxxxxxxxxx>
---
linux-arch-check-elf-interp.diff
Index: linux-sfr-test/arch/mips/include/asm/elf.h
===================================================================
--- linux-sfr-test.orig/arch/mips/include/asm/elf.h 2015-11-10 18:06:16.547399000 +0000
+++ linux-sfr-test/arch/mips/include/asm/elf.h 2015-11-11 02:20:02.099077000 +0000
@@ -448,7 +448,7 @@ struct arch_elf_state {
extern int arch_elf_pt_proc(void *ehdr, void *phdr, struct file *elf,
bool is_interp, struct arch_elf_state *state);

-extern int arch_check_elf(void *ehdr, bool has_interpreter,
+extern int arch_check_elf(void *ehdr, bool has_interpreter, void *interp_ehdr,
struct arch_elf_state *state);

extern void mips_set_personality_fp(struct arch_elf_state *state);
Index: linux-sfr-test/arch/mips/kernel/elf.c
===================================================================
--- linux-sfr-test.orig/arch/mips/kernel/elf.c 2015-11-11 02:19:56.376032000 +0000
+++ linux-sfr-test/arch/mips/kernel/elf.c 2015-11-11 02:20:02.104077000 +0000
@@ -128,7 +128,7 @@ int arch_elf_pt_proc(void *_ehdr, void *
return 0;
}

-int arch_check_elf(void *_ehdr, bool has_interpreter,
+int arch_check_elf(void *_ehdr, bool has_interpreter, void *_interp_ehdr,
struct arch_elf_state *state)
{
union {
Index: linux-sfr-test/fs/binfmt_elf.c
===================================================================
--- linux-sfr-test.orig/fs/binfmt_elf.c 2015-11-10 18:08:00.126238000 +0000
+++ linux-sfr-test/fs/binfmt_elf.c 2015-11-11 02:20:02.126077000 +0000
@@ -490,6 +490,7 @@ static inline int arch_elf_pt_proc(struc
* arch_check_elf() - check an ELF executable
* @ehdr: The main ELF header
* @has_interp: True if the ELF has an interpreter, else false.
+ * @interp_ehdr: The interpreter's ELF header
* @state: Architecture-specific state preserved throughout the process
* of loading the ELF.
*
@@ -501,6 +502,7 @@ static inline int arch_elf_pt_proc(struc
* with that return code.
*/
static inline int arch_check_elf(struct elfhdr *ehdr, bool has_interp,
+ struct elfhdr *interp_ehdr,
struct arch_elf_state *state)
{
/* Dummy implementation, always proceed */
@@ -828,7 +830,9 @@ static int load_elf_binary(struct linux_
* still possible to return an error to the code that invoked
* the exec syscall.
*/
- retval = arch_check_elf(&loc->elf_ex, !!interpreter, &arch_state);
+ retval = arch_check_elf(&loc->elf_ex,
+ !!interpreter, &loc->interp_elf_ex,
+ &arch_state);
if (retval)
goto out_free_dentry;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/