x86/asm changes for v4.4
Subsystems (7)
Linus,
Please pull the latest x86-asm-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-asm-for-linus
# HEAD: 3bd29515d1cad26fa85a1a9b442de8816c1f5c54 x86/entry/32: Fix FS and GS restore in opportunistic SYSEXIT
The main change in this cycle is another step in the big x86 system call interface rework by Andy Lutomirski, which moves most of the low level x86 entry code from assembly to C, for all syscall entries except native 64-bit system calls:
arch/x86/entry/entry_32.S | 182 +++---- arch/x86/entry/entry_64_compat.S | 547 +++++----------------
... our hope is that the final remaining step (converting native 64-bit system calls) will be less painful as all the previous steps, given that most of the legacies and quirks are concentrated around native 32-bit and compat environments.
Thanks,
Ingo
------------------>
Andy Lutomirski (42):
x86/sched/64: Don't save flags on context switch (reinstated) x86/uaccess: Tell the compiler that uaccess is unlikely to fault x86/uaccess: Add unlikely() to __chk_range_not_ok() failure paths selftests/x86: Add a test for vDSO unwinding
selftests/x86: Add a test for ptrace syscall restart and arg modification x86/entry/64/compat: Fix SYSENTER's NT flag before user memory access x86/entry, locking/lockdep: Move lockdep_sys_exit() to prepare_exit_to_usermode() x86/entry/64/compat: After SYSENTER, move STI after the NT fixup x86/vdso: Remove runtime 32-bit vDSO selection
x86/asm: Re-add parts of the manual CFI infrastructure
x86/vdso: Define BUILD_VDSO while building and emit .eh_frame in asm x86/vdso: Replace hex int80 CFI annotations with GAS directives x86/elf/64: Clear more registers in elf_common_init()
x86/vdso/32: Save extra registers in the INT80 vsyscall path x86/entry/64/compat: Disable SYSENTER and SYSCALL32 entries x86/entry/64/compat: Remove audit optimizations x86/entry/64/compat: Remove most of the fast system call machinery x86/entry/64/compat: Set up full pt_regs for all compat syscalls x86/entry/syscalls: Move syscall table declarations into asm/syscalls.h x86/syscalls: Give sys_call_ptr_t a useful type
x86/entry: Add do_syscall_32(), a C function to do 32-bit syscalls x86/entry/64/compat: Migrate the body of the syscall entry to C x86/entry: Add C code for fast system call entries
x86/vdso/compat: Wire up SYSENTER and SYSCSALL for compat userspace x86/entry/compat: Implement opportunistic SYSRETL for compat syscalls x86/entry/32: Open-code return tracking from fork and kthreads x86/entry/32: Switch INT80 to the new C syscall path
x86/entry/32: Re-implement SYSENTER using the new C path
x86/asm: Remove thread_info.sysenter_return
x86/entry: Remove unnecessary IRQ twiddling in fast 32-bit syscalls x86/entry: Make irqs_disabled checks in exit code depend on lockdep x86/entry: Force inlining of 32-bit syscall code
x86/entry: Micro-optimize compat fast syscall arg fetch
x86/entry: Hide two syscall entry assertions behind CONFIG_DEBUG_ENTRY x86/entry: Use pt_regs_to_thread_info() in syscall entry tracing x86/entry: Split and inline prepare_exit_to_usermode()
x86/entry: Split and inline syscall_return_slowpath() selftests/x86: Style fixes for the 'unwind_vdso' test
x86/asm: Remove the xyz_cfi macros from dwarf2.h
um/x86: Fix build after x86 syscall changes
x86/entry/32: Fix entry_INT80_32() to expect interrupts to be on x86/entry/32: Fix FS and GS restore in opportunistic SYSEXIT
Borislav Petkov (2):
x86/entry/vsyscall: Fix undefined symbol warning x86/entry/64/compat: Document sysenter_fix_flags's reason for existence
Denys Vlasenko (2):
x86/asm/entry/32, selftests: Add 'test_syscall_vdso' test x86/asm: Force inlining of cpu_relax()
Kees Cook (1):
x86/entry/vsyscall: Add CONFIG to control default
arch/x86/Kconfig | 49 ++ arch/x86/Makefile | 10 +- arch/x86/entry/common.c | 264 ++++++++-- arch/x86/entry/entry_32.S | 182 +++---- arch/x86/entry/entry_64.S | 9 +- arch/x86/entry/entry_64_compat.S | 547 +++++---------------- arch/x86/entry/syscall_32.c | 9 +- arch/x86/entry/syscall_64.c | 4 +- arch/x86/entry/syscalls/syscall_32.tbl | 12 +- arch/x86/entry/vdso/Makefile | 39 +- arch/x86/entry/vdso/vdso2c.c | 2 +- arch/x86/entry/vdso/vdso32-setup.c | 28 +- arch/x86/entry/vdso/vdso32/int80.S | 56 --- arch/x86/entry/vdso/vdso32/syscall.S | 75 --- arch/x86/entry/vdso/vdso32/sysenter.S | 116 ----- arch/x86/entry/vdso/vdso32/system_call.S | 57 +++ arch/x86/entry/vdso/vma.c | 13 +- arch/x86/entry/vsyscall/vsyscall_64.c | 9 +- arch/x86/ia32/ia32_signal.c | 4 +- arch/x86/include/asm/dwarf2.h | 84 ++++ arch/x86/include/asm/elf.h | 10 +- arch/x86/include/asm/processor.h | 4 +- arch/x86/include/asm/switch_to.h | 12 +- arch/x86/include/asm/syscall.h | 14 +- arch/x86/include/asm/thread_info.h | 1 - arch/x86/include/asm/uaccess.h | 14 +- arch/x86/include/asm/vdso.h | 10 +- arch/x86/kernel/asm-offsets.c | 3 - arch/x86/kernel/signal.c | 4 +- arch/x86/um/asm/syscall.h | 4 + arch/x86/um/sys_call_table_32.c | 7 +- arch/x86/um/sys_call_table_64.c | 7 +- arch/x86/xen/setup.c | 13 +- tools/testing/selftests/x86/Makefile | 6 +- tools/testing/selftests/x86/ptrace_syscall.c | 294 +++++++++++ .../testing/selftests/x86/raw_syscall_helper_32.S | 46 ++ tools/testing/selftests/x86/test_syscall_vdso.c | 401 +++++++++++++++ tools/testing/selftests/x86/thunks_32.S | 55 +++ tools/testing/selftests/x86/unwind_vdso.c | 211 ++++++++ 39 files changed, 1709 insertions(+), 976 deletions(-) delete mode 100644 arch/x86/entry/vdso/vdso32/int80.S delete mode 100644 arch/x86/entry/vdso/vdso32/syscall.S delete mode 100644 arch/x86/entry/vdso/vdso32/sysenter.S create mode 100644 arch/x86/entry/vdso/vdso32/system_call.S create mode 100644 arch/x86/include/asm/dwarf2.h create mode 100644 tools/testing/selftests/x86/ptrace_syscall.c create mode 100644 tools/testing/selftests/x86/raw_syscall_helper_32.S create mode 100644 tools/testing/selftests/x86/test_syscall_vdso.c create mode 100644 tools/testing/selftests/x86/thunks_32.S create mode 100644 tools/testing/selftests/x86/unwind_vdso.c
arch/x86/Kconfig +49 -0
@@ -2042,6 +2042,55 @@ config COMPAT_VDSO If unsure, say N: if you are compiling your own kernel, you are unlikely to be using a buggy version of glibc. +choice + prompt "vsyscall table for legacy applications" + depends on X86_64 + default LEGACY_VSYSCALL_EMULATE + help + Legacy user code that does not know how to find the vDSO expects + to be able to issue three syscalls by calling fixed addresses in + kernel space. Since this location is not randomized with ASLR, + it can be used to assist security vulnerability exploitation. + + This setting can be changed at boot time via the kernel command + line parameter vsyscall=[native|emulate|none]. + + On a system with recent enough glibc (2.14 or newer) and no + static binaries, you can say None without a performance penalty + to improve security. + + If unsure, select "Emulate". + + config LEGACY_VSYSCALL_NATIVE + bool "Native" + help + Actual executable code is located in the fixed vsyscall + address mapping, implementing time() efficiently. Since + this makes the mapping executable, it can be used during + security vulnerability exploitation (traditionally as + ROP gadgets). This configuration is not recommended. + + config LEGACY_VSYSCALL_EMULATE + bool "Emulate" + help + The kernel traps and emulates calls into the fixed + vsyscall address mapping. This makes the mapping + non-executable, but it still contains known contents, + which could be used in certain rare security vulnerability + exploits. This configuration is recommended when userspace + still uses the vsyscall area. + + config LEGACY_VSYSCALL_NONE + bool "None" + help + There will be no vsyscall mapping at all. This will + eliminate any risk of ASLR bypass due to the vsyscall + fixed address mapping. Attempts to use the vsyscalls + will be reported to dmesg, so that either old or + malicious userspace programs can be identified. + +endchoice + config CMDLINE_BOOL bool "Built-in kernel command line" ---help---
arch/x86/Makefile +8 -2
@@ -159,6 +159,12 @@ endif sp-$(CONFIG_X86_32) := esp sp-$(CONFIG_X86_64) := rsp +# do binutils support CFI? +cfi := $(call as-instr,.cfi_startproc\n.cfi_rel_offset $(sp-y)$(comma)0\n.cfi_endproc,-DCONFIG_AS_CFI=1) +# is .cfi_signal_frame supported too? +cfi-sigframe := $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1) +cfi-sections := $(call as-instr,.cfi_sections .debug_frame,-DCONFIG_AS_CFI_SECTIONS=1) + # does binutils support specific instructions? asinstr := $(call as-instr,fxsaveq (%rax),-DCONFIG_AS_FXSAVEQ=1) asinstr += $(call as-instr,pshufb %xmm0$(comma)%xmm0,-DCONFIG_AS_SSSE3=1)
@@ -166,8 +172,8 @@ asinstr += $(call as-instr,crc32l %eax$(comma)%eax,-DCONFIG_AS_CRC32=1) avx_instr := $(call as-instr,vxorps %ymm0$(comma)%ymm1$(comma)%ymm2,-DCONFIG_AS_AVX=1) avx2_instr :=$(call as-instr,vpbroadcastb %xmm0$(comma)%ymm1,-DCONFIG_AS_AVX2=1) -KBUILD_AFLAGS += $(asinstr) $(avx_instr) $(avx2_instr) -KBUILD_CFLAGS += $(asinstr) $(avx_instr) $(avx2_instr) +KBUILD_AFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr) $(avx2_instr) +KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr) $(avx2_instr) LDFLAGS := -m elf_$(UTS_MACHINE)
arch/x86/entry/common.c +216 -48
336 lines not on this page · raw message
arch/x86/entry/entry_32.S +60 -122
245 lines not on this page · raw message
arch/x86/entry/entry_64.S +2 -7
@@ -391,20 +391,16 @@ GLOBAL(stub_execveat) jmp return_from_execve END(stub_execveat) -#if defined(CONFIG_X86_X32_ABI) || defined(CONFIG_IA32_EMULATION) +#if defined(CONFIG_X86_X32_ABI) .align 8 GLOBAL(stub_x32_execve) -GLOBAL(stub32_execve) call compat_sys_execve jmp return_from_execve -END(stub32_execve) END(stub_x32_execve) .align 8 GLOBAL(stub_x32_execveat) -GLOBAL(stub32_execveat) call compat_sys_execveat jmp return_from_execve -END(stub32_execveat) END(stub_x32_execveat) #endif
@@ -557,7 +553,6 @@ END(irq_entries_start) jz retint_kernel /* Interrupt came from user space */ - LOCKDEP_SYS_EXIT_IRQ GLOBAL(retint_user) mov %rsp,%rdi call prepare_exit_to_usermode
@@ -587,7 +582,7 @@ GLOBAL(retint_user) * At this label, code paths which return to kernel and to user, * which come from interrupts/exception and from syscalls, merge. */ -restore_regs_and_iret: +GLOBAL(restore_regs_and_iret) RESTORE_EXTRA_REGS restore_c_regs_and_iret: RESTORE_C_REGS
arch/x86/entry/entry_64_compat.S +134 -413
645 lines not on this page · raw message
arch/x86/entry/syscall_32.c +3 -6
@@ -4,24 +4,21 @@#include <linux/sys.h> #include <linux/cache.h> #include <asm/asm-offsets.h> +#include <asm/syscall.h> #ifdef CONFIG_IA32_EMULATION #define SYM (sym, compat) compat#else #define SYM (sym, compat) sym -#define ia32_sys_call_table sys_call_table -#define __NR_syscall_compat_max __NR_syscall_max#endif -#define __SYSCALL_I386 (nr, sym, compat) extern asmlinkage void SYM(sym, compat)(void) ; +#define __SYSCALL_I386 (nr, sym, compat) extern asmlinkage long SYM(sym, compat)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ;#include <asm/syscalls_32.h> #undef __SYSCALL_I386#define __SYSCALL_I386 (nr, sym, compat) [nr] = SYM(sym, compat), -typedef asmlinkage void (*sys_call_ptr_t)(void); - -extern asmlinkage void sys_ni_syscall(void); +extern asmlinkage long sys_ni_syscall (unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long ); __visible const sys_call_ptr_t ia32_sys_call_table[__NR_syscall_compat_max+1] = {/*
arch/x86/entry/syscall_64.c +2 -2
@@ -14,13 +14,13 @@# define __SYSCALL_X32 (nr, sym, compat)/* nothing */ #endif -#define __SYSCALL_64 (nr, sym, compat) extern asmlinkage void sym(void) ; +#define __SYSCALL_64 (nr, sym, compat) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ;#include <asm/syscalls_64.h> #undef __SYSCALL_64#define __SYSCALL_64 (nr, sym, compat) [nr] = sym, -extern void sys_ni_syscall (void ); +extern long sys_ni_syscall (unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long ); asmlinkage const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = {/*
arch/x86/entry/syscalls/syscall_32.tbl +6 -6
@@ -8,7 +8,7 @@ # 0 i386 restart_syscall sys_restart_syscall 1 i386 exit sys_exit -2 i386 fork sys_fork stub32_fork +2 i386 fork sys_fork sys_fork 3 i386 read sys_read 4 i386 write sys_write 5 i386 open sys_open compat_sys_open
@@ -17,7 +17,7 @@ 8 i386 creat sys_creat 9 i386 link sys_link 10 i386 unlink sys_unlink -11 i386 execve sys_execve stub32_execve +11 i386 execve sys_execve compat_sys_execve 12 i386 chdir sys_chdir 13 i386 time sys_time compat_sys_time 14 i386 mknod sys_mknod
@@ -125,7 +125,7 @@ 116 i386 sysinfo sys_sysinfo compat_sys_sysinfo 117 i386 ipc sys_ipc compat_sys_ipc 118 i386 fsync sys_fsync -119 i386 sigreturn sys_sigreturn stub32_sigreturn +119 i386 sigreturn sys_sigreturn sys32_sigreturn 120 i386 clone sys_clone stub32_clone 121 i386 setdomainname sys_setdomainname 122 i386 uname sys_newuname
@@ -179,7 +179,7 @@ 170 i386 setresgid sys_setresgid16 171 i386 getresgid sys_getresgid16 172 i386 prctl sys_prctl -173 i386 rt_sigreturn sys_rt_sigreturn stub32_rt_sigreturn +173 i386 rt_sigreturn sys_rt_sigreturn sys32_rt_sigreturn 174 i386 rt_sigaction sys_rt_sigaction compat_sys_rt_sigaction 175 i386 rt_sigprocmask sys_rt_sigprocmask 176 i386 rt_sigpending sys_rt_sigpending compat_sys_rt_sigpending
@@ -196,7 +196,7 @@ 187 i386 sendfile sys_sendfile compat_sys_sendfile 188 i386 getpmsg 189 i386 putpmsg -190 i386 vfork sys_vfork stub32_vfork +190 i386 vfork sys_vfork sys_vfork 191 i386 ugetrlimit sys_getrlimit compat_sys_getrlimit 192 i386 mmap2 sys_mmap_pgoff 193 i386 truncate64 sys_truncate64 sys32_truncate64
@@ -364,7 +364,7 @@ 355 i386 getrandom sys_getrandom 356 i386 memfd_create sys_memfd_create 357 i386 bpf sys_bpf -358 i386 execveat sys_execveat stub32_execveat +358 i386 execveat sys_execveat compat_sys_execveat 359 i386 socket sys_socket 360 i386 socketpair sys_socketpair 361 i386 bind sys_bind
arch/x86/entry/vdso/Makefile +13 -26
@@ -19,9 +19,7 @@ obj-y += vma.o # vDSO images to build vdso_img-$(VDSO64-y) += 64 vdso_img-$(VDSOX32-y) += x32 -vdso_img-$(VDSO32-y) += 32-int80 -vdso_img-$(CONFIG_IA32_EMULATION) += 32-syscall -vdso_img-$(VDSO32-y) += 32-sysenter +vdso_img-$(VDSO32-y) += 32 obj-$(VDSO32-y) += vdso32-setup.o
@@ -69,7 +67,7 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \ -fno-omit-frame-pointer -foptimize-sibling-calls \ - -DDISABLE_BRANCH_PROFILING + -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO $(vobjs): KBUILD_CFLAGS += $(CFL)
@@ -122,15 +120,6 @@ $(obj)/%.so: $(obj)/%.so.dbg $(obj)/vdsox32.so.dbg: $(src)/vdsox32.lds $(vobjx32s) FORCE $(call if_changed,vdso) -# -# Build multiple 32-bit vDSO images to choose from at boot time. -# -vdso32.so-$(VDSO32-y) += int80 -vdso32.so-$(CONFIG_IA32_EMULATION) += syscall -vdso32.so-$(VDSO32-y) += sysenter - -vdso32-images = $(vdso32.so-y:%=vdso32-%.so) - CPPFLAGS_vdso32.lds = $(CPPFLAGS_vdso.lds) VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1
@@ -139,14 +128,12 @@ VDSO_LDFLAGS_vdso32.lds = -m32 -Wl,-m,elf_i386 -Wl,-soname=linux-gate.so.1 override obj-dirs = $(dir $(obj)) $(obj)/vdso32/ targets += vdso32/vdso32.lds -targets += vdso32/note.o vdso32/vclock_gettime.o $(vdso32.so-y:%=vdso32/%.o) +targets += vdso32/note.o vdso32/vclock_gettime.o vdso32/system_call.o targets += vdso32/vclock_gettime.o -$(obj)/vdso32.o: $(vdso32-images:%=$(obj)/%) - -KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -$(vdso32-images:%=$(obj)/%.dbg): KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) -$(vdso32-images:%=$(obj)/%.dbg): asflags-$(CONFIG_X86_64) += -m32 +KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO +$(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) +$(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32 KBUILD_CFLAGS_32 := $(filter-out -m64,$(KBUILD_CFLAGS)) KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32))
@@ -157,13 +144,13 @@ KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector) KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) KBUILD_CFLAGS_32 += -fno-omit-frame-pointer KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING -$(vdso32-images:%=$(obj)/%.dbg): KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) +$(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) -$(vdso32-images:%=$(obj)/%.dbg): $(obj)/vdso32-%.so.dbg: FORCE \ - $(obj)/vdso32/vdso32.lds \ - $(obj)/vdso32/vclock_gettime.o \ - $(obj)/vdso32/note.o \ - $(obj)/vdso32/%.o +$(obj)/vdso32.so.dbg: FORCE \ + $(obj)/vdso32/vdso32.lds \ + $(obj)/vdso32/vclock_gettime.o \ + $(obj)/vdso32/note.o \ + $(obj)/vdso32/system_call.o $(call if_changed,vdso) #
@@ -206,4 +193,4 @@ $(vdso_img_insttargets): install_%: $(obj)/%.dbg $(MODLIB)/vdso FORCE PHONY += vdso_install $(vdso_img_insttargets) vdso_install: $(vdso_img_insttargets) FORCE -clean-files := vdso32-syscall* vdso32-sysenter* vdso32-int80* vdso64* vdso-image-*.c vdsox32.so* +clean-files := vdso32.so vdso32.so.dbg vdso64* vdso-image-*.c vdsox32.so*
arch/x86/entry/vdso/vdso2c.c +1 -1
@@ -98,10 +98,10 @@ struct vdso_sym required_syms[] = { "VDSO_FAKE_SECTION_TABLE_END", false }, {"VDSO32_NOTE_MASK", true}, - {"VDSO32_SYSENTER_RETURN", true}, {"__kernel_vsyscall", true}, {"__kernel_sigreturn", true}, {"__kernel_rt_sigreturn", true}, + {"int80_landing_pad", true}, }; __attribute__((format(printf, 1, 2))) __attribute__((noreturn))
arch/x86/entry/vdso/vdso32-setup.c +1 -27
@@ -48,35 +48,9 @@ __setup("vdso32=", vdso32_setup);__setup_param ("vdso=" , vdso_setup, vdso32_setup,0 );#endif -#ifdef CONFIG_X86_64 - -#define vdso32_sysenter () (boot_cpu_has(X86_FEATURE_SYSENTER32)) -#define vdso32_syscall () (boot_cpu_has(X86_FEATURE_SYSCALL32)) - -#else /* CONFIG_X86_32 */ - -#define vdso32_sysenter () (boot_cpu_has(X86_FEATURE_SEP)) -#define vdso32_syscall () (0) - -#endif /* CONFIG_X86_64 */ - -#if defined(CONFIG_X86_32 ) || defined(CONFIG_COMPAT ) -const struct vdso_image *selected_vdso32; -#endif -int __init sysenter_setup (void ) { -#ifdef CONFIG_COMPAT -if (vdso32_syscall ()) - selected_vdso32 = &vdso_image_32_syscall; - else -#endif -if (vdso32_sysenter ()) - selected_vdso32 = &vdso_image_32_sysenter; -else - selected_vdso32 = &vdso_image_32_int80; - -init_vdso_image (selected_vdso32); +init_vdso_image (&vdso_image_32);return 0 ; }
arch/x86/entry/vdso/vdso32/int80.S deleted +0 -56
56 lines not on this page · raw message
arch/x86/entry/vdso/vdso32/syscall.S deleted +0 -75
75 lines not on this page · raw message
arch/x86/entry/vdso/vdso32/sysenter.S deleted +0 -116
116 lines not on this page · raw message
arch/x86/entry/vdso/vdso32/system_call.S new file +57 -0
57 lines not on this page · raw message
arch/x86/entry/vdso/vma.c +1 -12
@@ -180,21 +180,10 @@ static int map_vdso(const struct vdso_image *image, bool calculate_addr)#if defined(CONFIG_X86_32 ) || defined(CONFIG_IA32_EMULATION )static int load_vdso32 (void ) { -int ret; -if (vdso32_enabled !=1 )/* Other values all mean "disabled" */ return 0 ; - ret =map_vdso (selected_vdso32, false); -if (ret) -return ret; - -if (selected_vdso32->sym_VDSO32_SYSENTER_RETURN) -current_thread_info ()->sysenter_return = - current->mm->context.vdso + - selected_vdso32->sym_VDSO32_SYSENTER_RETURN; - -return 0 ; +return map_vdso (&vdso_image_32, false); }#endif
arch/x86/entry/vsyscall/vsyscall_64.c +8 -1
@@ -38,7 +38,14 @@#define CREATE_TRACE_POINTS #include "vsyscall_trace.h" -static enum {EMULATE ,NATIVE ,NONE } vsyscall_mode =EMULATE ; +static enum { EMULATE, NATIVE, NONE } vsyscall_mode = +#if defined(CONFIG_LEGACY_VSYSCALL_NATIVE ) +NATIVE ; +#elif defined(CONFIG_LEGACY_VSYSCALL_NONE ) +NONE ; +#else +EMULATE ; +#endif static int __init vsyscall_setup (char *str) {
arch/x86/ia32/ia32_signal.c +2 -2
@@ -289,7 +289,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,/* Return stub is in 32bit vsyscall page */ if (current->mm->context.vdso) restorer = current->mm->context.vdso + - selected_vdso32->sym___kernel_sigreturn; + vdso_image_32.sym___kernel_sigreturn;else restorer = &frame->retcode; }
@@ -368,7 +368,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig, restorer = ksig->ka.sa.sa_restorer; else restorer = current->mm->context.vdso + - selected_vdso32->sym___kernel_rt_sigreturn; + vdso_image_32.sym___kernel_rt_sigreturn;put_user_ex (ptr_to_compat (restorer), &frame->pretcode);/*
arch/x86/include/asm/dwarf2.h new file +84 -0
84 lines not on this page · raw message
arch/x86/include/asm/elf.h +5 -5
@@ -171,11 +171,11 @@ do { \static inline void elf_common_init (struct thread_struct *t,struct pt_regs *regs,const u16 ds) { -/* Commented-out registers are cleared in stub_execve */ -/*regs->ax = regs->bx =*/ regs->cx = regs->dx =0 ; - regs->si = regs->di/*= regs->bp*/ =0 ; +/* ax gets execve's return value. */ +/*regs->ax = */ regs->bx = regs->cx = regs->dx =0 ; + regs->si = regs->di = regs->bp =0 ; regs->r8 = regs->r9 = regs->r10 = regs->r11 =0 ; -/*regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0;*/ + regs->r12 = regs->r13 = regs->r14 = regs->r15 =0 ; t->fs = t->gs =0 ; t->fsindex = t->gsindex =0 ; t->ds = t->es = ds;
@@ -328,7 +328,7 @@ else \#define VDSO_ENTRY \ ((unsigned long)current->mm->context.vdso + \ - selected_vdso32->sym___kernel_vsyscall) + vdso_image_32.sym___kernel_vsyscall)struct linux_binprm ;
arch/x86/include/asm/processor.h +2 -2
@@ -556,12 +556,12 @@ static inline unsigned int cpuid_edx(unsigned int op) }/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ -static inline void rep_nop (void ) +static __always_inline void rep_nop(void) { asmvolatile ("rep; nop" :::"memory" ); } -static inline void cpu_relax (void ) +static __always_inline void cpu_relax(void) {rep_nop (); }
arch/x86/include/asm/switch_to.h +8 -4
@@ -79,12 +79,12 @@ do { \#else /* CONFIG_X86_32 */ /* frame pointer must be last for get_wchan */ -#define SAVE_CONTEXT "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t" -#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t" +#define SAVE_CONTEXT "pushq %%rbp ; movq %%rsi,%%rbp\n\t" +#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp\t"#define __EXTRA_CLOBBER \ , "rcx", "rbx", "rdx", "r8", "r9", "r10", "r11", \ - "r12", "r13", "r14", "r15" + "r12", "r13", "r14", "r15", "flags"#ifdef CONFIG_CC_STACKPROTECTOR #define __switch_canary \
@@ -100,7 +100,11 @@ do { \#define __switch_canary_iparam#endif /* CC_STACKPROTECTOR */ -/* Save restore flags to clear handle leaking NT */ +/* +* There is no need to save or restore flags, because flags are always +* clean in kernel mode, with the possible exception of IOPL. Kernel IOPL +* has no effect. +*/ #define switch_to (prev, next, last) \ asm volatile(SAVE_CONTEXT \ "movq %%rsp,%P[threadrsp](%[prev])\n\t"/* save RSP */ \
arch/x86/include/asm/syscall.h +13 -1
@@ -20,9 +20,21 @@#include <asm/thread_info.h> /* for TS_COMPAT */ #include <asm/unistd.h> -typedef void (*sys_call_ptr_t )(void ); +typedef asmlinkage long (*sys_call_ptr_t )(unsigned long ,unsigned long , +unsigned long ,unsigned long , +unsigned long ,unsigned long );extern const sys_call_ptr_t sys_call_table[]; +#if defined(CONFIG_X86_32 ) +#define ia32_sys_call_table sys_call_table +#define __NR_syscall_compat_max __NR_syscall_max +#define IA32_NR_syscalls NR_syscalls +#endif + +#if defined(CONFIG_IA32_EMULATION ) +extern const sys_call_ptr_t ia32_sys_call_table[]; +#endif +/* * Only the low 32 bits of orig_ax are meaningful, so we return int. * This importantly ignores the high bits on 64-bit, so comparisons
arch/x86/include/asm/thread_info.h +0 -1
@@ -59,7 +59,6 @@ struct thread_info {__u32 cpu;/* current CPU */ int saved_preempt_count;mm_segment_t addr_limit; -void __user *sysenter_return; unsigned int sig_on_uaccess_error:1; unsigned int uaccess_err:1; /* uaccess failed */ };
arch/x86/include/asm/uaccess.h +7 -7
@@ -51,13 +51,13 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un* limit, not add it to the address). */ if (__builtin_constant_p (size)) -return addr > limit - size; +return unlikely (addr > limit - size);/* Arbitrary sizes? Be careful about overflow */ addr += size; -if (addr < size) +if (unlikely (addr < size))return true; -return addr > limit; +return unlikely (addr > limit); }#define __range_not_ok (addr, size, limit) \
@@ -182,7 +182,7 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL)) : "=a" (__ret_gu), "=r" (__val_gu) \ : "0" (ptr), "i" (sizeof(*(ptr)))); \ (x) = (__force __typeof__(*(ptr))) __val_gu; \ - __ret_gu; \ +__builtin_expect (__ret_gu,0 ); \ })#define __put_user_x (size, x, ptr, __ret_pu) \
@@ -278,7 +278,7 @@ extern void __put_user_8(void);__put_user_x (X , __pu_val, ptr, __ret_pu); \break ; \ } \ - __ret_pu; \ +__builtin_expect (__ret_pu,0 ); \ })#define __put_user_size (x, ptr, size, retval, errret) \
@@ -401,7 +401,7 @@ do { \ ({ \int __pu_err; \__put_user_size ((x), (ptr), (size), __pu_err, -EFAULT ); \ - __pu_err; \ +__builtin_expect (__pu_err,0 ); \ })#define __get_user_nocheck (x, ptr, size) \
@@ -410,7 +410,7 @@ do { \unsigned long __gu_val; \__get_user_size (__gu_val, (ptr), (size), __gu_err, -EFAULT ); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ - __gu_err; \ +__builtin_expect (__gu_err,0 ); \ })/* FIXME: this hack is definitely wrong -AK */
arch/x86/include/asm/vdso.h +2 -8
@@ -26,7 +26,7 @@ struct vdso_image {long sym___kernel_sigreturn;long sym___kernel_rt_sigreturn;long sym___kernel_vsyscall; -long sym_VDSO32_SYSENTER_RETURN; +long sym_int80_landing_pad; };#ifdef CONFIG_X86_64
@@ -38,13 +38,7 @@ extern const struct vdso_image vdso_image_x32;#endif #if definedCONFIG_X86_32 || definedCONFIG_COMPAT -extern const struct vdso_image vdso_image_32_int80; -#ifdef CONFIG_COMPAT -extern const struct vdso_image vdso_image_32_syscall; -#endif -extern const struct vdso_image vdso_image_32_sysenter; - -extern const struct vdso_image *selected_vdso32; +extern const struct vdso_image vdso_image_32;#endif extern void __init init_vdso_image (const struct vdso_image *image);
arch/x86/kernel/asm-offsets.c +0 -3
@@ -54,9 +54,6 @@ void common(void) {OFFSET (IA32_SIGCONTEXT_ip, sigcontext_ia32, ip);BLANK (); -OFFSET (TI_sysenter_return, thread_info, sysenter_return); - -BLANK ();OFFSET (IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);#endif
arch/x86/kernel/signal.c +2 -2
@@ -299,7 +299,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,if (current->mm->context.vdso) restorer = current->mm->context.vdso + - selected_vdso32->sym___kernel_sigreturn; + vdso_image_32.sym___kernel_sigreturn;else restorer = &frame->retcode;if (ksig->ka.sa.sa_flags &SA_RESTORER )
@@ -363,7 +363,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,/* Set up to return from userspace. */ restorer = current->mm->context.vdso + - selected_vdso32->sym___kernel_rt_sigreturn; + vdso_image_32.sym___kernel_rt_sigreturn;if (ksig->ka.sa.sa_flags &SA_RESTORER ) restorer = ksig->ka.sa.sa_restorer;put_user_ex (restorer, &frame->pretcode);
arch/x86/um/asm/syscall.h +4 -0
@@ -3,6 +3,10 @@#include <uapi/linux/audit.h> +typedef asmlinkage long (*sys_call_ptr_t )(unsigned long ,unsigned long , +unsigned long ,unsigned long , +unsigned long ,unsigned long ); +static inline int syscall_get_arch (void ) {#ifdef CONFIG_X86_32
arch/x86/um/sys_call_table_32.c +3 -4
@@ -7,6 +7,7 @@#include <linux/sys.h> #include <linux/cache.h> #include <generated/user_constants.h> +#include <asm/syscall.h> #define __NO_STUBS
@@ -24,15 +25,13 @@#define old_mmap sys_old_mmap -#define __SYSCALL_I386 (nr, sym, compat) extern asmlinkage void sym(void) ; +#define __SYSCALL_I386 (nr, sym, compat) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ;#include <asm/syscalls_32.h> #undef __SYSCALL_I386#define __SYSCALL_I386 (nr, sym, compat) [ nr ] = sym, -typedef asmlinkage void (*sys_call_ptr_t)(void); - -extern asmlinkage void sys_ni_syscall(void); +extern asmlinkage long sys_ni_syscall (unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long );const sys_call_ptr_t sys_call_table[]____cacheline_aligned = {/*
arch/x86/um/sys_call_table_64.c +3 -4
@@ -7,6 +7,7 @@#include <linux/sys.h> #include <linux/cache.h> #include <generated/user_constants.h> +#include <asm/syscall.h> #define __NO_STUBS
@@ -37,15 +38,13 @@#define __SYSCALL_COMMON (nr, sym, compat) __SYSCALL_64(nr, sym, compat)#define __SYSCALL_X32 (nr, sym, compat)/* Not supported */ -#define __SYSCALL_64 (nr, sym, compat) extern asmlinkage void sym(void) ; +#define __SYSCALL_64 (nr, sym, compat) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) ;#include <asm/syscalls_64.h> #undef __SYSCALL_64#define __SYSCALL_64 (nr, sym, compat) [ nr ] = sym, -typedef void (*sys_call_ptr_t )(void ); - -extern void sys_ni_syscall (void ); +extern asmlinkage long sys_ni_syscall (unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long );const sys_call_ptr_t sys_call_table[]____cacheline_aligned = {/*
arch/x86/xen/setup.c +2 -11
@@ -965,17 +965,8 @@ char * __init xen_auto_xlated_memory_setup(void)static void __init fiddle_vdso (void ) {#ifdef CONFIG_X86_32 -/* -* This could be called before selected_vdso32 is initialized, so -* just fiddle with both possible images. vdso_image_32_syscall -* can't be selected, since it only exists on 64-bit systems. -*/ -u32 *mask; - mask = vdso_image_32_int80.data + - vdso_image_32_int80.sym_VDSO32_NOTE_MASK; - *mask |=1 <<VDSO_NOTE_NONEGSEG_BIT ; - mask = vdso_image_32_sysenter.data + - vdso_image_32_sysenter.sym_VDSO32_NOTE_MASK; +u32 *mask = vdso_image_32.data + + vdso_image_32.sym_VDSO32_NOTE_MASK; *mask |=1 <<VDSO_NOTE_NONEGSEG_BIT ;#endif }
tools/testing/selftests/x86/Makefile +4 -2
@@ -4,8 +4,8 @@ include ../lib.mk .PHONY: all all_32 all_64 warn_32bit_failure clean -TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs ldt_gdt syscall_nt -TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault sigreturn +TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs ldt_gdt syscall_nt ptrace_syscall +TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault sigreturn test_syscall_vdso unwind_vdso TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY) BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32)
@@ -60,3 +60,5 @@ endif # Some tests have additional dependencies. sysret_ss_attrs_64: thunks.S +ptrace_syscall_32: raw_syscall_helper_32.S +test_syscall_vdso_32: thunks_32.S
tools/testing/selftests/x86/ptrace_syscall.c new file +294 -0
294 lines not on this page · raw message
tools/testing/selftests/x86/raw_syscall_helper_32.S new file +46 -0
46 lines not on this page · raw message
tools/testing/selftests/x86/test_syscall_vdso.c new file +401 -0
388 lines not on this page · raw message
tools/testing/selftests/x86/thunks_32.S new file +55 -0
55 lines not on this page · raw message
tools/testing/selftests/x86/unwind_vdso.c new file +211 -0
211 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.