From: Christian Borntraeger Subject: Re: [PATCHv2] kvm-s390: fix potential array overrun in intercept handling Date: Thu, 21 Jan 2010 12:32:15 +0100 Message-ID: <201001211232.15630.borntraeger@de.ibm.com> References: <201001211156.03669.borntraeger@de.ibm.com> <201001211219.07628.borntraeger@de.ibm.com> <20100121112418.GA7335@osiris.boeblingen.de.ibm.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: Avi Kivity , Marcelo Tosatti , kvm@vger.kernel.org, Martin Schwidefsky , cotte@de.ibm.com To: Heiko Carstens Return-path: Received: from mtagate1.uk.ibm.com ([194.196.100.161]:55949 "EHLO mtagate1.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755297Ab0AULcT (ORCPT ); Thu, 21 Jan 2010 06:32:19 -0500 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o0LBWIdi004589 for ; Thu, 21 Jan 2010 11:32:18 GMT Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o0LBWIre1048588 for ; Thu, 21 Jan 2010 11:32:18 GMT Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o0LBWH9l030354 for ; Thu, 21 Jan 2010 11:32:18 GMT In-Reply-To: <20100121112418.GA7335@osiris.boeblingen.de.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: Am Donnerstag 21 Januar 2010 12:24:18 schrieb Heiko Carstens: > > - if (code & 3 || code > 0x48) > > + if (code & 3 || (code >> 2) >= ARRAY_SIZE(intercept_funcs)) > > return -ENOTSUPP; > > Not that it matters for this patch, but -ENOTSUPP should not leak to > userspace. Not sure if it does somewhere, but it is used all over the > place within arch/s390/kvm... > Use -EOPNOTSUPP or something similar instead. AFAICS it does not leak to userspace, ENOTSUPP is an internal code. see kvm_arch_vcpu_ioctl_run: [...] if (rc == -ENOTSUPP) { /* intercept cannot be handled in-kernel, prepare kvm-run */ kvm_run->exit_reason = KVM_EXIT_S390_SIEIC; kvm_run->s390_sieic.icptcode = vcpu->arch.sie_block->icptcode; kvm_run->s390_sieic.ipa = vcpu->arch.sie_block->ipa; kvm_run->s390_sieic.ipb = vcpu->arch.sie_block->ipb; rc = 0; } [...]