kernel - Fix CVE-2018-8897, debug register issue
commit09060390aba8f2c0f72d056e4b7b1026c06224f4
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 1 May 2018 03:47:20 +0000 (30 20:47 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 8 May 2018 17:02:39 +0000 (8 10:02 -0700)
tree27c53954fb22244e54cd29d8ee27d02bacc0906b
parentde942382d764fadf7fb0d8fcb14c2a98bab01d8f
kernel - Fix CVE-2018-8897, debug register issue

* #DB can be delayed in a way that causes it to occur on the first
  instruction of the int $3 or syscall handlers.  These handlers must
  be able to detect and handle the condition.  This is a historical
  artifact of cpu operation that has existed for a very long time on
  both AMD and Intel CPUs.

* Fix by giving #DB its own trampoline stack and a way to load a
  deterministic %gs and %cr3 independent of the normal CS check.
  This is CVE-2018-8897.

* Also fix the NMI trampoline while I'm here.

* Also fix an old issue with debug register trace traps which can
  occur when the kernel is accessing the user's address space.
  This fix was lost years ago, now recovered.

Credits: Nick Peterson of Everdox Tech, LLC (original reporter)
Credits: Thanks to Microsoft for coordinating the OS vendor response
sys/cpu/x86_64/include/asmacros.h
sys/cpu/x86_64/include/frame.h
sys/platform/pc64/include/globaldata.h
sys/platform/pc64/x86_64/exception.S
sys/platform/pc64/x86_64/genassym.c
sys/platform/pc64/x86_64/machdep.c
sys/platform/pc64/x86_64/mp_machdep.c
sys/platform/pc64/x86_64/pmap.c
sys/platform/pc64/x86_64/trap.c