aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2016-02-10 04:21:21 -0500
committerRalf Baechle <ralf@linux-mips.org>2016-02-11 05:38:22 -0500
commitf4d3d504198d464e406171cfa554a59bd4773d79 (patch)
tree58d8aa0a2c992c7ce029722e172fd02f20103fd3 /arch
parentb96d6a80c95815fd01e99a239cd515fc05e5f867 (diff)
mips: Differentiate between 32 and 64 bit ELF header
Depending on the configuration either the 32 or 64 bit version of elf_check_arch() is defined. parse_crash_elf{32|64}_headers() does some basic verification of the ELF header via vmcore_elf{32|64}_check_arch() which happen to map to elf_check_arch(). Since the implementation 32 and 64 bit version of elf_check_arch() differ, we use the wrong type: In file included from include/linux/elf.h:4:0, from fs/proc/vmcore.c:13: fs/proc/vmcore.c: In function 'parse_crash_elf64_headers': >> arch/mips/include/asm/elf.h:228:23: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] struct elfhdr *__h = (hdr); \ ^ include/linux/crash_dump.h:41:37: note: in expansion of macro 'elf_check_arch' #define vmcore_elf64_check_arch(x) (elf_check_arch(x) || vmcore_elf_check_arch_cross(x)) ^ fs/proc/vmcore.c:1015:4: note: in expansion of macro 'vmcore_elf64_check_arch' !vmcore_elf64_check_arch(&ehdr) || ^ Therefore, we rather define vmcore_elf{32|64}_check_arch() as a basic machine check and use it also in binfm_elf?32.c as well. Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de> Suggested-by: Maciej W. Rozycki <macro@imgtec.com> Reviewed-by: Maciej W. Rozycki <macro@imgtec.com> Reported-by: Fengguang Wu <fengguang.wu@intel.com> Cc: linux-kernel@vger.kernel.org Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/12529/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/include/asm/elf.h9
-rw-r--r--arch/mips/kernel/binfmt_elfn32.c2
-rw-r--r--arch/mips/kernel/binfmt_elfo32.c2
3 files changed, 9 insertions, 4 deletions
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index cefb7a596878..e090fc388e02 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -227,7 +227,7 @@ struct mips_elf_abiflags_v0 {
227 int __res = 1; \ 227 int __res = 1; \
228 struct elfhdr *__h = (hdr); \ 228 struct elfhdr *__h = (hdr); \
229 \ 229 \
230 if (__h->e_machine != EM_MIPS) \ 230 if (!mips_elf_check_machine(__h)) \
231 __res = 0; \ 231 __res = 0; \
232 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \ 232 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \
233 __res = 0; \ 233 __res = 0; \
@@ -258,7 +258,7 @@ struct mips_elf_abiflags_v0 {
258 int __res = 1; \ 258 int __res = 1; \
259 struct elfhdr *__h = (hdr); \ 259 struct elfhdr *__h = (hdr); \
260 \ 260 \
261 if (__h->e_machine != EM_MIPS) \ 261 if (!mips_elf_check_machine(__h)) \
262 __res = 0; \ 262 __res = 0; \
263 if (__h->e_ident[EI_CLASS] != ELFCLASS64) \ 263 if (__h->e_ident[EI_CLASS] != ELFCLASS64) \
264 __res = 0; \ 264 __res = 0; \
@@ -285,6 +285,11 @@ struct mips_elf_abiflags_v0 {
285 285
286#endif /* !defined(ELF_ARCH) */ 286#endif /* !defined(ELF_ARCH) */
287 287
288#define mips_elf_check_machine(x) ((x)->e_machine == EM_MIPS)
289
290#define vmcore_elf32_check_arch mips_elf_check_machine
291#define vmcore_elf64_check_arch mips_elf_check_machine
292
288struct mips_abi; 293struct mips_abi;
289 294
290extern struct mips_abi mips_abi; 295extern struct mips_abi mips_abi;
diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
index 1188e00bb120..1b992c6e3d8e 100644
--- a/arch/mips/kernel/binfmt_elfn32.c
+++ b/arch/mips/kernel/binfmt_elfn32.c
@@ -35,7 +35,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
35 int __res = 1; \ 35 int __res = 1; \
36 struct elfhdr *__h = (hdr); \ 36 struct elfhdr *__h = (hdr); \
37 \ 37 \
38 if (__h->e_machine != EM_MIPS) \ 38 if (!mips_elf_check_machine(__h)) \
39 __res = 0; \ 39 __res = 0; \
40 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \ 40 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \
41 __res = 0; \ 41 __res = 0; \
diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
index 928767858b86..abd3affe5fb3 100644
--- a/arch/mips/kernel/binfmt_elfo32.c
+++ b/arch/mips/kernel/binfmt_elfo32.c
@@ -47,7 +47,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
47 int __res = 1; \ 47 int __res = 1; \
48 struct elfhdr *__h = (hdr); \ 48 struct elfhdr *__h = (hdr); \
49 \ 49 \
50 if (__h->e_machine != EM_MIPS) \ 50 if (!mips_elf_check_machine(__h)) \
51 __res = 0; \ 51 __res = 0; \
52 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \ 52 if (__h->e_ident[EI_CLASS] != ELFCLASS32) \
53 __res = 0; \ 53 __res = 0; \