Skip to content

Commit

Permalink
kernel/kexec_file.c: remove checks in kexec_purgatory_load
Browse files Browse the repository at this point in the history
Before the purgatory is loaded several checks are done whether the ELF
file in kexec_purgatory is valid or not.  These checks are incomplete.
For example they don't check for the total size of the sections defined
in the section header table or if the entry point actually points into
the purgatory.

On the other hand the purgatory, although an ELF file on its own, is
part of the kernel.  Thus not trusting the purgatory means not trusting
the kernel build itself.

So remove all validity checks on the purgatory and just trust the kernel
build.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Philipp Rudo <[email protected]>
Acked-by: Dave Young <[email protected]>
Cc: AKASHI Takahiro <[email protected]>
Cc: Eric Biederman <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Thiago Jung Bauermann <[email protected]>
Cc: Vivek Goyal <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Philipp Rudo authored and torvalds committed Apr 14, 2018
1 parent ee6ebed commit d2b8178
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions kernel/kexec_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,22 +941,8 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min,
if (kexec_purgatory_size <= 0)
return -EINVAL;

if (kexec_purgatory_size < sizeof(Elf_Ehdr))
return -ENOEXEC;

pi->ehdr = (Elf_Ehdr *)kexec_purgatory;

if (memcmp(pi->ehdr->e_ident, ELFMAG, SELFMAG) != 0
|| pi->ehdr->e_type != ET_REL
|| !elf_check_arch(pi->ehdr)
|| pi->ehdr->e_shentsize != sizeof(Elf_Shdr))
return -ENOEXEC;

if (pi->ehdr->e_shoff >= kexec_purgatory_size
|| (pi->ehdr->e_shnum * sizeof(Elf_Shdr) >
kexec_purgatory_size - pi->ehdr->e_shoff))
return -ENOEXEC;

ret = __kexec_load_purgatory(image, min, max, top_down);
if (ret)
return ret;
Expand Down

0 comments on commit d2b8178

Please sign in to comment.