Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
xen.7653
xsa260-1.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xsa260-1.patch of Package xen.7653
From: Andrew Cooper <andrew.cooper3@citrix.com> Subject: x86/traps: Fix %dr6 handing in #DB handler Most bits in %dr6 accumulate, rather than being set directly based on the current source of #DB. Have the handler follow the manuals guidance, which avoids leaking hypervisor debugging activities into guest context. This is part of XSA-260 / CVE-2018-8897. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -3538,10 +3538,35 @@ static void ler_enable(void) void do_debug(struct cpu_user_regs *regs) { + unsigned long dr6; struct vcpu *v = current; + /* Stash dr6 as early as possible. */ + dr6 = read_debugreg(6); + DEBUGGER_trap_entry(TRAP_debug, regs); + /* + * At the time of writing (March 2018), on the subject of %dr6: + * + * The Intel manual says: + * Certain debug exceptions may clear bits 0-3. The remaining contents + * of the DR6 register are never cleared by the processor. To avoid + * confusion in identifying debug exceptions, debug handlers should + * clear the register (except bit 16, which they should set) before + * returning to the interrupted task. + * + * The AMD manual says: + * Bits 15:13 of the DR6 register are not cleared by the processor and + * must be cleared by software after the contents have been read. + * + * Some bits are reserved set, some are reserved clear, and some bits + * which were previously reserved set are reused and cleared by hardware. + * For future compatibility, reset to the default value, which will allow + * us to spot any bit being changed by hardware to its non-default value. + */ + write_debugreg(6, X86_DR6_DEFAULT); + if ( !guest_mode(regs) ) { if ( regs->eflags & X86_EFLAGS_TF ) @@ -3574,7 +3599,8 @@ void do_debug(struct cpu_user_regs *regs } /* Save debug status register where guest OS can peek at it */ - v->arch.debugreg[6] = read_debugreg(6); + v->arch.debugreg[6] |= (dr6 & ~X86_DR6_DEFAULT); + v->arch.debugreg[6] &= (dr6 | ~X86_DR6_DEFAULT); ler_enable(); do_guest_trap(TRAP_debug, regs, 0); --- a/xen/include/asm-x86/debugreg.h +++ b/xen/include/asm-x86/debugreg.h @@ -22,6 +22,8 @@ #define DR_SWITCH (0x8000) /* task switch */ #define DR_NOT_RTM (0x10000) /* clear: #BP inside RTM region */ +#define X86_DR6_DEFAULT 0xffff0ff0ul /* Default %dr6 value. */ + /* Now define a bunch of things for manipulating the control register. The top two bytes of the control register consist of 4 fields of 4 bits - each field corresponds to one of the four debug registers,
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor