Merge branch 'x86-entry-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 8 Jul 2019 18:42:09 +0000 (11:42 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 8 Jul 2019 18:42:09 +0000 (11:42 -0700)
Pull x86 vsyscall updates from Thomas Gleixner:
 "Further hardening of the legacy vsyscall by providing support for
  execute only mode and switching the default to it.

  This prevents a certain class of attacks which rely on the vsyscall
  page being accessible at a fixed address in the canonical kernel
  address space"

* 'x86-entry-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  selftests/x86: Add a test for process_vm_readv() on the vsyscall page
  x86/vsyscall: Add __ro_after_init to global variables
  x86/vsyscall: Change the default vsyscall mode to xonly
  selftests/x86/vsyscall: Verify that vsyscall=none blocks execution
  x86/vsyscall: Document odd SIGSEGV error code for vsyscalls
  x86/vsyscall: Show something useful on a read fault
  x86/vsyscall: Add a new vsyscall=xonly mode
  Documentation/admin: Remove the vsyscall=native documentation

1  2 
Documentation/admin-guide/kernel-parameters.txt
arch/x86/Kconfig

                        others).
  
        ccw_timeout_log [S390]
 -                      See Documentation/s390/CommonIO for details.
 +                      See Documentation/s390/common_io.rst for details.
  
        cgroup_disable= [KNL] Disable a particular controller
                        Format: {name of the controller(s) to disable}
                                /selinux/checkreqprot.
  
        cio_ignore=     [S390]
 -                      See Documentation/s390/CommonIO for details.
 +                      See Documentation/s390/common_io.rst for details.
        clk_ignore_unused
                        [CLK]
                        Prevents the clock framework from automatically gating
                        targets for exploits that can control RIP.
  
                        emulate     [default] Vsyscalls turn into traps and are
-                                   emulated reasonably safely.
+                                   emulated reasonably safely.  The vsyscall
+                                   page is readable.
  
-                       native      Vsyscalls are native syscall instructions.
-                                   This is a little bit faster than trapping
-                                   and makes a few dynamic recompilers work
-                                   better than they would in emulation mode.
-                                   It also makes exploits much easier to write.
+                       xonly       Vsyscalls turn into traps and are
+                                   emulated reasonably safely.  The vsyscall
+                                   page is not readable.
  
                        none        Vsyscalls don't work at all.  This makes
                                    them quite hard to use for exploits but
diff --combined arch/x86/Kconfig
@@@ -17,7 -17,6 +17,7 @@@ config X86_3
        select HAVE_DEBUG_STACKOVERFLOW
        select MODULES_USE_ELF_REL
        select OLD_SIGACTION
 +      select GENERIC_VDSO_32
  
  config X86_64
        def_bool y
@@@ -122,7 -121,6 +122,7 @@@ config X8
        select GENERIC_STRNCPY_FROM_USER
        select GENERIC_STRNLEN_USER
        select GENERIC_TIME_VSYSCALL
 +      select GENERIC_GETTIMEOFDAY
        select HARDLOCKUP_CHECK_TIMESTAMP       if X86_64
        select HAVE_ACPI_APEI                   if ACPI
        select HAVE_ACPI_APEI_NMI               if ACPI
        select HAVE_SYSCALL_TRACEPOINTS
        select HAVE_UNSTABLE_SCHED_CLOCK
        select HAVE_USER_RETURN_NOTIFIER
 +      select HAVE_GENERIC_VDSO
        select HOTPLUG_SMT                      if SMP
        select IRQ_FORCED_THREADING
        select NEED_SG_DMA_LENGTH
@@@ -2288,7 -2285,7 +2288,7 @@@ config COMPAT_VDS
  choice
        prompt "vsyscall table for legacy applications"
        depends on X86_64
-       default LEGACY_VSYSCALL_EMULATE
+       default LEGACY_VSYSCALL_XONLY
        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
          it can be used to assist security vulnerability exploitation.
  
          This setting can be changed at boot time via the kernel command
-         line parameter vsyscall=[emulate|none].
+         line parameter vsyscall=[emulate|xonly|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".
+         If unsure, select "Emulate execution only".
  
        config LEGACY_VSYSCALL_EMULATE
-               bool "Emulate"
+               bool "Full emulation"
                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.
+                 The kernel traps and emulates calls into the fixed vsyscall
+                 address mapping. This makes the mapping non-executable, but
+                 it still contains readable known contents, which could be
+                 used in certain rare security vulnerability exploits. This
+                 configuration is recommended when using legacy userspace
+                 that still uses vsyscalls along with legacy binary
+                 instrumentation tools that require code to be readable.
+                 An example of this type of legacy userspace is running
+                 Pin on an old binary that still uses vsyscalls.
+       config LEGACY_VSYSCALL_XONLY
+               bool "Emulate execution only"
+               help
+                 The kernel traps and emulates calls into the fixed vsyscall
+                 address mapping and does not allow reads.  This
+                 configuration is recommended when userspace might use the
+                 legacy vsyscall area but support for legacy binary
+                 instrumentation of legacy code is not needed.  It mitigates
+                 certain uses of the vsyscall area as an ASLR-bypassing
+                 buffer.
  
        config LEGACY_VSYSCALL_NONE
                bool "None"