• Paolo Bonzini's avatar
    KVM: x86: fix singlestepping over syscall · 24ee2a28
    Paolo Bonzini authored
    commit c8401dda 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: default avatarAndy Lutomirski <luto@kernel.org>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: default avatarRadim 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: default avatarBen Hutchings <ben@decadent.org.uk>
    24ee2a28
emulate.c 127 KB