KVM: x86: Handle errors when RIP is set during far jumps
authorNadav Amit <namit@cs.technion.ac.il>
Thu, 18 Sep 2014 19:39:39 +0000 (22:39 +0300)
committerZefan Li <lizefan@huawei.com>
Mon, 2 Feb 2015 09:04:58 +0000 (17:04 +0800)
commit48dfdb0c21f8254ef2a91f91792d73414fa635ae
tree1c633566ab3bb1b2ff2cae76362b484d237f73c3
parentd1d7b57b3c62a47e0a2a2a4c742d7df06b58cd15
KVM: x86: Handle errors when RIP is set during far jumps

commit d1442d85cc30ea75f7d399474ca738e0bc96f715 upstream.

Far jmp/call/ret may fault while loading a new RIP.  Currently KVM does not
handle this case, and may result in failed vm-entry once the assignment is
done.  The tricky part of doing so is that loading the new CS affects the
VMCS/VMCB state, so if we fail during loading the new RIP, we are left in
unconsistent state.  Therefore, this patch saves on 64-bit the old CS
descriptor and restores it if loading RIP failed.

This fixes CVE-2014-3647.

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[lizf: Backported to 3.4:
 - adjust context
 - __load_segment_descriptor() doesn't take in_task_switch parameter]
Signed-off-by: Zefan Li <lizefan@huawei.com>
arch/x86/kvm/emulate.c