From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Anthony Krowiak <akrowiak@linux.ibm.com>,
sashiko-reviews@lists.linux.dev
Cc: Heiko Carstens <hca@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
kvm@vger.kernel.org, Vasily Gorbik <gor@linux.ibm.com>,
linux-s390@vger.kernel.org,
Matthew Rosato <mjrosato@linux.ibm.com>,
Jason Herne <jjherne@linux.ibm.com>
Subject: Re: [PATCH v7 1/6] s390/vfio-ap: Fix leaks of pinned NIB and registered GISC
Date: Tue, 22 Sep 2026 18:54:34 +0200 [thread overview]
Message-ID: <e9d6ba2e-3751-480b-83ce-3c6854cbcd4b@linux.ibm.com> (raw)
In-Reply-To: <a0a5fbf4-829f-42bc-98f1-a8ee022b6c4b@linux.ibm.com>
Am 22.09.26 um 16:29 schrieb Anthony Krowiak:
>
>
> On 9/4/26 6:51 PM, sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>> - [Critical] Eagerly freeing AQIC resources when ap_zapq() or ap_tapq() returns an unrecognized response allows wild DMA writes to freed host memory.
>> --
>>
>> commit 6c73d9ea4d311d5d68e8f5501374842cccbe2c90
>> Author: Anthony Krowiak <akrowiak@linux.ibm.com>
>>
>> s390/vfio-ap: Fix leaks of pinned NIB and registered GISC
>>
>> Several code paths in the vfio_ap driver failed to free the AQIC
>> resources — the pinned guest NIB page and the registered guest ISC
>> used to enable interrupts for a queue — when a queue became unavailable
>> or when unexpected response codes were returned. This could cause memory
>> exhaustion and depletion of KVM interrupt subclass registrations over time
>> with repeated dynamic AP reconfiguration.
>>
>>> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
>>> index 940c0ff668bee..9d4f5b9e3301f 100644
>>> --- a/drivers/s390/crypto/vfio_ap_ops.c
>>> +++ b/drivers/s390/crypto/vfio_ap_ops.c
>> [ ... ]
>>> @@ -1959,8 +2087,16 @@ static void apq_reset_check(struct work_struct *reset_work)
>>> elapsed += AP_RESET_INTERVAL;
>>> status = ap_tapq(q->apqn, NULL);
>>> ret = apq_status_check(q->apqn, &status);
>>> - if (ret == -EIO)
>>> + if (ret == -EIO) {
>>> + /*
>>> + * TAPQ returned an invalid response code. This
>>> + * indicates a hardware or firmware bug; the queue
>>> + * cannot generate AP interrupts or DMA-write to the
>>> + * NIB, so free the AQIC resources rather than leak them.
>>> + */
>>> + vfio_ap_free_aqic_resources(q);
>>> return;
>>> + }
>> [Severity: Critical]
>> If apq_status_check() returns -EIO due to an unrecognized TAPQ response,
>> is it safe to eagerly free the AQIC resources?
>>
>> If the hardware is in an unknown state (due to a bug or unrecognized code),
>> could it still be actively DMA-writing to the pinned Notification Indicator
>> Byte (NIB) page?
>>
>> If vfio_ap_free_aqic_resources() unpins the page and returns it to the
>> system allocator, could a subsequent wild DMA write from the malfunctioning
>> AP queue corrupt memory belonging to a new owner, potentially causing a host
>> panic?
>
> Since we don't know the state of the queue, the AQIC resources should be
> intentionally leaked here lest the NIB page be re-allocated to another
> process potentially resulting in a wild DMA-write.
Yes, we should not free the ressources and rather leak them to avoid reuse.
next prev parent reply other threads:[~2026-09-22 16:54 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 [this message]
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
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=e9d6ba2e-3751-480b-83ce-3c6854cbcd4b@linux.ibm.com \
--to=borntraeger@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=akrowiak@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--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