Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796047472; b=nkXYy5BcfSpxXsULVA5odo0WTRVE1/ZsIao28SvBG6WwJdf0F2ybq1Uoov/0zCR8qHqu t2dUvNhO0Upu+7gHGYD9pr9+33UlTh8dJGk/XijtEFE2+XYHVZb0KfLkdcOGfDaDanVU6 Y2L2/eBoNSbG+X1GYWmq/Kz6R7g2ZO9arZCei3nOiaJknxqmgZsCy+8+7asy74dIxiZoW OalSHkXGY+CQ2cQjsewooJBoljx4vUppJF/EUoYcVBc56hXp/wiqzzBSt6cvsLbib9OLB XFX5PSo5NS1uR1b8J7hN1FmyFq7Aw3JcCDcCZCwBymKjdsy5Z2NpxUbFib3MEGlnXdw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796047472; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:Date:From:To:Cc:Subject: Message-ID:In-Reply-To:References:Organization:X-Mailer:MIME-Version: Content-Type:Content-Transfer-Encoding:X-TM-AS-GCONF: X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID:X-Proofpoint-GUID: X-Authority-Analysis:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=jUCBjAQwhcNOKg13KbQjbkEyRwJNl2jtJX+GaWIb/ts=; b=eWlR7ukwQg/blrjIa6c30f6dHsCN5gXZkelzawDpI30PLBRZ7ofzBPTXhaMfyAHSMl0b Dy1r7cAm1QNiShtvznZh7IaPJLIzkXp8Iv/7q3hxoFUqR1167hsvC4aND9ESwypkZM9Jd 7Z1HtGRnu0N+3Y9Yv2C47oGdN67pR6GFC5inp0K2wVeFUYmKhTUOzj4ffw8a2xl4CA9ID agf0TD5yxQQ6ACiUYCQDn0W3eCijUoTkrAaZaMr7WAcIjxgUGHusGcIULXw5OQR3IwEXJ Pu/1vgr28tYlK0hQPVimJLxUPXuQoY2O2MkrEkwiJzEAXuPVFTHa/+Xmq+gOIo+GPig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=Yilh0nm0; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0D6C606A327; Mon, 30 Nov 2026 14:04:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A0D6C606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=Yilh0nm0 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AUDZ4B43413680; Mon, 30 Nov 2026 14:04:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=jUCBjA QwhcNOKg13KbQjbkEyRwJNl2jtJX+GaWIb/ts=; b=Yilh0nm0/D5lgI66H7peYo 9urkyyH+dUNH7ZX50b1zIw5me3L+7hYmnBuvN3oSfqGdGsqiDI1lrUgrZWFYX3AH dTqpj9bdrUtY9OM4Ps7U506aL2+oTNRzv1J7oYuYvA+mePvgaLL3wFFPxW2JkkWX cf74HZvBYe7se9aagjNc1AS0iNhglZlpcKX+/gUYuEyrmSy6YzPiiVuO9RbDypkP n/o9jXVOzfVQOVU8Jd+rAdCn+V9pBaNwuo+31rPqkLtqC2nTeDP42X10ap210OJs HBWqSqNJ+b0SQeHmdSOj/6+ep/Jauwzn2URDn+PSmwQmJXOxZ9TGw3ijobVTJzXQ == Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pf3r4gf-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 30 Nov 2026 14:04:24 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6AUDJJpY1148784; Mon, 30 Nov 2026 14:04:23 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j8asgn33n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2026 14:04:23 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6AUE4Jc231785634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2026 14:04:19 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DB5A2004B; Mon, 30 Nov 2026 14:04:19 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 302582004E; Mon, 30 Nov 2026 14:04:18 +0000 (GMT) Received: from p-imbrenda (unknown [9.111.23.35]) by smtpav03.fra02v.mail.ibm.com (Postfix) with SMTP; Mon, 30 Nov 2026 14:04:18 +0000 (GMT) Date: Mon, 30 Nov 2026 15:04:15 +0100 From: Claudio Imbrenda To: Christian Borntraeger Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, frankja@linux.ibm.com, david@kernel.org, nrb@linux.ibm.com, schlameuss@linux.ibm.com, gra@linux.ibm.com, seiden@linux.ibm.com Subject: Re: [PATCH v1 02/12] KVM: s390: Fix potential leak in kvm_s390_get_io_int() Message-ID: <20261130150415.53d2cf96@p-imbrenda> In-Reply-To: <5911108a-6fec-4c78-b348-2e48758f42c2@de.ibm.com> References: <20261127150411.221072-1-imbrenda@linux.ibm.com> <20261127150411.221072-3-imbrenda@linux.ibm.com> <5911108a-6fec-4c78-b348-2e48758f42c2@de.ibm.com> Organization: IBM X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-redhat-linux-gnu) X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDA1NiBTYWx0ZWRfX60paNGvXfUqa KxO5J4zcv1ZhES0M3Fg2lyhahqSYnoTeMfYMtwBo6IM/kP3t9+4EmCxecDDR73leBb9AXUIkty9 zVD6wXwGxeOfFOs7yR8y2uZdt7k05Lc= X-Proofpoint-ORIG-GUID: 9QnIbHjdSyQ-O_vrjY1bagm_AfVZPpoz X-Proofpoint-GUID: 9QnIbHjdSyQ-O_vrjY1bagm_AfVZPpoz X-Authority-Analysis: v=2.4 cv=R6eWitRX c=1 sm=1 tr=0 ts=6b0d8268 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=kj9zAlcOel0A:10 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=VwQbUJbxAAAA:8 a=6_FQ8liDbMlyyUp9SzgA:9 a=CjuIK1q_8ugA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDA1NiBTYWx0ZWRfX+qLlnDtCYr+Q F9aQ8rrU6S7SRjgiXcRA3jQ8TcF+y6nY4IDQ4jBnTIz7fbYAUyJ79vvTa/SmoDM0XJDLTk62DrW H0PRZlTgnib1NM5DdXzpUks854RTaCiVOSS3yuCXCwqsoJuUH8beH0Nk2ylfjBuXDGtqjIFLj1t BQqo7fZgoLRi+gRzgSHskG/uryPPPTrkDlFPgWNXdiJk5Dl3DE0FT42Qq7GOxJNpfEO4LrhZXwf wv2+09J1dV+2YNdWfZZ02tKKPeIl6+AWoYnFVIqQI2J6F9jUftRpwb5AxyC9mb7yTO+aX+ghgRt ZpBrRZJZsJFM9dfRLKyNbOGx+R+VoSlkIX6n16bZh9PlCFe3G2oFO/ssqkyWHNrcMTS/kjnBZfv GOrIXPwUMwm+qQbPSXPNc3icjnjrolG8ABVkXF5m4653nQDsRDSaiKSXMwcCipj4/dcEhkXRXX2 EYtSilT2TRPQ+oPTKNg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_04,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 spamscore=0 bulkscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300056 On Mon, 30 Nov 2026 09:23:37 +0100 Christian Borntraeger wrote: > Am 27.11.26 um 16:04 schrieb Claudio Imbrenda: > > In case all of the following apply at the same time: > > > > * a higher priority GISA interrupt is pending > > * a lower priority classic interrupt is also pending > > * the pending interrupt queue is full > > > > then kvm_s390_reinject_io_int() will fail, the classic interrupt is > > dropped and its memory is leaked. > > > > Fix by checking whether the reinjection of the interrupt succeeded, and > > free it if not. The interrupt is still dropped, but no leak occurs. > > > > This is not expected to happen during normal guest operation, due to > > the large maximum size of the pending interrupt queue. > > > > Fixes: 4b35f65e67ee ("KVM: s390: make kvm_s390_get_io_int() aware of GISA") > > Cc: stable@vger.kernel.org > > Signed-off-by: Claudio Imbrenda > > --- > > arch/s390/kvm/s390/interrupt.c | 13 +++++++++++-- > > 1 file changed, 11 insertions(+), 2 deletions(-) > > > > diff --git a/arch/s390/kvm/s390/interrupt.c b/arch/s390/kvm/s390/interrupt.c > > index 31a6074feffc..33672f093322 100644 > > --- a/arch/s390/kvm/s390/interrupt.c > > +++ b/arch/s390/kvm/s390/interrupt.c > > @@ -1775,8 +1775,17 @@ struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm, > > if (tmp_inti) { > > tmp_inti->type = KVM_S390_INT_IO(1, 0, 0, 0); > > tmp_inti->io.io_int_word = isc_to_int_word(isc); > > - if (inti) > > - kvm_s390_reinject_io_int(kvm, inti); > > + if (inti) { > > + /* > > + * The maximum number of pending interrupts is so > > + * high that this is impossible in practice during > > + * normal guest operation. > > + * Drop the interrupt if the limit was somehow > > + * reached anyway, and free it, to avoid a leak. > > + */ > > + if (kvm_s390_reinject_io_int(kvm, inti)) > > + kfree(inti); > > + } > > can we do an even better another workaround? make the gisa interrupt lower priority and keep it > queued and inject the classic interrupt instead. something like > > if (inti && kvm_s390_reinject_io_int(kvm, inti)) { > /* > * The floating I/O queue is full: deliver the classical > * I/O interrupt and leave the adapter interrupt in GISA. > */ > kfree(tmp_inti); > gisa_set_ipm_gisc(gi->origin, isc); > goto out; > } > inti = tmp_inti; > > > > This is still a violation, but wrong prio is better then a lost interrupt. > fair enough, since it's already almost impossible to reach this scenario, and dropping an interrupt is a violation anyway, we might as well just disrespect priorities and not drop anything. Shall I write a proper patch, or do you want to do it yourself?