Skip to content

Commit cbdb967

Browse files
committed
KVM: svm: unconditionally intercept #DB
This is needed to avoid the possibility that the guest triggers an infinite stream of #DB exceptions (CVE-2015-8104). VMX is not affected: because it does not save DR6 in the VMCS, it already intercepts #DB unconditionally. Reported-by: Jan Beulich <jbeulich@suse.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 54a2055 commit cbdb967

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

Diff for: arch/x86/kvm/svm.c

+3-11
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ static void init_vmcb(struct vcpu_svm *svm)
10201020
set_exception_intercept(svm, UD_VECTOR);
10211021
set_exception_intercept(svm, MC_VECTOR);
10221022
set_exception_intercept(svm, AC_VECTOR);
1023+
set_exception_intercept(svm, DB_VECTOR);
10231024

10241025
set_intercept(svm, INTERCEPT_INTR);
10251026
set_intercept(svm, INTERCEPT_NMI);
@@ -1554,20 +1555,13 @@ static void svm_set_segment(struct kvm_vcpu *vcpu,
15541555
mark_dirty(svm->vmcb, VMCB_SEG);
15551556
}
15561557

1557-
static void update_db_bp_intercept(struct kvm_vcpu *vcpu)
1558+
static void update_bp_intercept(struct kvm_vcpu *vcpu)
15581559
{
15591560
struct vcpu_svm *svm = to_svm(vcpu);
15601561

1561-
clr_exception_intercept(svm, DB_VECTOR);
15621562
clr_exception_intercept(svm, BP_VECTOR);
15631563

1564-
if (svm->nmi_singlestep)
1565-
set_exception_intercept(svm, DB_VECTOR);
1566-
15671564
if (vcpu->guest_debug & KVM_GUESTDBG_ENABLE) {
1568-
if (vcpu->guest_debug &
1569-
(KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
1570-
set_exception_intercept(svm, DB_VECTOR);
15711565
if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
15721566
set_exception_intercept(svm, BP_VECTOR);
15731567
} else
@@ -1673,7 +1667,6 @@ static int db_interception(struct vcpu_svm *svm)
16731667
if (!(svm->vcpu.guest_debug & KVM_GUESTDBG_SINGLESTEP))
16741668
svm->vmcb->save.rflags &=
16751669
~(X86_EFLAGS_TF | X86_EFLAGS_RF);
1676-
update_db_bp_intercept(&svm->vcpu);
16771670
}
16781671

16791672
if (svm->vcpu.guest_debug &
@@ -3661,7 +3654,6 @@ static void enable_nmi_window(struct kvm_vcpu *vcpu)
36613654
*/
36623655
svm->nmi_singlestep = true;
36633656
svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF);
3664-
update_db_bp_intercept(vcpu);
36653657
}
36663658

36673659
static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr)
@@ -4287,7 +4279,7 @@ static struct kvm_x86_ops svm_x86_ops = {
42874279
.vcpu_load = svm_vcpu_load,
42884280
.vcpu_put = svm_vcpu_put,
42894281

4290-
.update_db_bp_intercept = update_db_bp_intercept,
4282+
.update_db_bp_intercept = update_bp_intercept,
42914283
.get_msr = svm_get_msr,
42924284
.set_msr = svm_set_msr,
42934285
.get_segment_base = svm_get_segment_base,

0 commit comments

Comments
 (0)