Skip to content

Commit c55b855

Browse files
hjl-toolsIngo Molnar
authored andcommitted
x86/boot/64: Verify alignment of the LOAD segment
Since the x86-64 kernel must be aligned to 2MB, refuse to boot the kernel if the alignment of the LOAD segment isn't a multiple of 2MB. Signed-off-by: H.J. Lu <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Eric Biederman <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Kees Cook <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/CAMe9rOrR7xSJgUfiCoZLuqWUwymRxXPoGBW38%2BpN%3D9g%[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent e3d0359 commit c55b855

File tree

1 file changed

+4
-0
lines changed
  • arch/x86/boot/compressed

1 file changed

+4
-0
lines changed

arch/x86/boot/compressed/misc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ static void parse_elf(void *output)
309309

310310
switch (phdr->p_type) {
311311
case PT_LOAD:
312+
#ifdef CONFIG_X86_64
313+
if ((phdr->p_align % 0x200000) != 0)
314+
error("Alignment of LOAD segment isn't multiple of 2MB");
315+
#endif
312316
#ifdef CONFIG_RELOCATABLE
313317
dest = output;
314318
dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);

0 commit comments

Comments
 (0)