From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796335714; b=ZIfFE7DMBtX/BTA0CTY7AxktVYwRSmnGfZUn5Hf2+oKbvOmrxcJQew2a20cOZSMhvb1O WwxO3x69h2B5Cqtxn6N0hZ712bV374HMVRR1YeHNbM1vUpKTZ9K7VC6yAKcWoI6q1d7/y g99B/tmhIX+NTihMDHqaksynegDlpux6whvYAsRFB8FmYlQC0bvA9lgXN4WQCnSuZuvM7 GHaL2VPofzSSuL/cwppsr7lLD8+dJY4uythXASozBtEdDlG2FSp0x6KRbVnzw60KB5343 wDUM7/8VQ0vvE83P8tBvR5jpuRC3hVJoaoGi+Vp1y9ayh/8/Fum/WVhPnMGYKHxEtmQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796335714; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=MFMwaK9zqZbrKTxIhjNRAFbhP+TJn+EIfucz4K1+CGI=; b=zqv9fbpSYR/7eGTF2WT/ZEu/UbhmMmiWezT/QxJE7590hxkgEiliL160TG6uawIgrVye 4r0lsUkVrnncWqPXoBgu7Nx3XOfpefaorzxoAMNKGEVXSZry+D7qqYN2cVcWuIB4hwaL5 ixlEhdfhVpzV54nZ/PEjx+9WmKbjvAFFbwG3GuYdIdp5VW9ah4Qw1BErcxZ/tIkU0N+vz /TXp1xH3KNRTzRkJzZReFU5/5FLIUh3cBx6nQwokskaBAFmf7M/QwQH6lvN8w4axdyjhy K0KctNfgIuRmGc+5hxFrB5oI7Eds38ExtTlPTmM6v2ODVon7HnYAWHz7w+D+OXPCEDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jN8K7et1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10856606A322 for ; Thu, 3 Dec 2026 22:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jN8K7et1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 660A61F0092C; Thu, 3 Dec 2026 22:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796335713; bh=MFMwaK9zqZbrKTxIhjNRAFbhP+TJn+EIfucz4K1+CGI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=jN8K7et1WVk58RYvSj7MCmr/hAguSvJ93yWXyBEo9YEckqTzHXJBpj2xhkpnpvxVF mOi/uzNuTMk3c0av5txUX8TqdX3w3TilcHuc62PuPFpYdh7G/Flc7K/MYPd9FSOpL0 rhFnXLoNT/PtNfE9pr7wuQS4HZeFnRUeuvoeFVw3wslLFKamY1KyZfPsFZ+aC8LmgI mC4WinWSHkcX6dtlL+G0oxciFcxQlNx4qo57ViAeJwkDXbcoHOFuR0d5rh3cEa5J+c 94dKjFkDfTsy63QXS8nuWD+OIjlsyi/V029f5Mq4OFPvW4NdTLCybXqoNhoO7DOJwg hW9qpXhEw0H4w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/5] s390/vfio-ap: bound the wait for queue reset verification Reply-To: sashiko-reviews@lists.linux.dev To: "Jason J. Herne" , linux-s390@vger.kernel.org Cc: "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" In-Reply-To: <20261203214531.1395796-3-jjherne@linux.ibm.com> References: <20261203214531.1395796-1-jjherne@linux.ibm.com> <20261203214531.1395796-3-jjherne@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 22:08:33 +0000 X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] s390/vfio-ap: timed-out unreset queue still passed to next guest - [High] s390/vfio-ap: sie_page2 GISA freed while unreset queue still references it - [Low] s390/vfio-ap: final ap_zapq() retry leaks NIB on non-operational status -- commit b0dd58c5d0782ca7241d08c5695985f4c6e563d9 Author: Jason J. Herne s390/vfio-ap: bound the wait for queue reset verification This commit adds a 2-second timeout to apq_reset_check() so that verification of an AP queue reset does not loop indefinitely, leaking AQIC resources and recording a non-zero reset_status on timeout. > diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio= _ap_ops.c > index 10430b9446dbb..fba6f256ce77a 100644 > --- a/drivers/s390/crypto/vfio_ap_ops.c > +++ b/drivers/s390/crypto/vfio_ap_ops.c [ ... ] > @@ -1974,6 +1975,20 @@ static void apq_reset_check(struct work_struct *re= set_work) > q =3D container_of(reset_work, struct vfio_ap_queue, reset_work); > memcpy(&status, &q->reset_status, sizeof(status)); > while (true) { > + if (elapsed >=3D VFIOAP_RESET_TIMEOUT) { [Severity: Low] Can this timeout check leak the NIB page if the final ap_zapq() retry returns a non-operational status? When elapsed reaches VFIOAP_RESET_TIMEOUT, the ap_zapq() retry path continues straight into this check without inspecting status.response_code. If that ap_zapq() returned AP_RESPONSE_DECONFIGURED, AP_RESPONSE_CHECKSTOPPED, or AP_RESPONSE_Q_NOT_AVAIL, this logs a spurious timeout warning and leaks the NIB page instead of freeing AQIC resources via the -ENODEV path. > + /* > + * Reset timed out. The queue could still be active so > + * leak AQIC resources rather than risk wild DMA write. > + */ > + pr_warn_ratelimited("Reset timed out for APQN %02x.%04x: leaking NIB = page to prevent host crash\n", > + AP_QID_CARD(q->apqn), > + AP_QID_QUEUE(q->apqn)); [Severity: High] What prevents the unreset AP queue from writing to a freed GISA page after VM teardown? vfio_ap_irq_enable() programs the queue hardware with both h_nib and the physical address of kvm->arch.sie_page2->gisa via ap_aqic(). When this timeout lets vfio_ap_mdev_unset_kvm() return, KVM proceeds to kvm_arch_destroy_vm() and calls kfree(kvm->arch.sie_page2). If the still-active queue later raises an interrupt, hardware can write to the freed and reused host kernel page, causing host memory corruption. (Because saved_isc is not unregistered here, this also triggers WARN(gi->alert.mask !=3D 0x00) in kvm_s390_gisa_destroy().) > + memcpy(&q->reset_status, &status, sizeof(status)); > + if (!q->reset_status.response_code) > + /* Record BUSY status so queue is not passable. */ > + q->reset_status.response_code =3D AP_RESPONSE_BUSY; > + return; > + } [Severity: High] Does recording a non-zero reset_status actually prevent the unreset queue from being passed to the next guest? _queue_passable() is only checked inside vfio_ap_mdev_filter_matrix(), which is not called when detaching or attaching a guest. During VM teardown, vfio_ap_mdev_unset_kvm() ignores the -EIO return from vfio_ap_mdev_reset_queues() and leaves matrix_mdev->shadow_apcb intact. When another guest later opens the same mdev, vfio_ap_mdev_set_kvm() calls vfio_ap_mdev_update_guest_apcb() directly with that stale shadow_apcb. The new guest then gets access to the unreset, unzeroized queue, breaking guest-to-guest isolation. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203214531.1395= 796-1-jjherne@linux.ibm.com?part=3D2