Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1268515

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

Path csiph.com!usenet.pasdenom.info!aioe.org!bofh.it!news.nic.it!robomod
From "Maciej W. Rozycki" <macro@imgtec.com>
Newsgroups linux.kernel
Subject [PATCH 5/8] ELF: Also pass any interpreter's file header to `arch_check_elf'
Date Fri, 13 Nov 2015 01:50:01 +0100
Message-ID <quaIV-7Mk-1@gated-at.bofh.it> (permalink)
References <quaIV-7Mk-3@gated-at.bofh.it>
X-Original-To Ralf Baechle <ralf@linux-mips.org>
User-Agent Alpine 2.00 (DEB 1167 2008-08-23)
MIME-Version 1.0
Content-Type text/plain; charset="US-ASCII"
X-Originating-IP [10.100.200.62]
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 68
Organization linux.* mail to news gateway
X-Original-Cc Andrew Morton <akpm@linux-foundation.org>, Matthew Fortune <Matthew.Fortune@imgtec.com>, <linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>
X-Original-Date Fri, 13 Nov 2015 00:47:48 +0000
X-Original-Message-ID <alpine.DEB.2.00.1511130006190.7097@tp.orcam.me.uk>
X-Original-References <alpine.DEB.2.00.1511111418430.7097@tp.orcam.me.uk>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1268515

Show key headers only | View raw


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@imgtec.com>
---
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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 5/8] ELF: Also pass any interpreter's file header to  `arch_check_elf' "Maciej W. Rozycki" <macro@imgtec.com> - 2015-11-13 01:50 +0100

csiph-web