]> Git Repo - linux.git/commitdiff
fs/binfmt_elf: use PT_LOAD p_align values for static PIE
authorH.J. Lu <[email protected]>
Thu, 20 Jan 2022 02:09:40 +0000 (18:09 -0800)
committerLinus Torvalds <[email protected]>
Thu, 20 Jan 2022 06:52:54 +0000 (08:52 +0200)
Extend commit ce81bb256a22 ("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]>
fs/binfmt_elf.c

index b9a33cc34d6bf6f699ac776ad88f3a8093678ac4..605017eb9349e5e9de8b60ff38118eb0428c11dc 100644 (file)
@@ -1116,11 +1116,11 @@ out_free_interp:
                         * independently randomized mmap region (0 load_bias
                         * without MAP_FIXED nor MAP_FIXED_NOREPLACE).
                         */
-                       if (interpreter) {
+                       alignment = maximum_alignment(elf_phdata, elf_ex->e_phnum);
+                       if (alignment > ELF_MIN_ALIGN) {
                                load_bias = ELF_ET_DYN_BASE;
                                if (current->flags & PF_RANDOMIZE)
                                        load_bias += arch_mmap_rnd();
-                               alignment = maximum_alignment(elf_phdata, elf_ex->e_phnum);
                                if (alignment)
                                        load_bias &= ~(alignment - 1);
                                elf_flags |= MAP_FIXED_NOREPLACE;
This page took 0.057934 seconds and 4 git commands to generate.