binfmt_elf.c EI_CLASS check patch

From: Chris Rohlf
Date: Mon Feb 26 2007 - 11:54:03 EST


During some research of mine I realized most of my ELF analysis tools
break on ELF objects with an ELF header e_ident[EI_CLASS] not equal to
ELFCLASS32 or ELFCLASS64. These objects still work fine because the
ELF loader code does not check this value upon execution. So I wrote
a quick patch to do it.

--- binfmt_elf.c.or1 2007-02-25 18:46:29.000000000 -0500
+++ binfmt_elf.c 2007-02-25 17:35:29.000000000 -0500
@@ -573,6 +573,10 @@ static int load_elf_binary(struct linux_
if (!bprm->file->f_op||!bprm->file->f_op->mmap)
goto out;

+ if (loc->elf_ex.e_ident[EI_CLASS] != ELFCLASS32 &&
+ loc->elf_ex.e_ident[EI_CLASS] != ELFCLASS64)
+ goto out;
+
/* Now read in all of the header information */
if (loc->elf_ex.e_phentsize != sizeof(struct elf_phdr))
goto out;


I am not on the list, please CC replies to me.

Chris

--

http://em386.blogspot.com
-
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/