x86: Remove compat vdso support
Subsystems (3)
v3 cover x86: Remove compat vdso support
This is in the spirit of throwing patches at the list to see what sticks :)
This is intended as an alternative to my compat vdso relocation patches
(http://thread.gmane.org/gmane.linux.kernel/1665080)
v1 of this patch was thoroughly nakked out of existence. v2 is similar, but might survive the nakking. The critical difference is that this version defaults to the compatible vdso-less mode instead of the modern incompatible mode.
Changes from v2: Update a comment that I missed.
Changes from v1:
- CONFIG_ENABLE_VDSO32_BY_DEFAULT now defaults to n
- Improved the config text and description
- Improved the kernel parameter docs
Andy Lutomirski (2):
x86: Remove compat vdso support
x86_32: Remove user bit from identity map PDE
Documentation/kernel-parameters.txt | 23 +++- arch/x86/Kconfig | 28 +++-- arch/x86/include/asm/elf.h | 4 - arch/x86/include/asm/fixmap.h | 8 -- arch/x86/include/asm/pgtable_types.h | 7 +- arch/x86/include/asm/vdso.h | 5 +- arch/x86/vdso/vdso-layout.lds.S | 2 +- arch/x86/vdso/vdso32-setup.c | 234 ++++------------------------------- arch/x86/vdso/vdso32/vdso32.lds.S | 2 - 9 files changed, 62 insertions(+), 251 deletions(-)
Signature · 1 line
1.8.5.3
PATCH v3 1/2 x86: Remove compat vdso support
The compat vDSO is a complicated hack that's needed to maintain compatibility with a small range of never-released glibc versions.
This removes it and replaces it with a much simpler hack: a config option to disable the 32-bit vDSO by default.
--- Documentation/kernel-parameters.txt | 23 +++- arch/x86/Kconfig | 28 +++-- arch/x86/include/asm/elf.h | 4 - arch/x86/include/asm/fixmap.h | 8 -- arch/x86/include/asm/vdso.h | 5 +- arch/x86/vdso/vdso-layout.lds.S | 2 +- arch/x86/vdso/vdso32-setup.c | 234 ++++-------------------------------- arch/x86/vdso/vdso32/vdso32.lds.S | 2 - 8 files changed, 61 insertions(+), 245 deletions(-)
Documentation/kernel-parameters.txt +17 -6
@@ -3409,14 +3409,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted. of CONFIG_HIGHPTE. vdso= [X86,SH] - vdso=2: enable compat VDSO (default with COMPAT_VDSO) - vdso=1: enable VDSO (default) + On X86_32, this is an alias for vdso32=. Otherwise: + + vdso=1: enable VDSO (the default) vdso=0: disable VDSO mapping - vdso32= [X86] - vdso32=2: enable compat VDSO (default with COMPAT_VDSO) - vdso32=1: enable 32-bit VDSO (default) - vdso32=0: disable 32-bit VDSO mapping + vdso32= [X86] Control the 32-bit vDSO + vdso32=1: enable 32-bit VDSO + vdso32=0 or vdso32=2: disable 32-bit VDSO + + See the help text for CONFIG_ENABLE_VDSO32_BY_DEFAULT + for more details. The CONFIG_ENABLE_VDSO32_BY_DEFAULT + is set, the default is vdso32=1; otherwise, the default + is vdso32=0. + + For compatibility with older kernels, vdso32=2 is + an alias for vdso32=0. + + Try vdso32=0 if you encounter an error that says: + dl_main: Assertion `(void *) ph->p_vaddr == _rtld_local._dl_sysinfo_dso' failed! vector= [IA-64,SMP] vector=percpu: enable percpu vector domain
arch/x86/Kconfig +20 -8
@@ -1835,18 +1835,30 @@ config DEBUG_HOTPLUG_CPU0 If unsure, say N. -config COMPAT_VDSO - def_bool y - prompt "Compat VDSO support" +config ENABLE_VDSO32_BY_DEFAULT + def_bool n + prompt "Enable the 32-bit vDSO (breaks glibc 2.3.3)" depends on X86_32 || IA32_EMULATION ---help--- - Map the 32-bit VDSO to the predictable old-style address too. + Certain buggy versions of glibc will crash if they are + presented with a 32-bit vDSO that not mapped at the address + indicated in its segment table. - Say N here if you are running a sufficiently recent glibc - version (2.3.3 or later), to remove the high-mapped - VDSO mapping and to exclusively use the randomized VDSO. + The bug was introduced by f866314b89d56845f55e6f365e18b31ec978ec3a + and fixed by 3b3ddb4f7db98ec9e912ccdf54d35df4aa30e04a and + 49ad572a70b8aeb91e57483a11dd1b77e31c4468. Glibc 2.3.3 is + the only released version with the bug, but OpenSUSE 9 + contains a buggy "glibc 2.3.2". - If unsure, say Y. + The symptom of the bug is that everything crashes on startup, saying: + dl_main: Assertion `(void *) ph->p_vaddr == _rtld_local._dl_sysinfo_dso' failed! + + Saying N here changes the default value of the vdso32 boot + option from 1 to 0, which turns off the 32-bit vDSO entirely. + This works around the glibc bug but hurts performance. + + If unsure, say Y: if you are compiling your own kernel, you + are unlikely to be using a buggy version of glibc. config CMDLINE_BOOL bool "Built-in kernel command line"
arch/x86/include/asm/elf.h +0 -4
@@ -281,16 +281,12 @@ do { \#define STACK_RND_MASK (0x7ff) -#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO)) -#define ARCH_DLINFO ARCH_DLINFO_IA32(vdso_enabled)/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ #else /* CONFIG_X86_32 */ -#define VDSO_HIGH_BASE 0xffffe000U/* CONFIG_COMPAT_VDSO address */ -/* 1GB for 64bit, 8MB for 32bit */ #define STACK_RND_MASK (test_thread_flag(TIF_ADDR32) ? 0x7ff : 0x3fffff)
arch/x86/include/asm/fixmap.h +0 -8
@@ -40,15 +40,8 @@*/ extern unsigned long __FIXADDR_TOP;#define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP) - -#define FIXADDR_USER_START __fix_to_virt(FIX_VDSO) -#define FIXADDR_USER_END __fix_to_virt(FIX_VDSO - 1)#else #define FIXADDR_TOP (VSYSCALL_END-PAGE_SIZE) - -/* Only covers 32bit vsyscalls currently. Need another set for 64bit. */ -#define FIXADDR_USER_START ((unsigned long)VSYSCALL32_VSYSCALL) -#define FIXADDR_USER_END (FIXADDR_USER_START + PAGE_SIZE)#endif
@@ -74,7 +67,6 @@ extern unsigned long __FIXADDR_TOP;enum fixed_addresses {#ifdef CONFIG_X86_32 FIX_HOLE , -FIX_VDSO ,#else VSYSCALL_LAST_PAGE , VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE
arch/x86/include/asm/vdso.h +1 -4
@@ -2,8 +2,6 @@#define _ASM_X86_VDSO_H#if definedCONFIG_X86_32 || definedCONFIG_COMPAT -extern const char VDSO32_PRELINK []; -/* * Given a pointer to the vDSO image, find the pointer to VDSO32_name * as that symbol is defined in the vDSO sources or linker script.
@@ -11,8 +9,7 @@ extern const char VDSO32_PRELINK[];#define VDSO32_SYMBOL (base, name) \ ({ \ extern const char VDSO32_##name[]; \ - (void __user *)(VDSO32_##name - VDSO32_PRELINK + \ - (unsigned long)(base)); \ + (void __user *)(VDSO32_##name + (unsigned long)(base)); \ })#endif
arch/x86/vdso/vdso-layout.lds.S +1 -1
@@ -6,7 +6,7 @@ SECTIONS { - . = VDSO_PRELINK + SIZEOF_HEADERS; + . = SIZEOF_HEADERS; .hash : { *(.hash) } :text .gnu.hash : { *(.gnu.hash) }
arch/x86/vdso/vdso32-setup.c +22 -212
314 lines not on this page · raw message
arch/x86/vdso/vdso32/vdso32.lds.S +0 -2
@@ -8,7 +8,6 @@ * values visible using the asm-x86/vdso.h macros from the kernel proper. */ -#define VDSO_PRELINK 0 #include "../vdso-layout.lds.S" /* The ELF entry point can be used to set the AT_SYSINFO value. */
@@ -31,7 +30,6 @@ VERSION /* * Symbols we define here called VDSO* get their values into vdso32-syms.h. */ -VDSO32_PRELINK = VDSO_PRELINK; VDSO32_vsyscall = __kernel_vsyscall; VDSO32_sigreturn = __kernel_sigreturn; VDSO32_rt_sigreturn = __kernel_rt_sigreturn;
Signature · 1 line
1.8.5.3
PATCH v3 2/2 x86_32: Remove user bit from identity map PDE
In reply to Andy LutomirskiThe only reason that the user bit was set was to support userspace access to the compat vDSO in the fixmap. The compat vDSO is gone, so the user bit can be removed.
--- arch/x86/include/asm/pgtable_types.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
arch/x86/include/asm/pgtable_types.h +1 -6
@@ -214,13 +214,8 @@#ifdef CONFIG_X86_64 #define __PAGE_KERNEL_IDENT_LARGE_EXEC __PAGE_KERNEL_LARGE_EXEC#else -/* -* For PDE_IDENT_ATTR include USER bit. As the PDE and PTE protection -* bits are combined, this will alow user to access the high address mapped -* VDSO in the presence of CONFIG_COMPAT_VDSO -*/ #define PTE_IDENT_ATTR 0x003/* PRESENT+RW */ -#define PDE_IDENT_ATTR 0x067/* PRESENT+RW+USER+DIRTY+ACCESSED */ +#define PDE_IDENT_ATTR 0x063/* PRESENT+RW+DIRTY+ACCESSED */ #define PGD_IDENT_ATTR 0x001/* PRESENT (no other attributes) */ #endif
Signature · 1 line
1.8.5.3