[PATCH v3 05/23] x86: Remove compat_arch_setup_additional_pages()
From: Dmitry Safonov
Date: Fri Jun 11 2021 - 14:03:23 EST
The same as for x32 task, detect ia32 task by in_ia32_syscall().
A process that has just done sys_exec() for compatible ELF
is doing compatible syscall after personality is set in
load_elf_binary(), see the comment near in_32bit_syscall().
Removing compat_arch_setup_additional_pages() provides single point of
entry - arch_setup_additional_pages(), makes ifdeffery easier to read,
aligns the code with powerpc and sparc (mips also has single vdso setup
function, but instead of taking bitness from mm.context, takes vdso
image pointer there).
Together with arm64 code align to use in_compat_task(), it makes
possible to remove compat_arch_setup_additional_pages() macro
re-definition from compat elf code (another redefined macro less).
Cc: x86@xxxxxxxxxx
Signed-off-by: Dmitry Safonov <dima@xxxxxxxxxx>
---
arch/x86/entry/vdso/vma.c | 48 +++++++++++++++-----------------------
arch/x86/include/asm/elf.h | 5 ----
2 files changed, 19 insertions(+), 34 deletions(-)
diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 43d42ce82e86..99415ffb9501 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -375,50 +375,40 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)
return map_vdso(image, addr);
}
-#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
-static int load_vdso32(void)
-{
- if (vdso32_enabled != 1) /* Other values all mean "disabled" */
- return 0;
-
- return map_vdso(&vdso_image_32, 0);
-}
-#endif
-
#ifdef CONFIG_X86_64
-int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
+static int load_vdso_64(void)
{
if (!vdso64_enabled)
return 0;
- return map_vdso_randomized(&vdso_image_64);
-}
-
-#ifdef CONFIG_COMPAT
-int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp)
-{
#ifdef CONFIG_X86_X32_ABI
- if (in_x32_syscall()) {
- if (!vdso64_enabled)
- return 0;
+ if (in_x32_syscall())
return map_vdso_randomized(&vdso_image_x32);
- }
#endif
-#ifdef CONFIG_IA32_EMULATION
- return load_vdso32();
+
+ return map_vdso_randomized(&vdso_image_64);
+}
#else
- return 0;
-#endif
+static int load_vdso_64(void)
+{
+ WARN_ON_ONCE(1);
+ return -ENODATA;
}
#endif
-#else
+
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
{
- return load_vdso32();
-}
+#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
+ if (in_ia32_syscall()) {
+ if (vdso32_enabled != 1) /* Other values all mean "disabled" */
+ return 0;
+ return map_vdso(&vdso_image_32, 0);
+ }
#endif
+ return load_vdso_64();
+}
+
bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs)
{
#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 9ee5b3b3ba93..93ff2c7ca4df 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -377,11 +377,6 @@ else if (IS_ENABLED(CONFIG_IA32_EMULATION)) \
((unsigned long)current->mm->context.vdso + \
vdso_image_32.sym___kernel_vsyscall)
-struct linux_binprm;
-extern int compat_arch_setup_additional_pages(struct linux_binprm *bprm,
- int uses_interp);
-#define compat_arch_setup_additional_pages compat_arch_setup_additional_pages
-
extern bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs);
/* Do not change the values. See get_align_mask() */
--
2.31.1