]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r333368: Prepare DB# handler for deferred trigger of watchpoints.
authoremaste <emaste@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 8 May 2018 17:05:39 +0000 (17:05 +0000)
committeremaste <emaste@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Tue, 8 May 2018 17:05:39 +0000 (17:05 +0000)
commit108cb9133a858ab29b1a1d94a783889b676cdcae
treef3c3c32d7db55545050289efbf9bbe05a3e49419
parent1f722dc5d8bdada19809808cb33262339b032357
MFC r333368: Prepare DB# handler for deferred trigger of watchpoints.

Prepare DB# handler for deferred trigger of watchpoints.

Since pop %ss/mov %ss instructions defer all interrupts and exceptions
for the next instruction, it is possible that the userspace watchpoint
trap executes on the first instruction of the kernel entry for
syscall/bpt.

In this case, DB# should be treated similarly to NMI: on amd64 we must
always load GSBASE even if the trap comes from kernel mode, and load
the kernel page table root into %cr3.  Moreover, the trap must
use the dedicated stack, because we are still on the user stack when
trapped on syscall entry.

For i386, we must reload %cr3.  The syscall instruction is not configured,
so there is no issue with executing on user stack when trapping.

Due to some CPU erratas it is not always possible to detect that the
userspace watchpoint triggered by inspecting %dr6.  In trap(), compare the
trap %rip with the known unsafe entry points and if matched pretend that
the watchpoint did not fire at all.

Thank you to the MSRC Incident Response Team, and in particular Greg
Lenti and Nate Warfield, for coordinating the response to this issue
across multiple vendors.

Thanks to Computer Recycling at The Working Center of Kitchener for
making hardware available to allow us to test the patch on additional
CPU families.

Reviewed by: jhb
Discussed with: Matthew Dillon
Tested by: emaste
Security: CVE-2018-8897
Security: FreeBSD-SA-18:06.debugreg
Sponsored by: The FreeBSD Foundation

git-svn-id: svn://svn.freebsd.org/base/stable/10@333370 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/amd64/amd64/exception.S
sys/amd64/amd64/machdep.c
sys/amd64/amd64/mp_machdep.c
sys/amd64/amd64/trap.c
sys/i386/i386/trap.c