Bug fix to ELF Loader which rejects valid ELFs
Subsystems (2)
PATCH v2 1/1 Bug fix to ELF Loader which rejects valid ELFs
Check was incorrectly being applied to size of elf phdrs, instead of the number. The ELF standard allows for up to 65535 headers, but the check was being compared to the number of headers multiplied by the size of a program header.
--- fs/binfmt_elf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/binfmt_elf.c +0 -0
@@ -445,11 +445,11 @@ static struct elf_phdr *load_elf_phdrs(const struct
elfhdr *elf_ex,
goto out;
/* Sanity check the number of program headers... */
- /* ...and their total size. */
- size = sizeof(struct elf_phdr) * elf_ex->e_phnum;
- if (size == 0 || size > 65536 || size > ELF_MIN_ALIGN)
+ if (elf_ex->e_phnum == 0)
goto out;
+ size = array_size(sizeof(*elf_phdata), elf_ex->e_phnum);
+
elf_phdata = kmalloc(size, GFP_KERNEL);
if (!elf_phdata)
goto out;
Signature · 1 line
2.17.1