From: Anthony Krowiak <akrowiak@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-s390@vger.kernel.org,
Alexander Gordeev <agordeev@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
kvm@vger.kernel.org,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>
Subject: Re: [PATCH v7 5/6] s390/vfio-ap: fix queue state leakage to guest and host
Date: Thu, 24 Sep 2026 17:47:07 -0400 [thread overview]
Message-ID: <bb74e30c-ee6c-474e-b60c-f2f55928f49b@linux.ibm.com> (raw)
In-Reply-To: <20260904224637.A2C711F00A3D@smtp.kernel.org>
On 9/4/26 6:46 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] A hardware error during queue reset circumvents the newly introduced security check, incorrectly marking a potentially un-zeroized queue as 'passable'.
> --
>
> commit 239f603c9ac4d1441b4d22a11bde0df9a2b5aa5c
> Author: Anthony Krowiak <akrowiak@linux.ibm.com>
>
> s390/vfio-ap: fix queue state leakage to guest and host
>
> This commit introduces an upper bound on the wait time for a queue reset
> to complete and prevents the leakage of queue state to guests. It ensures
> zeroization is strictly confirmed by returning true in _queue_passable()
> only when the response code is AP_RESPONSE_NORMAL.
>
>> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
>> --- a/drivers/s390/crypto/vfio_ap_ops.c
>> +++ b/drivers/s390/crypto/vfio_ap_ops.c
>> @@ -785,14 +785,14 @@ static bool _queue_passable(struct vfio_ap_queue *q)
>> if (!q)
>> return false;
>>
>> - switch (q->reset_status.response_code) {
>> - case AP_RESPONSE_NORMAL:
>> - case AP_RESPONSE_DECONFIGURED:
>> - case AP_RESPONSE_CHECKSTOPPED:
>> - return true;
>> - default:
>> - return false;
>> - }
>> + /*
>> + * A queue is only passable if zeroization was confirmed by
>> + * apq_reset_check() via TAPQ status bit verification. This is
>> + * indicated by reset_status.response_code == AP_RESPONSE_NORMAL (0).
>> + * This is to protect against leaking the internal state of the queue
>> + * to the guest.
>> + */
>> + return q->reset_status.response_code == AP_RESPONSE_NORMAL;
>> }
> [ ... ]
>
>> @@ -2129,7 +2153,7 @@ static void apq_reset_check(struct work_struct *reset_work)
>> */
>> vfio_ap_free_aqic_resources(q);
>> return;
> [Severity: High]
> This is a pre-existing issue, but does this error path leave
> q->reset_status.response_code set to AP_RESPONSE_NORMAL if a hardware or
> firmware fault occurs?
>
> When vfio_ap_mdev_reset_queue() successfully initiates a reset, ap_zapq()
> returns AP_RESPONSE_NORMAL (0), which is initially copied into
> q->reset_status.
>
> If ap_tapq() subsequently returns an invalid response code causing
> apq_status_check() to return -EIO, this workqueue function aborts and frees
> the AQIC resources. However, it exits without updating q->reset_status to a
> failure state.
>
> Because _queue_passable() now strictly checks for AP_RESPONSE_NORMAL, could
> this fail-open state result in an un-zeroized queue being incorrectly passed
> to an untrusted guest, leaking cryptographic key material?
This will be fixed in the next version.
>
>> -
>> + }
>> if (elapsed >= AP_RESET_MAX_WAIT) {
>> /*
>> * Zeroization confirmed (ret == 0): the TAPQ status bits
>> @@ -2143,8 +2167,10 @@ static void apq_reset_check(struct work_struct *reset_work)
>> * queue cannot generate interrupts, so the NIB page is
>> * no longer a DMA target and it is safe to free it.
>> */
next prev parent reply other threads:[~2026-09-24 21:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 22:35 [PATCH v7 0/6] s390/vfio-ap: Fix pre-existing bugs in vfio_ap device driver Anthony Krowiak
2026-09-04 22:35 ` [PATCH v7 1/6] s390/vfio-ap: Fix leaks of pinned NIB and registered GISC Anthony Krowiak
2026-09-04 22:51 ` sashiko-bot
2026-09-22 14:29 ` Anthony Krowiak
2026-09-22 16:54 ` Christian Borntraeger
2026-09-04 22:35 ` [PATCH v7 2/6] s390/vfio-ap: Fix failure to release IRQ notification eventfd contexts Anthony Krowiak
2026-09-04 22:49 ` sashiko-bot
2026-09-04 22:35 ` [PATCH v7 3/6] s390/vfio-ap: Fix unbounded loop in apq_reset_check() Anthony Krowiak
2026-09-04 22:49 ` sashiko-bot
2026-09-04 22:35 ` [PATCH v7 4/6] s390/vfio-ap: Use AP_DOMAINS for adm_add bitmap size in vfio_ap_mdev_cfg_add() Anthony Krowiak
2026-09-04 22:46 ` sashiko-bot
2026-09-04 22:35 ` [PATCH v7 5/6] s390/vfio-ap: fix queue state leakage to guest and host Anthony Krowiak
2026-09-04 22:46 ` sashiko-bot
2026-09-24 21:47 ` Anthony Krowiak [this message]
2026-09-04 22:35 ` [PATCH v7 6/6] s390/vfio-ap: replace guest-reachable WARNs with ratelimited warnings and add dmesg visibility to DBF_WARNs Anthony Krowiak
2026-09-04 22:50 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb74e30c-ee6c-474e-b60c-f2f55928f49b@linux.ibm.com \
--to=akrowiak@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox