Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
xen.8005
58249392-x86-svm-dont-clobber-eax-edx-if-RDMSR-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 58249392-x86-svm-dont-clobber-eax-edx-if-RDMSR-intercept-fails.patch of Package xen.8005
# Commit a0b4e3c0681a11b765fe218fba0ba4ebb9fa56c5 # Date 2016-11-10 15:34:42 +0000 # Author Andrew Cooper <andrew.cooper3@citrix.com> # Committer Andrew Cooper <andrew.cooper3@citrix.com> 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> --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1749,26 +1749,28 @@ static int svm_msr_write_intercept(unsig static void svm_do_msr_access(struct cpu_user_regs *regs) { - int rc, inst_len; - struct vcpu *v = current; - struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; - uint64_t msr_content; + struct vcpu *curr = current; + bool_t rdmsr = !curr->arch.hvm_svm.vmcb->exitinfo1; + int rc, inst_len = __get_instruction_length( + curr, rdmsr ? INSTR_RDMSR : INSTR_WRMSR); - if ( vmcb->exitinfo1 == 0 ) + if ( inst_len == 0 ) + return; + + if ( rdmsr ) { - if ( (inst_len = __get_instruction_length(v, INSTR_RDMSR)) == 0 ) - return; - rc = hvm_msr_read_intercept(regs->ecx, &msr_content); - regs->eax = (uint32_t)msr_content; - regs->edx = (uint32_t)(msr_content >> 32); + uint64_t msr_content = 0; + + rc = hvm_msr_read_intercept(regs->_ecx, &msr_content); + if ( rc == X86EMUL_OKAY ) + { + regs->rax = (uint32_t)msr_content; + regs->rdx = (uint32_t)(msr_content >> 32); + } } else - { - if ( (inst_len = __get_instruction_length(v, INSTR_WRMSR)) == 0 ) - return; - msr_content = ((uint64_t)regs->edx << 32) | (uint32_t)regs->eax; - rc = hvm_msr_write_intercept(regs->ecx, msr_content); - } + rc = hvm_msr_write_intercept(regs->_ecx, + (regs->rdx << 32) | regs->_eax); if ( rc == X86EMUL_OKAY ) __update_guest_eip(regs, inst_len);
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