]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: emulate: avoid accessing NULL ctxt->memopp
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 23 Oct 2014 12:54:14 +0000 (14:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Nov 2014 18:10:28 +0000 (10:10 -0800)
commit a430c9166312e1aa3d80bce32374233bdbfeba32 upstream.

A failure to decode the instruction can cause a NULL pointer access.
This is fixed simply by moving the "done" label as close as possible
to the return.

This fixes CVE-2014-8481.

Reported-by: Andy Lutomirski <luto@amacapital.net>
Fixes: 41061cdb98a0bec464278b4db8e894a3121671f5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/emulate.c

index 41157106f548e7875fa095e50dd38ce7e5e6282c..258b0d9349941f5028165cead5a7e29ee171b90d 100644 (file)
@@ -4481,10 +4481,10 @@ done_prefixes:
        /* Decode and fetch the destination operand: register or memory. */
        rc = decode_operand(ctxt, &ctxt->dst, (ctxt->d >> DstShift) & OpMask);
 
-done:
        if (ctxt->rip_relative)
                ctxt->memopp->addr.mem.ea += ctxt->_eip;
 
+done:
        return (rc != X86EMUL_CONTINUE) ? EMULATION_FAILED : EMULATION_OK;
 }