diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2017-06-07 16:13:14 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2017-07-02 19:13:03 +0300 |
commit | 24ee2a286de7ac680ad4b2423c2dcee68444e567 (patch) | |
tree | 179f28ffa8620ab0b1fe055b8cb633cc0428061d /arch/x86/kvm/emulate.c | |
parent | e3378be9d9cbe1f77ecfc03b4350991be58f3f82 (diff) | |
download | linux-24ee2a286de7ac680ad4b2423c2dcee68444e567.tar.xz |
KVM: x86: fix singlestepping over syscall
commit c8401dda2f0a00cd25c0af6a95ed50e478d25de4 upstream.
TF is handled a bit differently for syscall and sysret, compared
to the other instructions: TF is checked after the instruction completes,
so that the OS can disable #DB at a syscall by adding TF to FMASK.
When the sysret is executed the #DB is taken "as if" the syscall insn
just completed.
KVM emulates syscall so that it can trap 32-bit syscall on Intel processors.
Fix the behavior, otherwise you could get #DB on a user stack which is not
nice. This does not affect Linux guests, as they use an IST or task gate
for #DB.
This fixes CVE-2017-7518.
Reported-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
[bwh: Backported to 3.16:
- kvm_vcpu_check_singlestep() did not take an rflags parameter but
called get_rflags() itself; delete that code
- kvm_vcpu_check_singlestep() sets some flags differently
- Drop changes to kvm_skip_emulated_instruction()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r-- | arch/x86/kvm/emulate.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 35f8884817fa..3ef118df2547 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2310,6 +2310,7 @@ static int em_syscall(struct x86_emulate_ctxt *ctxt) ctxt->eflags &= ~(EFLG_VM | EFLG_IF | EFLG_RF); } + ctxt->tf = (ctxt->eflags & X86_EFLAGS_TF) != 0; return X86EMUL_CONTINUE; } |