x86/PV: writes of %fs and %gs base MSRs require canonical addresses
authorJan Beulich <jbeulich@suse.com>
Tue, 22 Nov 2016 12:46:28 +0000 (13:46 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Nov 2016 12:46:28 +0000 (13:46 +0100)
commitf3fa3abf3e61fb1f25ce721e14ac324dda67311f
tree9ac7648b412dbd2b5cd4ce423041c13a11eaa063
parent93aa42b85ae0084ba7b749d0e990c94fbf0c17e3
x86/PV: writes of %fs and %gs base MSRs require canonical addresses

Commit c42494acb2 ("x86: fix FS/GS base handling when using the
fsgsbase feature") replaced the use of wrmsr_safe() on these paths
without recognizing that wr{f,g}sbase() use just wrmsrl() and that the
WR{F,G}SBASE instructions also raise #GP for non-canonical input.

Similarly arch_set_info_guest() needs to prevent non-canonical
addresses from getting stored into state later to be loaded by context
switch code. For consistency also check stack pointers and LDT base.
DR0..3, otoh, already get properly checked in set_debugreg() (albeit
we discard the error there).

The SHADOW_GS_BASE check isn't strictly necessary, but I think we
better avoid trying the WRMSR if we know it's going to fail.

This is CVE-2016-9385 / XSA-193.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/domain.c
xen/arch/x86/traps.c