* [patch 1/4] kvm-s390: check cpu_id prior to using it
[not found] <20111018102711.259185287@de.ibm.com>
@ 2011-10-18 10:27 ` Christian Borntraeger
0 siblings, 0 replies; only message in thread
From: Christian Borntraeger @ 2011-10-18 10:27 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tossati
Cc: Carsten Otte, Heiko Carstens, Martin Schwidefsky, KVM, stable,
Christian Borntraeger
[-- Attachment #1: 500-kvm-check-cpuid.diff --]
[-- Type: text/plain, Size: 1262 bytes --]
From: Carsten Otte <cotte@de.ibm.com>
We use the cpu id provided by userspace as array index here. Thus we
clearly need to check it first. Ooops.
CC: <stable@vger.kernel.org>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
arch/s390/kvm/kvm-s390.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
Index: b/arch/s390/kvm/kvm-s390.c
===================================================================
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -312,11 +312,17 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu
struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
unsigned int id)
{
- struct kvm_vcpu *vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
- int rc = -ENOMEM;
+ struct kvm_vcpu *vcpu;
+ int rc = -EINVAL;
+ if (id >= KVM_MAX_VCPUS)
+ goto out;
+
+ rc = -ENOMEM;
+
+ vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
if (!vcpu)
- goto out_nomem;
+ goto out;
vcpu->arch.sie_block = (struct kvm_s390_sie_block *)
get_zeroed_page(GFP_KERNEL);
@@ -352,7 +358,7 @@ out_free_sie_block:
free_page((unsigned long)(vcpu->arch.sie_block));
out_free_cpu:
kfree(vcpu);
-out_nomem:
+out:
return ERR_PTR(rc);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-10-18 10:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20111018102711.259185287@de.ibm.com>
2011-10-18 10:27 ` [patch 1/4] kvm-s390: check cpu_id prior to using it Christian Borntraeger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).