]> xenbits.xensource.com Git - xen.git/commit
x86/svm: Don't clobber eax and edx if an RDMSR intercept fails
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 2 Nov 2016 14:36:49 +0000 (14:36 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 10 Nov 2016 15:34:42 +0000 (15:34 +0000)
commita0b4e3c0681a11b765fe218fba0ba4ebb9fa56c5
tree92afdf7d7d91d942256658f67c49b6cc5efd2207
parent420596c8685d2c413ef4fc11fc942739b856a049
x86/svm: Don't clobber eax and edx if an RDMSR intercept fails

The original code has a bug; eax and edx get unconditionally updated even when
hvm_msr_read_intercept() doesn't return X86EMUL_OKAY.

It is only by blind luck (vmce_rdmsr() eagerly initialising its msr_content
pointer) that this isn't an information leak into guests.

While fixing this bug, reduce the scope of msr_content and initialise it to 0.
This makes it obvious that a stack leak won't occur, even if there were to be
a buggy codepath in hvm_msr_read_intercept().

Also make some non-functional improvements.  Make the insn_len calculation
common, and reduce the quantity of explicit casting by making better use of
the existing register names.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/hvm/svm/svm.c