From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796237444; b=Yr93yBYgqKS1Ac5AisbbXGSObULlECmE+pIIV0QELAgUgj976pB1US713WA6343PH2SX jy/zOOVOtFXNv5fM3i+cMGwtgAq7XMFsGAD+grem1vVIYvUHRLoy3c9TIAEx82rCp1DMy LlttqA2VDDNqnJKFeEu6d8rTyk8dk6aeQ0zGYud5MT+xVXNSkol5mu6Aec+NnQxKYQ+Mq hFehx6iAguLyb1Sj0IF5gbIbA98cWxwmyT36ralY8kl1CZjxIceJmadwzljqLNUNt82vb 7cN+DVj980xr0ZCctObdvwfztkqhywVlP6ucTDUM+0sQhHwXo4xITrcN4924zQdJfaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796237444; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-TM-AS-GCONF:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Spam-Info:X-Authority-Analysis: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=CCwGMfQ5Unj/aIkR9Zx2KOdnl+lyR7X9kj7PhVDp95E=; b=TVuvhxCUIEAb/YhiXNziyQXBVoy69az+F6tIHqMr+fzHiELQ9N33a66N4HHxIDIJY884 wPUzMV8Tc3yUxOuu9VIAUXOwhMCJ16gKvpGFwrJrPIYnnW6ng7L7tDoTh4zu97CYN05Lw /M9R4KK+Pj2G0UhqjK5PQRhek/ZejSA+22p2+PU4U8a3LCz0igwTGZZYbRi3IY9+ItQ/w jfIs637vhCoZfK4JJeA0kBR0c37mzRaYvxXYo97OYiqzAvOQG2JIAz1fuq11BhnOl3lnm 4yryQk26Ak+kMAIeIglVxIqztwgfRiakoMPFrNdn4hB40+GYfQ2rETAT8lxh1cEb34Q== 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=aZDsOSN2; 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 45A27606A68B; Wed, 2 Dec 2026 18:50:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 45A27606A68B 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) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=aZDsOSN2 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2I4jYD3754897; Wed, 2 Dec 2026 18:50:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=CCwGMfQ5Unj/aIkR9 Zx2KOdnl+lyR7X9kj7PhVDp95E=; b=aZDsOSN2EsFgY9qUfBBkxjDoLtOXqEOWl viIAKV/Ima8X3FJjrlysuVqoJqlEXl0iv4NLfyvvMbFGRkp8SDQXTBcbBv6jlvxC 0a3Sln/grvkWX4U1ADGcbkIL3erag+bynPHyfdeoGQaBz90T88ok/IjrDdz/587h r4ZaT5RatCtVoa2+V1+LfxJu6LhGMqXNvoSpYiFNwl7FxMEzXivBH33kg65RCry5 LSFF86Mc3kloZrCv2+CZHrnZpyu6BGI30WDzvD9Tvi2lmJNdKaJuwJHu4eFEtAwG vb+9ej3YHGy3w2t0IuXHgdYrc26TY2D1YiiYxLVQhmrjQJJPBxP5w== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pmtbf85-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 18:50:25 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2I7QjM3553711; Wed, 2 Dec 2026 18:50:25 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4j9v5w6asg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 18:50:25 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B2IoL0m46006636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Dec 2026 18:50:21 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A9AA2004B; Wed, 2 Dec 2026 18:50:21 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6930020043; Wed, 2 Dec 2026 18:50:21 +0000 (GMT) Received: from p-imbrenda.ehn-de.ibm.com (unknown [9.68.31.243]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 2 Dec 2026 18:50:21 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, david@kernel.org, nrb@linux.ibm.com, schlameuss@linux.ibm.com, gra@linux.ibm.com, seiden@linux.ibm.com Subject: [PATCH v2 02/12] KVM: s390: Fix potential leak in kvm_s390_get_io_int() Date: Wed, 2 Dec 2026 19:50:10 +0100 Message-ID: <20261202185020.241132-3-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261202185020.241132-1-imbrenda@linux.ibm.com> References: <20261202185020.241132-1-imbrenda@linux.ibm.com> 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-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: O1_YwRmhyh25nRBVfiAeoS-Vjcx8vsLa X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA3NCBTYWx0ZWRfX5GODeylloG37 6a33zM/A2u5hsxrRSCBSjK3h4Uw8FCd5k2O5i+fcO6D/csu9EXRiJQCuyNnVAsnrh2iUwFUkm63 dlfSY36nPcRSa3CZqh7auN1OqJ0FVbdoeHYqhE4QNg1qn30GhO1TYIaj0xc7okjZgUHTU7X2Knx f47HG0DwV8jPRSoi3Avlp6Hbi1h96IQ3nCiXgCwJWmDIo2XKylW/G4y1V/pwhx5M2fZ8QrUPFfC xkjgXAf7yV+kF2DsSgSbzBNv4ZN+SWy7LogrkDq2T9iBc4gHvirT9LqDopNOvIXyoIilKDu0I5g 5cCiLxioW9caTdNdC8AICZMqEtw4nvMzONYzmn3b0GvUBS/Jby5r7uuVUmySThWS+NpqhAWOgOu Y9kxuEZz4VtUSlbMLd3n/ZOgqHIptQOVsco5WLVaeIJqRlz85WNo4obRSNAHcufvCXRukZhoACI hcWA3RtZIqIsL99/EXw== X-Proofpoint-GUID: O1_YwRmhyh25nRBVfiAeoS-Vjcx8vsLa X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA3NCBTYWx0ZWRfX79QZshO6qseE eyXZKoX2gXKYZvAWEVXsusMU2fhdbzd/vA9KuYU7tGfrP8sgYDzaIsKcZgOy0a/aDQp6W1duzUl 5jQD8X52fqITEhBTeVvznn7FjqoeiWM= X-Authority-Analysis: v=2.4 cv=U9cHnuru c=1 sm=1 tr=0 ts=6b106872 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=qVwGWHX9UI8Ynp3XYQ8A:9 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-12-02_04,2026-12-02_07,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020074 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 in case of failure, inject the lower priority interrupt and keep the higher priority GISA interrupt pending. While this is technically a violation of the architecture, it's a smaller violation than dropping an interrupt completely. 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 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/s390/kvm/s390/interrupt.c b/arch/s390/kvm/s390/interrupt.c index 31a6074feffc..8612d2e96205 100644 --- a/arch/s390/kvm/s390/interrupt.c +++ b/arch/s390/kvm/s390/interrupt.c @@ -1775,8 +1775,21 @@ 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 && kvm_s390_reinject_io_int(kvm, inti)) { + /* + * The maximum number of pending interrupts is so + * high that this is impossible in practice during + * normal guest operation. + * If this happens anyway, deliver the lower + * priority interrupt, instead of discarding it. It + * is still technically a violation of the + * architecture, but it's not as bad as dropping an + * interrupt entirely. + */ + kfree(tmp_inti); + gisa_set_ipm_gisc(gi->origin, isc); + goto out; + } inti = tmp_inti; } else gisa_set_ipm_gisc(gi->origin, isc); -- 2.56.1