Skip to content

Commit 9630f0d

Browse files
hjl-toolstorvalds
authored andcommitted
fs/binfmt_elf: use PT_LOAD p_align values for static PIE
Extend commit ce81bb2 ("fs/binfmt_elf: use PT_LOAD p_align values for suitable start address") which fixed PIE binaries built with -Wl,-z,max-page-size=0x200000, to cover static PIE binaries. This fixes: https://bugzilla.kernel.org/show_bug.cgi?id=215275 Tested by verifying static PIE binaries with -Wl,-z,max-page-size=0x200000 loading. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: H.J. Lu <[email protected]> Cc: Chris Kennelly <[email protected]> Cc: Al Viro <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Song Liu <[email protected]> Cc: David Rientjes <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Sandeep Patil <[email protected]> Cc: Fangrui Song <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c55cdc5 commit 9630f0d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/binfmt_elf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,11 +1116,11 @@ static int load_elf_binary(struct linux_binprm *bprm)
11161116
* independently randomized mmap region (0 load_bias
11171117
* without MAP_FIXED nor MAP_FIXED_NOREPLACE).
11181118
*/
1119-
if (interpreter) {
1119+
alignment = maximum_alignment(elf_phdata, elf_ex->e_phnum);
1120+
if (alignment > ELF_MIN_ALIGN) {
11201121
load_bias = ELF_ET_DYN_BASE;
11211122
if (current->flags & PF_RANDOMIZE)
11221123
load_bias += arch_mmap_rnd();
1123-
alignment = maximum_alignment(elf_phdata, elf_ex->e_phnum);
11241124
if (alignment)
11251125
load_bias &= ~(alignment - 1);
11261126
elf_flags |= MAP_FIXED_NOREPLACE;

0 commit comments

Comments
 (0)