Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

elf: Expose ELF header on arch_setup_additional_pages()

Like it is done for SET_PERSONALITY with ARM, which requires the ELF
header to select correct personality parameters, x86 requires the
headers when selecting which VDSO to load, instead of relying on the
going-away TIF_IA32/X32 flags.

Add an indirection macro to arch_setup_additional_pages(), that x86 can
reimplement to receive the extra parameter just for ELF files. This
requires no changes to other architectures, who can continue to use the
original arch_setup_additional_pages for ELF and non-ELF binaries.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20201004032536.1229030-8-krisman@collabora.com

authored by

Gabriel Krisman Bertazi and committed by
Thomas Gleixner
9a29a671 2424b146

+14 -4
+1 -1
fs/binfmt_elf.c
··· 1246 1246 set_binfmt(&elf_format); 1247 1247 1248 1248 #ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES 1249 - retval = arch_setup_additional_pages(bprm, !!interpreter); 1249 + retval = ARCH_SETUP_ADDITIONAL_PAGES(bprm, elf_ex, !!interpreter); 1250 1250 if (retval < 0) 1251 1251 goto out; 1252 1252 #endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */
+8 -3
fs/compat_binfmt_elf.c
··· 115 115 #define START_THREAD COMPAT_START_THREAD 116 116 #endif 117 117 118 - #ifdef compat_arch_setup_additional_pages 118 + #ifdef compat_arch_setup_additional_pages 119 + #define COMPAT_ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \ 120 + compat_arch_setup_additional_pages(bprm, interpreter) 121 + #endif 122 + 123 + #ifdef COMPAT_ARCH_SETUP_ADDITIONAL_PAGES 119 124 #undef ARCH_HAS_SETUP_ADDITIONAL_PAGES 120 125 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 121 - #undef arch_setup_additional_pages 122 - #define arch_setup_additional_pages compat_arch_setup_additional_pages 126 + #undef ARCH_SETUP_ADDITIONAL_PAGES 127 + #define ARCH_SETUP_ADDITIONAL_PAGES COMPAT_ARCH_SETUP_ADDITIONAL_PAGES 123 128 #endif 124 129 125 130 #ifdef compat_elf_read_implies_exec
+5
include/linux/elf.h
··· 27 27 start_thread(regs, elf_entry, start_stack) 28 28 #endif 29 29 30 + #if defined(ARCH_HAS_SETUP_ADDITIONAL_PAGES) && !defined(ARCH_SETUP_ADDITIONAL_PAGES) 31 + #define ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \ 32 + arch_setup_additional_pages(bprm, interpreter) 33 + #endif 34 + 30 35 #define ELF32_GNU_PROPERTY_ALIGN 4 31 36 #define ELF64_GNU_PROPERTY_ALIGN 8 32 37