Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1276877 > unrolled thread
| Started by | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| First post | 2015-11-24 23:50 +0100 |
| Last post | 2015-11-25 19:10 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3.2 41/52] KVM: svm: unconditionally intercept #DB Ben Hutchings <ben@decadent.org.uk> - 2015-11-24 23:50 +0100
Re: [PATCH 3.2 41/52] KVM: svm: unconditionally intercept #DB Paolo Bonzini <pbonzini@redhat.com> - 2015-11-25 12:40 +0100
Re: [PATCH 3.2 41/52] KVM: svm: unconditionally intercept #DB Ben Hutchings <ben@decadent.org.uk> - 2015-11-25 19:00 +0100
Re: [PATCH 3.2 41/52] KVM: svm: unconditionally intercept #DB Paolo Bonzini <pbonzini@redhat.com> - 2015-11-25 19:10 +0100
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2015-11-24 23:50 +0100 |
| Subject | [PATCH 3.2 41/52] KVM: svm: unconditionally intercept #DB |
| Message-ID | <qyuzq-5RA-65@gated-at.bofh.it> |
3.2.74-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <pbonzini@redhat.com>
commit cbdb967af3d54993f5814f1cee0ed311a055377d upstream.
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>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[bwh: Backported to 3.2: #DB and #BP did not share a function, and there is
no operation pointer referring to it, so remove update_db_intercept()
entirely]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
arch/x86/kvm/svm.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1015,6 +1015,7 @@ static void init_vmcb(struct vcpu_svm *s
set_exception_intercept(svm, UD_VECTOR);
set_exception_intercept(svm, MC_VECTOR);
set_exception_intercept(svm, AC_VECTOR);
+ set_exception_intercept(svm, DB_VECTOR);
set_intercept(svm, INTERCEPT_INTR);
set_intercept(svm, INTERCEPT_NMI);
@@ -1550,26 +1551,6 @@ static void svm_set_segment(struct kvm_v
mark_dirty(svm->vmcb, VMCB_SEG);
}
-static void update_db_intercept(struct kvm_vcpu *vcpu)
-{
- struct vcpu_svm *svm = to_svm(vcpu);
-
- clr_exception_intercept(svm, DB_VECTOR);
- clr_exception_intercept(svm, BP_VECTOR);
-
- if (svm->nmi_singlestep)
- set_exception_intercept(svm, DB_VECTOR);
-
- if (vcpu->guest_debug & KVM_GUESTDBG_ENABLE) {
- if (vcpu->guest_debug &
- (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
- set_exception_intercept(svm, DB_VECTOR);
- if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
- set_exception_intercept(svm, BP_VECTOR);
- } else
- vcpu->guest_debug = 0;
-}
-
static void svm_guest_debug(struct kvm_vcpu *vcpu, struct kvm_guest_debug *dbg)
{
struct vcpu_svm *svm = to_svm(vcpu);
@@ -1580,8 +1561,6 @@ static void svm_guest_debug(struct kvm_v
svm->vmcb->save.dr7 = vcpu->arch.dr7;
mark_dirty(svm->vmcb, VMCB_DR);
-
- update_db_intercept(vcpu);
}
static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd)
@@ -1655,7 +1634,6 @@ static int db_interception(struct vcpu_s
if (!(svm->vcpu.guest_debug & KVM_GUESTDBG_SINGLESTEP))
svm->vmcb->save.rflags &=
~(X86_EFLAGS_TF | X86_EFLAGS_RF);
- update_db_intercept(&svm->vcpu);
}
if (svm->vcpu.guest_debug &
@@ -3557,7 +3535,6 @@ static void enable_nmi_window(struct kvm
*/
svm->nmi_singlestep = true;
svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF);
- update_db_intercept(vcpu);
}
static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2015-11-25 12:40 +0100 |
| Message-ID | <qyGAy-5Fi-19@gated-at.bofh.it> |
| In reply to | #1276877 |
On 24/11/2015 23:33, Ben Hutchings wrote:
> 3.2.74-rc1 review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Paolo Bonzini <pbonzini@redhat.com>
>
> commit cbdb967af3d54993f5814f1cee0ed311a055377d upstream.
>
> 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>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> [bwh: Backported to 3.2: #DB and #BP did not share a function, and there is
> no operation pointer referring to it, so remove update_db_intercept()
> entirely]
This is wrong, you still need to check the BP intercept in the
(incorrectly named as of 3.2) update_db_intercept function.
Something like:
-static void update_db_intercept(struct kvm_vcpu *vcpu)
+static void update_bp_intercept(struct kvm_vcpu *vcpu)
{
struct vcpu_svm *svm = to_svm(vcpu);
- clr_exception_intercept(svm, DB_VECTOR);
clr_exception_intercept(svm, BP_VECTOR);
-
- if (svm->nmi_singlestep)
- set_exception_intercept(svm, DB_VECTOR);
-
if (vcpu->guest_debug & KVM_GUESTDBG_ENABLE) {
- if (vcpu->guest_debug &
- (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
- set_exception_intercept(svm, DB_VECTOR);
if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
set_exception_intercept(svm, BP_VECTOR);
} else
vcpu->guest_debug = 0;
}
Then the calls in db_interception and enable_nmi_window can be removed,
but the one in svm_guest_debug is important.
Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2015-11-25 19:00 +0100 |
| Message-ID | <qyMwj-12v-9@gated-at.bofh.it> |
| In reply to | #1277263 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, 2015-11-25 at 12:31 +0100, Paolo Bonzini wrote:
>
> On 24/11/2015 23:33, Ben Hutchings wrote:
> > 3.2.74-rc1 review patch. If anyone has any objections, please let me know.
> >
> > ------------------
> >
> > From: Paolo Bonzini <pbonzini@redhat.com>
> >
> > commit cbdb967af3d54993f5814f1cee0ed311a055377d upstream.
> >
> > 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>
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > [bwh: Backported to 3.2: #DB and #BP did not share a function, and there is
> > no operation pointer referring to it, so remove update_db_intercept()
> > entirely]
>
> This is wrong, you still need to check the BP intercept in the
> (incorrectly named as of 3.2) update_db_intercept function.
>
> Something like:
>
> -static void update_db_intercept(struct kvm_vcpu *vcpu)
> +static void update_bp_intercept(struct kvm_vcpu *vcpu)
> {
> > > struct vcpu_svm *svm = to_svm(vcpu);
>
> -> > clr_exception_intercept(svm, DB_VECTOR);
> > > clr_exception_intercept(svm, BP_VECTOR);
> -
> -> > if (svm->nmi_singlestep)
> -> > > set_exception_intercept(svm, DB_VECTOR);
> -
> > > if (vcpu->guest_debug & KVM_GUESTDBG_ENABLE) {
> -> > > if (vcpu->guest_debug &
> -> > > (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
> -> > > > set_exception_intercept(svm, DB_VECTOR);
> > > > if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
> > > > > set_exception_intercept(svm, BP_VECTOR);
> > > } else
> > > vcpu->guest_debug = 0;
> }
>
>
> Then the calls in db_interception and enable_nmi_window can be removed,
> but the one in svm_guest_debug is important.
Sorry about that. I now have with this version:
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 10 Nov 2015 09:14:39 +0100
Subject: KVM: svm: unconditionally intercept #DB
commit cbdb967af3d54993f5814f1cee0ed311a055377d upstream.
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>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[bwh: Backported to 3.2, with thanks to Paolo:
- update_db_bp_intercept() was called update_db_intercept()
- The remaining call is in svm_guest_debug() rather than through svm_x86_ops]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
arch/x86/kvm/svm.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1015,6 +1015,7 @@ static void init_vmcb(struct vcpu_svm *s
set_exception_intercept(svm, UD_VECTOR);
set_exception_intercept(svm, MC_VECTOR);
set_exception_intercept(svm, AC_VECTOR);
+ set_exception_intercept(svm, DB_VECTOR);
set_intercept(svm, INTERCEPT_INTR);
set_intercept(svm, INTERCEPT_NMI);
@@ -1550,20 +1551,13 @@ static void svm_set_segment(struct kvm_v
mark_dirty(svm->vmcb, VMCB_SEG);
}
-static void update_db_intercept(struct kvm_vcpu *vcpu)
+static void update_bp_intercept(struct kvm_vcpu *vcpu)
{
struct vcpu_svm *svm = to_svm(vcpu);
- clr_exception_intercept(svm, DB_VECTOR);
clr_exception_intercept(svm, BP_VECTOR);
- if (svm->nmi_singlestep)
- set_exception_intercept(svm, DB_VECTOR);
-
if (vcpu->guest_debug & KVM_GUESTDBG_ENABLE) {
- if (vcpu->guest_debug &
- (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
- set_exception_intercept(svm, DB_VECTOR);
if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
set_exception_intercept(svm, BP_VECTOR);
} else
@@ -1581,7 +1575,7 @@ static void svm_guest_debug(struct kvm_v
mark_dirty(svm->vmcb, VMCB_DR);
- update_db_intercept(vcpu);
+ update_bp_intercept(vcpu);
}
static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd)
@@ -1655,7 +1649,6 @@ static int db_interception(struct vcpu_s
if (!(svm->vcpu.guest_debug & KVM_GUESTDBG_SINGLESTEP))
svm->vmcb->save.rflags &=
~(X86_EFLAGS_TF | X86_EFLAGS_RF);
- update_db_intercept(&svm->vcpu);
}
if (svm->vcpu.guest_debug &
@@ -3557,7 +3550,6 @@ static void enable_nmi_window(struct kvm
*/
svm->nmi_singlestep = true;
svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF);
- update_db_intercept(vcpu);
}
static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr)
--
Ben Hutchings
This sentence contradicts itself - no actually it doesn't.
[toc] | [prev] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2015-11-25 19:10 +0100 |
| Message-ID | <qyMFZ-1lB-35@gated-at.bofh.it> |
| In reply to | #1277656 |
On 25/11/2015 18:56, Ben Hutchings wrote:
> On Wed, 2015-11-25 at 12:31 +0100, Paolo Bonzini wrote:
>>
>> On 24/11/2015 23:33, Ben Hutchings wrote:
>>> 3.2.74-rc1 review patch. If anyone has any objections, please let me know.
>>>
>>> ------------------
>>>
>>> From: Paolo Bonzini <pbonzini@redhat.com>
>>>
>>> commit cbdb967af3d54993f5814f1cee0ed311a055377d upstream.
>>>
>>> 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>
>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>> [bwh: Backported to 3.2: #DB and #BP did not share a function, and there is
>>> no operation pointer referring to it, so remove update_db_intercept()
>>> entirely]
>>
>> This is wrong, you still need to check the BP intercept in the
>> (incorrectly named as of 3.2) update_db_intercept function.
>>
>> Something like:
>>
>> -static void update_db_intercept(struct kvm_vcpu *vcpu)
>> +static void update_bp_intercept(struct kvm_vcpu *vcpu)
>> {
>> > > struct vcpu_svm *svm = to_svm(vcpu);
>>
>> -> > clr_exception_intercept(svm, DB_VECTOR);
>> > > clr_exception_intercept(svm, BP_VECTOR);
>> -
>> -> > if (svm->nmi_singlestep)
>> -> > > set_exception_intercept(svm, DB_VECTOR);
>> -
>> > > if (vcpu->guest_debug & KVM_GUESTDBG_ENABLE) {
>> -> > > if (vcpu->guest_debug &
>> -> > > (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
>> -> > > > set_exception_intercept(svm, DB_VECTOR);
>> > > > if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
>> > > > > set_exception_intercept(svm, BP_VECTOR);
>> > > } else
>> > > vcpu->guest_debug = 0;
>> }
>>
>>
>> Then the calls in db_interception and enable_nmi_window can be removed,
>> but the one in svm_guest_debug is important.
>
> Sorry about that. I now have with this version:
>
> From: Paolo Bonzini <pbonzini@redhat.com>
> Date: Tue, 10 Nov 2015 09:14:39 +0100
> Subject: KVM: svm: unconditionally intercept #DB
>
> commit cbdb967af3d54993f5814f1cee0ed311a055377d upstream.
>
> 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>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> [bwh: Backported to 3.2, with thanks to Paolo:
> - update_db_bp_intercept() was called update_db_intercept()
> - The remaining call is in svm_guest_debug() rather than through svm_x86_ops]
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---
> arch/x86/kvm/svm.c | 14 +++-----------
> 1 file changed, 3 insertions(+), 11 deletions(-)
>
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1015,6 +1015,7 @@ static void init_vmcb(struct vcpu_svm *s
> set_exception_intercept(svm, UD_VECTOR);
> set_exception_intercept(svm, MC_VECTOR);
> set_exception_intercept(svm, AC_VECTOR);
> + set_exception_intercept(svm, DB_VECTOR);
>
> set_intercept(svm, INTERCEPT_INTR);
> set_intercept(svm, INTERCEPT_NMI);
> @@ -1550,20 +1551,13 @@ static void svm_set_segment(struct kvm_v
> mark_dirty(svm->vmcb, VMCB_SEG);
> }
>
> -static void update_db_intercept(struct kvm_vcpu *vcpu)
> +static void update_bp_intercept(struct kvm_vcpu *vcpu)
> {
> struct vcpu_svm *svm = to_svm(vcpu);
>
> - clr_exception_intercept(svm, DB_VECTOR);
> clr_exception_intercept(svm, BP_VECTOR);
>
> - if (svm->nmi_singlestep)
> - set_exception_intercept(svm, DB_VECTOR);
> -
> if (vcpu->guest_debug & KVM_GUESTDBG_ENABLE) {
> - if (vcpu->guest_debug &
> - (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))
> - set_exception_intercept(svm, DB_VECTOR);
> if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
> set_exception_intercept(svm, BP_VECTOR);
> } else
> @@ -1581,7 +1575,7 @@ static void svm_guest_debug(struct kvm_v
>
> mark_dirty(svm->vmcb, VMCB_DR);
>
> - update_db_intercept(vcpu);
> + update_bp_intercept(vcpu);
> }
>
> static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd)
> @@ -1655,7 +1649,6 @@ static int db_interception(struct vcpu_s
> if (!(svm->vcpu.guest_debug & KVM_GUESTDBG_SINGLESTEP))
> svm->vmcb->save.rflags &=
> ~(X86_EFLAGS_TF | X86_EFLAGS_RF);
> - update_db_intercept(&svm->vcpu);
> }
>
> if (svm->vcpu.guest_debug &
> @@ -3557,7 +3550,6 @@ static void enable_nmi_window(struct kvm
> */
> svm->nmi_singlestep = true;
> svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF);
> - update_db_intercept(vcpu);
> }
>
> static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr)
>
Thanks, this looks good.
Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web