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 9BFFD473C9A; Fri, 7 Aug 2026 15:06:21 +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=1786115183; cv=none; b=JKteLaHwfL0dt/fh9Dt/kQrSJKjPj+IBVWRqcyGTrkTY19RLXyPEf9Jqz4igaksSKc3aAN7OrZa7jzv3T2PQ2Qlxa7ja0/BxzqLSbnuK//Zzi5XbdOee/67PLy088IT+OQVyGN0LL33cnnqy4LWxW+8SX2anhdDHQ2feAiPgsCQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786115183; c=relaxed/simple; bh=kHFsfK1ijD65ih4LIZ4vsgNZPGQmLpsEScQCh6MGUw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iDDCumMY3MNnHZNtQHvbN65UeCNMa1XVsHp3EJrS/T7Xf3VdTiOMdDMJcsu6BneuCtcAoSzGL5I+aIYtXWs6m9JNUEmDLsYSvEdx5Yjq8rp6DYJzMaOUIIo4HyWJ4yDJbttAiFnzsWnN0nlf7j0NFbweYLkotebVxdsY52HGA74= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ibab1n7q; 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="Ibab1n7q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E4C81F000E9; Fri, 7 Aug 2026 15:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786115180; bh=NjbHn/mJEV1IvxzfJ5xE9JAZFlJkWY4/nniy5r3ByCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ibab1n7qdr+oRhHzRR2IiG+a3RbacXFmTavDqHLkZn29N3rSGAeJe8ATjbtw8mOGJ eDg6Z405uKdIHC92Er/5A0XuzRDLQtHlzjohGPCSpY/sXY4Ftbuxw2DyinvkI3Pgy4 Fd/3UfnT+ZXYDFjy15ybs0InoOyG4jEKKWVcRyfg= 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.18 184/396] KVM: s390: pci: Validate AIBV and AISB before pinning guest pages Date: Fri, 7 Aug 2026 16:35:44 +0200 Message-ID: <20260807143428.259478774@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143424.272339768@linuxfoundation.org> References: <20260807143424.272339768@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.18-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 @@ -245,7 +245,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; @@ -272,6 +272,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); @@ -287,6 +295,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,