[PATCH 04/19] x86: Remove compat_arch_setup_additional_pages()

From: Dmitry Safonov
Date: Sun Nov 08 2020 - 00:18:01 EST


The same as for x32 task, detect ia32 task by in_ia32_syscall().
It's valid as new-execed task is pretending to be in a syscall of
relevant bitness/ABI, 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 marco less).

Cc: x86@xxxxxxxxxx
Signed-off-by: Dmitry Safonov <dima@xxxxxxxxxx>
---
arch/x86/entry/vdso/vma.c | 41 +++++++++++++++++++-------------------
arch/x86/include/asm/elf.h | 5 -----
2 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
index 4eea508e9b10..aace862ed9a1 100644
--- a/arch/x86/entry/vdso/vma.c
+++ b/arch/x86/entry/vdso/vma.c
@@ -376,48 +376,49 @@ int map_vdso_once(const struct vdso_image *image, unsigned long addr)
}

#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
-static int load_vdso32(void)
+static int load_vdso_ia32(void)
{
if (vdso32_enabled != 1) /* Other values all mean "disabled" */
return 0;

return map_vdso(&vdso_image_32, 0);
}
+#else
+static int load_vdso_ia32(void)
+{
+ WARN_ON_ONCE(1);
+ return -ENODATA;
+}
#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 (in_ia32_syscall())
+ return load_vdso_ia32();
+
+ return load_vdso_64();
}
-#endif

#ifdef CONFIG_X86_64
static __init int vdso_setup(char *s)
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index d00b723eea2d..51a08f6b18e5 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -377,11 +377,6 @@ else \
((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
-
/* Do not change the values. See get_align_mask() */
enum align_flags {
ALIGN_VA_32 = BIT(0),
--
2.28.0