From: Marc Zyngier <maz@kernel.org>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Cc: Jia He <justin.he@arm.com>,
kvm@vger.kernel.org, Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Will Deacon <will@kernel.org>,
Steven Price <steven.price@arm.com>,
kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/8] KVM: arm/arm64: vgic: Fix potential double free dist->spis in __kvm_vgic_destroy()
Date: Thu, 12 Dec 2019 17:28:18 +0000 [thread overview]
Message-ID: <20191212172824.11523-3-maz@kernel.org> (raw)
In-Reply-To: <20191212172824.11523-1-maz@kernel.org>
From: Miaohe Lin <linmiaohe@huawei.com>
In kvm_vgic_dist_init() called from kvm_vgic_map_resources(), if
dist->vgic_model is invalid, dist->spis will be freed without set
dist->spis = NULL. And in vgicv2 resources clean up path,
__kvm_vgic_destroy() will be called to free allocated resources.
And dist->spis will be freed again in clean up chain because we
forget to set dist->spis = NULL in kvm_vgic_dist_init() failed
path. So double free would happen.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Link: https://lore.kernel.org/r/1574923128-19956-1-git-send-email-linmiaohe@huawei.com
---
virt/kvm/arm/vgic/vgic-init.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index b3c5de48064c..7c58112ae67c 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -177,6 +177,7 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
break;
default:
kfree(dist->spis);
+ dist->spis = NULL;
return -EINVAL;
}
}
--
2.20.1
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2019-12-12 17:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-12 17:28 [GIT PULL] KVM/arm updates for 5.5-rc2 Marc Zyngier
2019-12-12 17:28 ` [PATCH 1/8] KVM: arm/arm64: Get rid of unused arg in cpu_init_hyp_mode() Marc Zyngier
2019-12-12 17:28 ` Marc Zyngier [this message]
2019-12-12 17:28 ` [PATCH 3/8] KVM: arm/arm64: vgic: Use wrapper function to lock/unlock all vcpus in kvm_vgic_create() Marc Zyngier
2019-12-12 17:28 ` [PATCH 4/8] KVM: arm64: Sanely ratelimit sysreg messages Marc Zyngier
2019-12-12 17:28 ` [PATCH 5/8] KVM: arm64: Don't log IMP DEF sysreg traps Marc Zyngier
2019-12-12 17:28 ` [PATCH 6/8] KVM: arm/arm64: Remove excessive permission check in kvm_arch_prepare_memory_region Marc Zyngier
2019-12-12 17:28 ` [PATCH 7/8] KVM: arm64: Ensure 'params' is initialised when looking up sys register Marc Zyngier
2019-12-12 17:28 ` [PATCH 8/8] KVM: arm/arm64: Properly handle faulting of device mappings Marc Zyngier
2019-12-18 16:48 ` [GIT PULL] KVM/arm updates for 5.5-rc2 Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191212172824.11523-3-maz@kernel.org \
--to=maz@kernel.org \
--cc=ard.biesheuvel@linaro.org \
--cc=justin.he@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=steven.price@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox