linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] um: remove vDSO passthrough on 32bit x86
@ 2025-10-28  9:15 Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 01/10] um: Split out default elf_aux_platform Thomas Weißschuh
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

Inheriting the vDSO from the host is problematic. The values read
from the time functions will not be correct for the UML kernel.
Furthermore the start and end of the vDSO are not stable or
detectable by userspace. Specifically the vDSO datapages start
before AT_SYSINFO_EHDR and the vDSO itself is larger than a single page.

This codepath is only used on 32bit x86 UML. In my testing with both
32bit and 64bit hosts the passthrough functionality has always been
disabled anyways due to the checks against envp in scan_elf_aux().

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (10):
      um: Split out default elf_aux_platform
      x86/um: Move ELF_PLATFORM fallback to x86-specific code
      um: Split out default elf_aux_hwcap
      x86/um: Do not inherit vDSO from host
      x86/um: Drop gate area handling
      um: Remove fixaddr_user_init()
      um: Remove redundant range check from __access_ok_vsyscall()
      um: Remove __access_ok_vsyscall()
      x86/um: Remove FIXADDR_USER_START and FIXADDR_USE_END
      um: Always set up AT_HWCAP and AT_PLATFORM

 arch/um/include/asm/page.h    |   4 --
 arch/um/include/asm/uaccess.h |   9 +---
 arch/um/kernel/mem.c          | 107 ------------------------------------------
 arch/um/os-Linux/Makefile     |   4 +-
 arch/um/os-Linux/elf_aux.c    |  37 +++------------
 arch/um/os-Linux/main.c       |   4 --
 arch/um/os-Linux/user_syms.c  |   6 ---
 arch/x86/um/Kconfig           |   4 --
 arch/x86/um/Makefile          |   5 +-
 arch/x86/um/asm/elf.h         |  39 ++-------------
 arch/x86/um/elfcore.c         |  78 ------------------------------
 arch/x86/um/mem_32.c          |  50 --------------------
 12 files changed, 15 insertions(+), 332 deletions(-)
---
base-commit: 83e4187d1b952c36ffc2d01a2e532ad8a9e80a76
change-id: 20250925-uml-remove-32bit-pseudo-vdso-8b02724e8626

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 01/10] um: Split out default elf_aux_platform
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 02/10] x86/um: Move ELF_PLATFORM fallback to x86-specific code Thomas Weißschuh
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

Setting all auxiliary vector values to default values if one of them
was not provided by the host will discard perfectly fine values.

Move the elf_aux_platform fallback to its own conditional.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/um/os-Linux/elf_aux.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c
index 0a0f91cf4d6d..a62fe39e85c9 100644
--- a/arch/um/os-Linux/elf_aux.c
+++ b/arch/um/os-Linux/elf_aux.c
@@ -62,14 +62,16 @@ __init void scan_elf_aux( char **envp)
 		}
 	}
 	if ( ! __kernel_vsyscall || ! vsyscall_ehdr ||
-	     ! elf_aux_hwcap || ! elf_aux_platform ||
+	     ! elf_aux_hwcap ||
 	     ! page_size || (vsyscall_ehdr % page_size) ) {
 		__kernel_vsyscall = 0;
 		vsyscall_ehdr = 0;
 		elf_aux_hwcap = 0;
-		elf_aux_platform = "i586";
 	}
 	else {
 		vsyscall_end = vsyscall_ehdr + page_size;
 	}
+
+	if (!elf_aux_platform)
+		elf_aux_platform = "i586";
 }

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 02/10] x86/um: Move ELF_PLATFORM fallback to x86-specific code
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 01/10] um: Split out default elf_aux_platform Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 03/10] um: Split out default elf_aux_hwcap Thomas Weißschuh
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

The generic UM code should not have references to x86-specific value.

Move the fallback into the x86-specific header.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/um/os-Linux/elf_aux.c | 3 ---
 arch/x86/um/asm/elf.h      | 3 ++-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c
index a62fe39e85c9..4aadb9ea5ae3 100644
--- a/arch/um/os-Linux/elf_aux.c
+++ b/arch/um/os-Linux/elf_aux.c
@@ -71,7 +71,4 @@ __init void scan_elf_aux( char **envp)
 	else {
 		vsyscall_end = vsyscall_ehdr + page_size;
 	}
-
-	if (!elf_aux_platform)
-		elf_aux_platform = "i586";
 }
diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h
index 62ed5d68a978..e7a045e01471 100644
--- a/arch/x86/um/asm/elf.h
+++ b/arch/x86/um/asm/elf.h
@@ -69,7 +69,8 @@
 } while (0);
 
 extern char * elf_aux_platform;
-#define ELF_PLATFORM (elf_aux_platform)
+#define ELF_PLATFORM_FALLBACK "i586"
+#define ELF_PLATFORM (elf_aux_platform ?: ELF_PLATFORM_FALLBACK)
 
 extern unsigned long vsyscall_ehdr;
 extern unsigned long vsyscall_end;

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 03/10] um: Split out default elf_aux_hwcap
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 01/10] um: Split out default elf_aux_platform Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 02/10] x86/um: Move ELF_PLATFORM fallback to x86-specific code Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 04/10] x86/um: Do not inherit vDSO from host Thomas Weißschuh
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

Setting all auxiliary vector values to default values if one of them
was not provided by the host will discard perfectly fine values.

Remove the elf_aux_platform fallback from the vDSO ones.
As zero is the correct fallback anyways, don't create a new conditional.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/um/os-Linux/elf_aux.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c
index 4aadb9ea5ae3..9ee0e3199790 100644
--- a/arch/um/os-Linux/elf_aux.c
+++ b/arch/um/os-Linux/elf_aux.c
@@ -62,11 +62,9 @@ __init void scan_elf_aux( char **envp)
 		}
 	}
 	if ( ! __kernel_vsyscall || ! vsyscall_ehdr ||
-	     ! elf_aux_hwcap ||
 	     ! page_size || (vsyscall_ehdr % page_size) ) {
 		__kernel_vsyscall = 0;
 		vsyscall_ehdr = 0;
-		elf_aux_hwcap = 0;
 	}
 	else {
 		vsyscall_end = vsyscall_ehdr + page_size;

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 04/10] x86/um: Do not inherit vDSO from host
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
                   ` (2 preceding siblings ...)
  2025-10-28  9:15 ` [PATCH 03/10] um: Split out default elf_aux_hwcap Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 05/10] x86/um: Drop gate area handling Thomas Weißschuh
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

Inheriting the vDSO from the host is problematic. The values read
from the time functions will not be correct for the UML kernel.
Furthermore the start and end of the vDSO are not stable or
detectable by userspace. Specifically the vDSO datapages start
before AT_SYSINFO_EHDR and the vDSO itself is larger than a single page.

This codepath is only used on 32bit x86 UML. In my testing with both
32bit and 64bit hosts the passthrough functionality has always been
disabled anyways due to the checks against envp in scan_elf_aux().

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/um/os-Linux/elf_aux.c   | 27 ---------------
 arch/um/os-Linux/user_syms.c |  6 ----
 arch/x86/um/Kconfig          |  1 -
 arch/x86/um/Makefile         |  1 -
 arch/x86/um/asm/elf.h        | 29 ++--------------
 arch/x86/um/elfcore.c        | 78 --------------------------------------------
 6 files changed, 3 insertions(+), 139 deletions(-)

diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c
index 9ee0e3199790..f8927a5959d8 100644
--- a/arch/um/os-Linux/elf_aux.c
+++ b/arch/um/os-Linux/elf_aux.c
@@ -20,31 +20,15 @@ typedef Elf32_auxv_t elf_auxv_t;
 /* These are initialized very early in boot and never changed */
 char * elf_aux_platform;
 extern long elf_aux_hwcap;
-unsigned long vsyscall_ehdr;
-unsigned long vsyscall_end;
-unsigned long __kernel_vsyscall;
 
 __init void scan_elf_aux( char **envp)
 {
-	long page_size = 0;
 	elf_auxv_t * auxv;
 
 	while ( *envp++ != NULL) ;
 
 	for ( auxv = (elf_auxv_t *)envp; auxv->a_type != AT_NULL; auxv++) {
 		switch ( auxv->a_type ) {
-			case AT_SYSINFO:
-				__kernel_vsyscall = auxv->a_un.a_val;
-				/* See if the page is under TASK_SIZE */
-				if (__kernel_vsyscall < (unsigned long) envp)
-					__kernel_vsyscall = 0;
-				break;
-			case AT_SYSINFO_EHDR:
-				vsyscall_ehdr = auxv->a_un.a_val;
-				/* See if the page is under TASK_SIZE */
-				if (vsyscall_ehdr < (unsigned long) envp)
-					vsyscall_ehdr = 0;
-				break;
 			case AT_HWCAP:
 				elf_aux_hwcap = auxv->a_un.a_val;
 				break;
@@ -56,17 +40,6 @@ __init void scan_elf_aux( char **envp)
 				elf_aux_platform =
 					(char *) (long) auxv->a_un.a_val;
 				break;
-			case AT_PAGESZ:
-				page_size = auxv->a_un.a_val;
-				break;
 		}
 	}
-	if ( ! __kernel_vsyscall || ! vsyscall_ehdr ||
-	     ! page_size || (vsyscall_ehdr % page_size) ) {
-		__kernel_vsyscall = 0;
-		vsyscall_ehdr = 0;
-	}
-	else {
-		vsyscall_end = vsyscall_ehdr + page_size;
-	}
 }
diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c
index a310ae27b479..67f6112318b6 100644
--- a/arch/um/os-Linux/user_syms.c
+++ b/arch/um/os-Linux/user_syms.c
@@ -31,12 +31,6 @@ extern void *memset(void *, int, size_t);
 EXPORT_SYMBOL(memset);
 #endif
 
-#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
-/* needed for __access_ok() */
-EXPORT_SYMBOL(vsyscall_ehdr);
-EXPORT_SYMBOL(vsyscall_end);
-#endif
-
 #ifdef _FORTIFY_SOURCE
 extern int __sprintf_chk(char *str, int flag, size_t len, const char *format);
 EXPORT_SYMBOL(__sprintf_chk);
diff --git a/arch/x86/um/Kconfig b/arch/x86/um/Kconfig
index c52fb5cb8d21..798c6cc53e82 100644
--- a/arch/x86/um/Kconfig
+++ b/arch/x86/um/Kconfig
@@ -8,7 +8,6 @@ endmenu
 
 config UML_X86
 	def_bool y
-	select ARCH_BINFMT_ELF_EXTRA_PHDRS if X86_32
 	select ARCH_USE_QUEUED_RWLOCKS
 	select ARCH_USE_QUEUED_SPINLOCKS
 	select DCACHE_WORD_ACCESS
diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile
index b42c31cd2390..1767e6061b4d 100644
--- a/arch/x86/um/Makefile
+++ b/arch/x86/um/Makefile
@@ -18,7 +18,6 @@ obj-y = bugs_$(BITS).o delay.o fault.o \
 ifeq ($(CONFIG_X86_32),y)
 
 obj-y += syscalls_32.o
-obj-$(CONFIG_ELF_CORE) += elfcore.o
 
 subarch-y = ../lib/string_32.o ../lib/atomic64_32.o ../lib/atomic64_cx8_32.o
 subarch-y += ../lib/cmpxchg8b_emu.o ../lib/atomic64_386_32.o
diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h
index e7a045e01471..8d7df4684c38 100644
--- a/arch/x86/um/asm/elf.h
+++ b/arch/x86/um/asm/elf.h
@@ -72,32 +72,9 @@ extern char * elf_aux_platform;
 #define ELF_PLATFORM_FALLBACK "i586"
 #define ELF_PLATFORM (elf_aux_platform ?: ELF_PLATFORM_FALLBACK)
 
-extern unsigned long vsyscall_ehdr;
-extern unsigned long vsyscall_end;
-extern unsigned long __kernel_vsyscall;
-
-/*
- * This is the range that is readable by user mode, and things
- * acting like user mode such as get_user_pages.
- */
-#define FIXADDR_USER_START      vsyscall_ehdr
-#define FIXADDR_USER_END        vsyscall_end
-
-
-/*
- * Architecture-neutral AT_ values in 0-17, leave some room
- * for more of them, start the x86-specific ones at 32.
- */
-#define AT_SYSINFO		32
-#define AT_SYSINFO_EHDR		33
-
-#define ARCH_DLINFO						\
-do {								\
-	if ( vsyscall_ehdr ) {					\
-		NEW_AUX_ENT(AT_SYSINFO,	__kernel_vsyscall);	\
-		NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr);	\
-	}							\
-} while (0)
+/* No user-accessible fixmap addresses, i.e. vsyscall */
+#define FIXADDR_USER_START      0
+#define FIXADDR_USER_END        0
 
 #else
 
diff --git a/arch/x86/um/elfcore.c b/arch/x86/um/elfcore.c
deleted file mode 100644
index ef50662fc40d..000000000000
--- a/arch/x86/um/elfcore.c
+++ /dev/null
@@ -1,78 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <linux/elf.h>
-#include <linux/elfcore.h>
-#include <linux/coredump.h>
-#include <linux/fs.h>
-#include <linux/mm.h>
-
-#include <asm/elf.h>
-
-
-Elf32_Half elf_core_extra_phdrs(struct coredump_params *cprm)
-{
-	return vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0;
-}
-
-int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
-{
-	if ( vsyscall_ehdr ) {
-		const struct elfhdr *const ehdrp =
-			(struct elfhdr *) vsyscall_ehdr;
-		const struct elf_phdr *const phdrp =
-			(const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff);
-		int i;
-		Elf32_Off ofs = 0;
-
-		for (i = 0; i < ehdrp->e_phnum; ++i) {
-			struct elf_phdr phdr = phdrp[i];
-
-			if (phdr.p_type == PT_LOAD) {
-				ofs = phdr.p_offset = offset;
-				offset += phdr.p_filesz;
-			} else {
-				phdr.p_offset += ofs;
-			}
-			phdr.p_paddr = 0; /* match other core phdrs */
-			if (!dump_emit(cprm, &phdr, sizeof(phdr)))
-				return 0;
-		}
-	}
-	return 1;
-}
-
-int elf_core_write_extra_data(struct coredump_params *cprm)
-{
-	if ( vsyscall_ehdr ) {
-		const struct elfhdr *const ehdrp =
-			(struct elfhdr *) vsyscall_ehdr;
-		const struct elf_phdr *const phdrp =
-			(const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff);
-		int i;
-
-		for (i = 0; i < ehdrp->e_phnum; ++i) {
-			if (phdrp[i].p_type == PT_LOAD) {
-				void *addr = (void *) phdrp[i].p_vaddr;
-				size_t filesz = phdrp[i].p_filesz;
-				if (!dump_emit(cprm, addr, filesz))
-					return 0;
-			}
-		}
-	}
-	return 1;
-}
-
-size_t elf_core_extra_data_size(struct coredump_params *cprm)
-{
-	if ( vsyscall_ehdr ) {
-		const struct elfhdr *const ehdrp =
-			(struct elfhdr *)vsyscall_ehdr;
-		const struct elf_phdr *const phdrp =
-			(const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff);
-		int i;
-
-		for (i = 0; i < ehdrp->e_phnum; ++i)
-			if (phdrp[i].p_type == PT_LOAD)
-				return (size_t) phdrp[i].p_filesz;
-	}
-	return 0;
-}

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 05/10] x86/um: Drop gate area handling
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
                   ` (3 preceding siblings ...)
  2025-10-28  9:15 ` [PATCH 04/10] x86/um: Do not inherit vDSO from host Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 06/10] um: Remove fixaddr_user_init() Thomas Weißschuh
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

With the removal of the vDSO passthrough from the host,
FIXADDR_USER_START is always 0 and the gate area setup code is dead.

Remove it.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/um/include/asm/page.h |  4 ----
 arch/x86/um/Makefile       |  4 ++--
 arch/x86/um/mem_32.c       | 50 ----------------------------------------------
 3 files changed, 2 insertions(+), 56 deletions(-)

diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
index 6f54254aaf44..2d363460d896 100644
--- a/arch/um/include/asm/page.h
+++ b/arch/um/include/asm/page.h
@@ -96,8 +96,4 @@ extern unsigned long uml_physmem;
 
 #endif	/* __ASSEMBLER__ */
 
-#ifdef CONFIG_X86_32
-#define __HAVE_ARCH_GATE_AREA 1
-#endif
-
 #endif	/* __UM_PAGE_H */
diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile
index 1767e6061b4d..f9ea75bf43ac 100644
--- a/arch/x86/um/Makefile
+++ b/arch/x86/um/Makefile
@@ -13,7 +13,7 @@ obj-y = bugs_$(BITS).o delay.o fault.o \
 	ptrace.o ptrace_$(BITS).o ptrace_user.o setjmp_$(BITS).o signal.o \
 	stub_segv.o \
 	sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \
-	mem_$(BITS).o subarch.o os-Linux/
+	subarch.o os-Linux/
 
 ifeq ($(CONFIG_X86_32),y)
 
@@ -26,7 +26,7 @@ subarch-y += ../kernel/sys_ia32.o
 
 else
 
-obj-y += syscalls_64.o vdso/
+obj-y += mem_64.o syscalls_64.o vdso/
 
 subarch-y = ../lib/csum-partial_64.o ../lib/memcpy_64.o \
 	../lib/memmove_64.o ../lib/memset_64.o
diff --git a/arch/x86/um/mem_32.c b/arch/x86/um/mem_32.c
deleted file mode 100644
index 29b2203bc82c..000000000000
--- a/arch/x86/um/mem_32.c
+++ /dev/null
@@ -1,50 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
- */
-
-#include <linux/mm.h>
-#include <asm/elf.h>
-
-static struct vm_area_struct gate_vma;
-
-static int __init gate_vma_init(void)
-{
-	if (!FIXADDR_USER_START)
-		return 0;
-
-	vma_init(&gate_vma, NULL);
-	gate_vma.vm_start = FIXADDR_USER_START;
-	gate_vma.vm_end = FIXADDR_USER_END;
-	vm_flags_init(&gate_vma, VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC);
-	gate_vma.vm_page_prot = PAGE_READONLY;
-
-	return 0;
-}
-__initcall(gate_vma_init);
-
-struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
-{
-	return FIXADDR_USER_START ? &gate_vma : NULL;
-}
-
-int in_gate_area_no_mm(unsigned long addr)
-{
-	if (!FIXADDR_USER_START)
-		return 0;
-
-	if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))
-		return 1;
-
-	return 0;
-}
-
-int in_gate_area(struct mm_struct *mm, unsigned long addr)
-{
-	struct vm_area_struct *vma = get_gate_vma(mm);
-
-	if (!vma)
-		return 0;
-
-	return (addr >= vma->vm_start) && (addr < vma->vm_end);
-}

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 06/10] um: Remove fixaddr_user_init()
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
                   ` (4 preceding siblings ...)
  2025-10-28  9:15 ` [PATCH 05/10] x86/um: Drop gate area handling Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 07/10] um: Remove redundant range check from __access_ok_vsyscall() Thomas Weißschuh
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

With the removal of the vDSO passthrough from the host,
FIXADDR_USER_START is always 0 and fixaddr_user_init() is dead code.

Remove it.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/um/kernel/mem.c | 107 ---------------------------------------------------
 1 file changed, 107 deletions(-)

diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index dc938715ec9d..39c4a7e21c6f 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -84,109 +84,6 @@ void __init mem_init(void)
 	kmalloc_ok = 1;
 }
 
-#if IS_ENABLED(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA)
-/*
- * Create a page table and place a pointer to it in a middle page
- * directory entry.
- */
-static void __init one_page_table_init(pmd_t *pmd)
-{
-	if (pmd_none(*pmd)) {
-		pte_t *pte = (pte_t *) memblock_alloc_low(PAGE_SIZE,
-							  PAGE_SIZE);
-		if (!pte)
-			panic("%s: Failed to allocate %lu bytes align=%lx\n",
-			      __func__, PAGE_SIZE, PAGE_SIZE);
-
-		set_pmd(pmd, __pmd(_KERNPG_TABLE +
-					   (unsigned long) __pa(pte)));
-		BUG_ON(pte != pte_offset_kernel(pmd, 0));
-	}
-}
-
-static void __init one_md_table_init(pud_t *pud)
-{
-#if CONFIG_PGTABLE_LEVELS > 2
-	pmd_t *pmd_table = (pmd_t *) memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
-	if (!pmd_table)
-		panic("%s: Failed to allocate %lu bytes align=%lx\n",
-		      __func__, PAGE_SIZE, PAGE_SIZE);
-
-	set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table)));
-	BUG_ON(pmd_table != pmd_offset(pud, 0));
-#endif
-}
-
-static void __init one_ud_table_init(p4d_t *p4d)
-{
-#if CONFIG_PGTABLE_LEVELS > 3
-	pud_t *pud_table = (pud_t *) memblock_alloc_low(PAGE_SIZE, PAGE_SIZE);
-	if (!pud_table)
-		panic("%s: Failed to allocate %lu bytes align=%lx\n",
-		      __func__, PAGE_SIZE, PAGE_SIZE);
-
-	set_p4d(p4d, __p4d(_KERNPG_TABLE + (unsigned long) __pa(pud_table)));
-	BUG_ON(pud_table != pud_offset(p4d, 0));
-#endif
-}
-
-static void __init fixrange_init(unsigned long start, unsigned long end,
-				 pgd_t *pgd_base)
-{
-	pgd_t *pgd;
-	p4d_t *p4d;
-	pud_t *pud;
-	pmd_t *pmd;
-	int i, j;
-	unsigned long vaddr;
-
-	vaddr = start;
-	i = pgd_index(vaddr);
-	j = pmd_index(vaddr);
-	pgd = pgd_base + i;
-
-	for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) {
-		p4d = p4d_offset(pgd, vaddr);
-		if (p4d_none(*p4d))
-			one_ud_table_init(p4d);
-		pud = pud_offset(p4d, vaddr);
-		if (pud_none(*pud))
-			one_md_table_init(pud);
-		pmd = pmd_offset(pud, vaddr);
-		for (; (j < PTRS_PER_PMD) && (vaddr < end); pmd++, j++) {
-			one_page_table_init(pmd);
-			vaddr += PMD_SIZE;
-		}
-		j = 0;
-	}
-}
-
-static void __init fixaddr_user_init( void)
-{
-	long size = FIXADDR_USER_END - FIXADDR_USER_START;
-	pte_t *pte;
-	phys_t p;
-	unsigned long v, vaddr = FIXADDR_USER_START;
-
-	if (!size)
-		return;
-
-	fixrange_init( FIXADDR_USER_START, FIXADDR_USER_END, swapper_pg_dir);
-	v = (unsigned long) memblock_alloc_low(size, PAGE_SIZE);
-	if (!v)
-		panic("%s: Failed to allocate %lu bytes align=%lx\n",
-		      __func__, size, PAGE_SIZE);
-
-	memcpy((void *) v , (void *) FIXADDR_USER_START, size);
-	p = __pa(v);
-	for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE,
-		      p += PAGE_SIZE) {
-		pte = virt_to_kpte(vaddr);
-		pte_set_val(*pte, p, PAGE_READONLY);
-	}
-}
-#endif
-
 void __init paging_init(void)
 {
 	unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
@@ -199,10 +96,6 @@ void __init paging_init(void)
 
 	max_zone_pfn[ZONE_NORMAL] = high_physmem >> PAGE_SHIFT;
 	free_area_init(max_zone_pfn);
-
-#if IS_ENABLED(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA)
-	fixaddr_user_init();
-#endif
 }
 
 /*

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 07/10] um: Remove redundant range check from __access_ok_vsyscall()
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
                   ` (5 preceding siblings ...)
  2025-10-28  9:15 ` [PATCH 06/10] um: Remove fixaddr_user_init() Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 08/10] um: Remove __access_ok_vsyscall() Thomas Weißschuh
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

The only caller __access_ok() is already doing the same check through
__addr_range_nowrap().

Remove the redundant check.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/um/include/asm/uaccess.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h
index 1c6e0ae41b0c..3770bdeee100 100644
--- a/arch/um/include/asm/uaccess.h
+++ b/arch/um/include/asm/uaccess.h
@@ -17,8 +17,7 @@
 
 #define __access_ok_vsyscall(addr, size) \
 	  (((unsigned long) (addr) >= FIXADDR_USER_START) && \
-	  ((unsigned long) (addr) + (size) <= FIXADDR_USER_END) && \
-	  ((unsigned long) (addr) + (size) >= (unsigned long)(addr)))
+	  ((unsigned long) (addr) + (size) <= FIXADDR_USER_END))
 
 #define __addr_range_nowrap(addr, size) \
 	((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 08/10] um: Remove __access_ok_vsyscall()
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
                   ` (6 preceding siblings ...)
  2025-10-28  9:15 ` [PATCH 07/10] um: Remove redundant range check from __access_ok_vsyscall() Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 09/10] x86/um: Remove FIXADDR_USER_START and FIXADDR_USE_END Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 10/10] um: Always set up AT_HWCAP and AT_PLATFORM Thomas Weißschuh
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

FIXADDR_USER_START and FIXADDR_USER_END are now always zero.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/um/include/asm/uaccess.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h
index 3770bdeee100..0df9ea4abda8 100644
--- a/arch/um/include/asm/uaccess.h
+++ b/arch/um/include/asm/uaccess.h
@@ -15,10 +15,6 @@
 	(((unsigned long) (addr) < TASK_SIZE) && \
 	 (((unsigned long) (addr) + (size)) < TASK_SIZE))
 
-#define __access_ok_vsyscall(addr, size) \
-	  (((unsigned long) (addr) >= FIXADDR_USER_START) && \
-	  ((unsigned long) (addr) + (size) <= FIXADDR_USER_END))
-
 #define __addr_range_nowrap(addr, size) \
 	((unsigned long) (addr) <= ((unsigned long) (addr) + (size)))
 
@@ -39,9 +35,7 @@ static inline int __access_ok(const void __user *ptr, unsigned long size);
 static inline int __access_ok(const void __user *ptr, unsigned long size)
 {
 	unsigned long addr = (unsigned long)ptr;
-	return __addr_range_nowrap(addr, size) &&
-		(__under_task_size(addr, size) ||
-		 __access_ok_vsyscall(addr, size));
+	return __addr_range_nowrap(addr, size) && __under_task_size(addr, size);
 }
 
 #define __get_kernel_nofault(dst, src, type, err_label)			\

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 09/10] x86/um: Remove FIXADDR_USER_START and FIXADDR_USE_END
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
                   ` (7 preceding siblings ...)
  2025-10-28  9:15 ` [PATCH 08/10] um: Remove __access_ok_vsyscall() Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  2025-10-28  9:15 ` [PATCH 10/10] um: Always set up AT_HWCAP and AT_PLATFORM Thomas Weißschuh
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

There are no users left.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/x86/um/asm/elf.h | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h
index 8d7df4684c38..fdd5a612f678 100644
--- a/arch/x86/um/asm/elf.h
+++ b/arch/x86/um/asm/elf.h
@@ -72,10 +72,6 @@ extern char * elf_aux_platform;
 #define ELF_PLATFORM_FALLBACK "i586"
 #define ELF_PLATFORM (elf_aux_platform ?: ELF_PLATFORM_FALLBACK)
 
-/* No user-accessible fixmap addresses, i.e. vsyscall */
-#define FIXADDR_USER_START      0
-#define FIXADDR_USER_END        0
-
 #else
 
 /* x86-64 relocation types, taken from asm-x86_64/elf.h */
@@ -157,10 +153,6 @@ extern char * elf_aux_platform;
 
 #define ELF_PLATFORM "x86_64"
 
-/* No user-accessible fixmap addresses, i.e. vsyscall */
-#define FIXADDR_USER_START      0
-#define FIXADDR_USER_END        0
-
 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
 struct linux_binprm;
 extern int arch_setup_additional_pages(struct linux_binprm *bprm,

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 10/10] um: Always set up AT_HWCAP and AT_PLATFORM
  2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
                   ` (8 preceding siblings ...)
  2025-10-28  9:15 ` [PATCH 09/10] x86/um: Remove FIXADDR_USER_START and FIXADDR_USE_END Thomas Weißschuh
@ 2025-10-28  9:15 ` Thomas Weißschuh
  9 siblings, 0 replies; 11+ messages in thread
From: Thomas Weißschuh @ 2025-10-28  9:15 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Kees Cook
  Cc: linux-um, linux-kernel, linux-mm, Thomas Weißschuh

Historically the code to set up AT_HWCAP and AT_PLATFORM was only built
for 32bit x86 as it was intermingled with the vDSO passthrough code.

Now that vDSO passthrough has been removed, always pass through AT_HWCAP
and AT_PLATFORM.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 arch/um/os-Linux/Makefile  | 4 +---
 arch/um/os-Linux/elf_aux.c | 7 ++++++-
 arch/um/os-Linux/main.c    | 4 ----
 arch/x86/um/Kconfig        | 3 ---
 arch/x86/um/asm/elf.h      | 7 ++++---
 5 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
index 70c73c22f715..f8d672d570d9 100644
--- a/arch/um/os-Linux/Makefile
+++ b/arch/um/os-Linux/Makefile
@@ -6,7 +6,7 @@
 # Don't instrument UML-specific code
 KCOV_INSTRUMENT                := n
 
-obj-y = execvp.o file.o helper.o irq.o main.o mem.o process.o \
+obj-y = elf_aux.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
 	registers.o sigio.o signal.o start_up.o time.o tty.o \
 	umid.o user_syms.o util.o skas/
 
@@ -14,8 +14,6 @@ CFLAGS_signal.o += -Wframe-larger-than=4096
 
 CFLAGS_main.o += -Wno-frame-larger-than
 
-obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o
-
 obj-$(CONFIG_SMP) += smp.o
 
 USER_OBJS := $(user-objs-y) elf_aux.o execvp.o file.o helper.o irq.o \
diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c
index f8927a5959d8..72f416edf252 100644
--- a/arch/um/os-Linux/elf_aux.c
+++ b/arch/um/os-Linux/elf_aux.c
@@ -14,12 +14,17 @@
 #include <elf_user.h>
 #include <mem_user.h>
 #include "internal.h"
+#include <linux/swab.h>
 
+#if __BITS_PER_LONG == 64
+typedef Elf64_auxv_t elf_auxv_t;
+#else
 typedef Elf32_auxv_t elf_auxv_t;
+#endif
 
 /* These are initialized very early in boot and never changed */
 char * elf_aux_platform;
-extern long elf_aux_hwcap;
+long elf_aux_hwcap;
 
 __init void scan_elf_aux( char **envp)
 {
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index 730723106228..7e114862a723 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -21,8 +21,6 @@
 
 #define STACKSIZE (8 * 1024 * 1024)
 
-long elf_aux_hwcap;
-
 static void __init set_stklim(void)
 {
 	struct rlimit lim;
@@ -149,9 +147,7 @@ int __init main(int argc, char **argv, char **envp)
 	install_fatal_handler(SIGINT);
 	install_fatal_handler(SIGTERM);
 
-#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
 	scan_elf_aux(envp);
-#endif
 
 	change_sig(SIGPIPE, 0);
 	ret = linux_main(argc, argv, envp);
diff --git a/arch/x86/um/Kconfig b/arch/x86/um/Kconfig
index 798c6cc53e82..bdd7c8e39b01 100644
--- a/arch/x86/um/Kconfig
+++ b/arch/x86/um/Kconfig
@@ -34,8 +34,5 @@ config X86_64
 config ARCH_HAS_SC_SIGNALS
 	def_bool !64BIT
 
-config ARCH_REUSE_HOST_VSYSCALL_AREA
-	def_bool !64BIT
-
 config GENERIC_HWEIGHT
 	def_bool y
diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h
index fdd5a612f678..22d0111b543b 100644
--- a/arch/x86/um/asm/elf.h
+++ b/arch/x86/um/asm/elf.h
@@ -68,9 +68,7 @@
 	pr_reg[16] = PT_REGS_SS(regs);		\
 } while (0);
 
-extern char * elf_aux_platform;
 #define ELF_PLATFORM_FALLBACK "i586"
-#define ELF_PLATFORM (elf_aux_platform ?: ELF_PLATFORM_FALLBACK)
 
 #else
 
@@ -151,7 +149,7 @@ extern char * elf_aux_platform;
 	(pr_reg)[25] = 0;					\
 	(pr_reg)[26] = 0;
 
-#define ELF_PLATFORM "x86_64"
+#define ELF_PLATFORM_FALLBACK "x86_64"
 
 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
 struct linux_binprm;
@@ -180,6 +178,9 @@ struct task_struct;
 extern long elf_aux_hwcap;
 #define ELF_HWCAP (elf_aux_hwcap)
 
+extern char *elf_aux_platform;
+#define ELF_PLATFORM (elf_aux_platform ?: ELF_PLATFORM_FALLBACK)
+
 #define SET_PERSONALITY(ex) do {} while(0)
 
 #endif

-- 
2.51.1.dirty



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-10-28  9:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-28  9:15 [PATCH 00/10] um: remove vDSO passthrough on 32bit x86 Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 01/10] um: Split out default elf_aux_platform Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 02/10] x86/um: Move ELF_PLATFORM fallback to x86-specific code Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 03/10] um: Split out default elf_aux_hwcap Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 04/10] x86/um: Do not inherit vDSO from host Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 05/10] x86/um: Drop gate area handling Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 06/10] um: Remove fixaddr_user_init() Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 07/10] um: Remove redundant range check from __access_ok_vsyscall() Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 08/10] um: Remove __access_ok_vsyscall() Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 09/10] x86/um: Remove FIXADDR_USER_START and FIXADDR_USE_END Thomas Weißschuh
2025-10-28  9:15 ` [PATCH 10/10] um: Always set up AT_HWCAP and AT_PLATFORM Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox