]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arm/arm64: KVM: Fix set_clear_sgi_pend_reg offset
authorChristoffer Dall <christoffer.dall@linaro.org>
Thu, 25 Sep 2014 16:41:07 +0000 (18:41 +0200)
committerLuis Henriques <luis.henriques@canonical.com>
Wed, 20 May 2015 12:25:45 +0000 (13:25 +0100)
commit 0fea6d7628ed6e25a9ee1b67edf7c859718d39e8 upstream.

The sgi values calculated in read_set_clear_sgi_pend_reg() and
write_set_clear_sgi_pend_reg() were horribly incorrectly multiplied by 4
with catastrophic results in that subfunctions ended up overwriting
memory not allocated for the expected purpose.

This showed up as bugs in kfree() and the kernel complaining a lot of
you turn on memory debugging.

This addresses: http://marc.info/?l=kvm&m=141164910007868&w=2

Reported-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
virt/kvm/arm/vgic.c

index b224b729cd0f8b84074897fe04472cd713afac16..078e704940b3f1938e9fd839dd158b062b200e71 100644 (file)
@@ -674,7 +674,7 @@ static bool read_set_clear_sgi_pend_reg(struct kvm_vcpu *vcpu,
 {
        struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
        int sgi;
-       int min_sgi = (offset & ~0x3) * 4;
+       int min_sgi = (offset & ~0x3);
        int max_sgi = min_sgi + 3;
        int vcpu_id = vcpu->vcpu_id;
        u32 reg = 0;
@@ -695,7 +695,7 @@ static bool write_set_clear_sgi_pend_reg(struct kvm_vcpu *vcpu,
 {
        struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
        int sgi;
-       int min_sgi = (offset & ~0x3) * 4;
+       int min_sgi = (offset & ~0x3);
        int max_sgi = min_sgi + 3;
        int vcpu_id = vcpu->vcpu_id;
        u32 reg;