From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30A37306754; Fri, 7 Aug 2026 14:48:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114099; cv=none; b=QM4nOTdY+agOmeWYSE7L3+cuULo1EmFaE2lDz+FXRU8rtzcx9EFwGMRAgvyN9PwWID95Bdd6CR5DSOkn/ok2Sikti8xn7DFOpivkbzmslccK2KJRlaB/cnY0nk8KYUH6xu0x+eWYVoQnP3ze0G2efFqmFKQMLeudeC3RJpHnxBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786114099; c=relaxed/simple; bh=z61Vs3MrLnAr3wJhArLEjeVc8YZrPMOaBtFgzf75anQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=opv2JkFC2DDYnXn5NyQWLQ7110GnenJiEAbf138plsWRqQAWMZLJfMW31QWfZQnkPk4yHqWzPT6p91/J0DWV7A8KZRWK4+rk7yQMkIvE8TC0a9g6MVdUhddVxRmZgCs4gCXaL3XPLvFFknYaypEfhwUQ8p8SloKAFJ9kA6uF5Z0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bDcQXUAu; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bDcQXUAu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA19B1F000E9; Fri, 7 Aug 2026 14:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786114096; bh=G/YHfYhH3YSWZ7f06eZqpal9QKTAET4quQEaF9CmXl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bDcQXUAukgxjp+KlvduW8qObwHrUjdT6dlaYipz5oNVAovbcWxlmJM3qwujS7OnmG QEHs/4mYskn+ASVAPhoKAZbYXDkPzwD6vNcLXHSKpN6fj0Q7g9pK52/30m+vqFzthM +2R5H34ToMD5kWqemqvrEnde86qkqU/7dD/dgGSs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christian Borntraeger , Matthew Rosato , Farhan Ali Subject: [PATCH 6.12 143/337] KVM: s390: pci: Validate AIBV and AISB before pinning guest pages Date: Fri, 7 Aug 2026 16:35:46 +0200 Message-ID: <20260807143421.636249149@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143418.516897842@linuxfoundation.org> References: <20260807143418.516897842@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Farhan Ali commit 868d32ac72cba21c5c6d8a66a814b7c25a3a5c01 upstream. The AIBV holds one bit per MSI-X vector for a given function. The size of the bit vector is derived from the NOI and the AIBVO. If the size of the AIBV exceeds a single page boundary, then reject the request as we cannot safely pin the guest AIBV. Similarly reject the request if the AISB address is not 8-byte aligned as the architecture requires doubleword alignment for the summary bit address. Since the AISBO can address up to 64 bits, the size of the AISB can only be 8 bytes for the function. This also ensures the AISB doesn't exceed a single page boundary. Fixes: 3c5a1b6f0a18 ("KVM: s390: pci: provide routines for enabling/disabling interrupt forwarding") Cc: stable@vger.kernel.org Reviewed-by: Christian Borntraeger Reviewed-by: Matthew Rosato Signed-off-by: Farhan Ali Tested-by: Matthew Rosato Signed-off-by: Christian Borntraeger Signed-off-by: Greg Kroah-Hartman --- arch/s390/kvm/pci.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/arch/s390/kvm/pci.c +++ b/arch/s390/kvm/pci.c @@ -225,7 +225,7 @@ static int kvm_s390_pci_aif_enable(struc bool assist) { struct page *pages[1], *aibv_page, *aisb_page = NULL; - unsigned int msi_vecs, idx; + unsigned int msi_vecs, idx, size; struct zpci_gaite *gaite; unsigned long hva, bit; struct kvm *kvm; @@ -252,6 +252,14 @@ static int kvm_s390_pci_aif_enable(struc return gisc; /* Replace AIBV address */ + size = BITS_TO_LONGS(msi_vecs + fib->fmt0.aibvo) * sizeof(unsigned long); + npages = DIV_ROUND_UP((fib->fmt0.aibv & ~PAGE_MASK) + size, PAGE_SIZE); + /* AIBV cannot span more than 1 page */ + if (npages > 1) { + rc = -EINVAL; + goto out; + } + idx = srcu_read_lock(&kvm->srcu); hva = gfn_to_hva(kvm, gpa_to_gfn((gpa_t)fib->fmt0.aibv)); npages = pin_user_pages_fast(hva, 1, FOLL_WRITE | FOLL_LONGTERM, pages); @@ -267,6 +275,12 @@ static int kvm_s390_pci_aif_enable(struc /* Pin the guest AISB if one was specified */ if (fib->fmt0.sum == 1) { + /* AISB must be dword aligned */ + if (fib->fmt0.aisb & 0x7) { + rc = -EINVAL; + goto unpin1; + } + idx = srcu_read_lock(&kvm->srcu); hva = gfn_to_hva(kvm, gpa_to_gfn((gpa_t)fib->fmt0.aisb)); npages = pin_user_pages_fast(hva, 1, FOLL_WRITE | FOLL_LONGTERM,