1 From 4d47555a80495657161a7e71ec3014ff2021e450 Mon Sep 17 00:00:00 2001
2 From: Carsten Otte <cotte@de.ibm.com>
3 Date: Tue, 18 Oct 2011 12:27:12 +0200
4 Subject: KVM: s390: check cpu_id prior to using it
6 From: Carsten Otte <cotte@de.ibm.com>
8 commit 4d47555a80495657161a7e71ec3014ff2021e450 upstream.
10 We use the cpu id provided by userspace as array index here. Thus we
11 clearly need to check it first. Ooops.
13 Signed-off-by: Carsten Otte <cotte@de.ibm.com>
14 Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
15 Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
19 arch/s390/kvm/kvm-s390.c | 14 ++++++++++----
20 1 file changed, 10 insertions(+), 4 deletions(-)
22 --- a/arch/s390/kvm/kvm-s390.c
23 +++ b/arch/s390/kvm/kvm-s390.c
24 @@ -312,11 +312,17 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu
25 struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
28 - struct kvm_vcpu *vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
30 + struct kvm_vcpu *vcpu;
33 + if (id >= KVM_MAX_VCPUS)
38 + vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL);
43 vcpu->arch.sie_block = (struct kvm_s390_sie_block *)
44 get_zeroed_page(GFP_KERNEL);
45 @@ -352,7 +358,7 @@ out_free_sie_block:
46 free_page((unsigned long)(vcpu->arch.sie_block));