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 D9E3644781F; Mon, 17 Aug 2026 15:18:33 +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=1786979915; cv=none; b=drKGAcH2uGJe4UJfMge1K+2TBNqHmNuOxxYSAORmnjBUt9onh9UXs3FG7Vl2wLOO7Tbj4RxPsUAqSRZ49UKAQCR2kCyCeLHs+IfAJoKOyccSI03pihi4xMV1oy3vqNSgQ2Ex06U47vI+dZ2jKqQ48DrxNXrOcxBG0fdhICck2Rw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786979915; c=relaxed/simple; bh=ggfUkMndEx8n9iv5jAn6WciAHMCzkAdRv7M27FH5X98=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BIYgx/AEYDA8LdazlyB8grVZlKFwWvM5bS0NimmWrT8ChU+g06e+a8rrCsWb4Jan3EniG4IlY3bLK9eTPCwZRwO/q5cm7sY1bI7sBYU1Q8fiM4rglqOxZmjwAmB8PMqX7blXvrIZevw9Vj6sgLod9HsxaC3Wpknr4oQskyowulM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YMCsE2dG; 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="YMCsE2dG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EFC91F000E9; Mon, 17 Aug 2026 15:18:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786979913; bh=c1MDN7Et6x7jGC0Yu988HJ7CnJK2YqpKhQPFa0rO96c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YMCsE2dGtAEjlEJuBZELaaHhI4S9scn9qDBiR6FGivd5NflpaEtfSVBiOt2u7dGLr mDwr1QTpas44smdkphkFblhI+Vv45P9C3JfF0gnlIiFxG41zAbIFg+gcFMNb5ELN94 5POrEX2L9QNyGZeIbQJRalreLzeIWJ2KEhGT3hUk= 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.1 390/609] KVM: s390: pci: Validate AIBV and AISB before pinning guest pages Date: Mon, 17 Aug 2026 15:31:26 +0200 Message-ID: <20260817132557.292823993@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132543.039278408@linuxfoundation.org> References: <20260817132543.039278408@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.1-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,