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

x86/elf: Use e_machine to check for x32/ia32 in setup_additional_pages()

Since TIF_X32 is going away, avoid using it to find the ELF type when
choosing which additional pages to set up.

According to SysV AMD64 ABI Draft, an AMD64 ELF object using ILP32 must
have ELFCLASS32 with (E_MACHINE == EM_X86_64), so use that ELF field to
differentiate a x32 object from a IA32 object when executing
setup_additional_pages() in compat mode.

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-9-krisman@collabora.com


authored by

Gabriel Krisman Bertazi and committed by
Thomas Gleixner
3316ec8c 9a29a671

+6 -4
+2 -2
arch/x86/entry/vdso/vma.c
··· 413 413 414 414 #ifdef CONFIG_COMPAT 415 415 int compat_arch_setup_additional_pages(struct linux_binprm *bprm, 416 - int uses_interp) 416 + int uses_interp, bool x32) 417 417 { 418 418 #ifdef CONFIG_X86_X32_ABI 419 - if (test_thread_flag(TIF_X32)) { 419 + if (x32) { 420 420 if (!vdso64_enabled) 421 421 return 0; 422 422 return map_vdso_randomized(&vdso_image_x32);
+4 -2
arch/x86/include/asm/elf.h
··· 383 383 extern int arch_setup_additional_pages(struct linux_binprm *bprm, 384 384 int uses_interp); 385 385 extern int compat_arch_setup_additional_pages(struct linux_binprm *bprm, 386 - int uses_interp); 387 - #define compat_arch_setup_additional_pages compat_arch_setup_additional_pages 386 + int uses_interp, bool x32); 387 + #define COMPAT_ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \ 388 + compat_arch_setup_additional_pages(bprm, interpreter, \ 389 + (ex->e_machine == EM_X86_64)) 388 390 389 391 /* Do not change the values. See get_align_mask() */ 390 392 enum align_flags {