From: "Tobias Schumacher" <ts@linux.ibm.com>
To: <sashiko-reviews@lists.linux.dev>,
"Tobias Schumacher" <ts@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
<linux-s390@vger.kernel.org>, "Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH v3 4/8] s390/pci: Fix use-after-free race in zpci floating interrupt cleanup
Date: Fri, 09 Oct 2026 10:22:11 +0200 [thread overview]
Message-ID: <DM05UI42G3Y8.M70PK5HKUNKQ@linux.ibm.com> (raw)
In-Reply-To: <sashiko-outbox-164948@kernel.org>
On Fri Oct 9, 2026 at 8:32 AM CEST, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] s390/pci: pending directed MSIs cause spurious interrupts on reallocation
> --
>
> commit 125383b5f8790de7f1cbeff916db7b71f9226ee6
> Author: Tobias Schumacher <ts@linux.ibm.com>
>
> s390/pci: Fix use-after-free race in zpci floating interrupt cleanup
>
> This commit splits directed vectors from floating vectors into a separate
> zpci_dibv array and adds RCU synchronization to zpci_msi_teardown_floating()
> to prevent use-after-free issues. It also annotates zpci_ibv with __rcu to
> ensure safe access to floating vectors during teardown.
>
>> diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
>> index d5763c5feb097..c5fabad381395 100644
>> --- a/arch/s390/pci/pci_irq.c
>> +++ b/arch/s390/pci/pci_irq.c
> [ ... ]
>> @@ -342,13 +343,16 @@ static struct airq_struct zpci_airq = {
>>
>> static void zpci_msi_teardown_directed(struct zpci_dev *zdev)
>> {
>> - airq_iv_free(zpci_ibv[0], zdev->msi_first_bit, zdev->msi_nr_irqs);
>> + airq_iv_free(zpci_dibv[0], zdev->msi_first_bit, zdev->msi_nr_irqs);
>
> [Severity: High]
> Does this code leave pending DMA bits on remote CPUs intact?
>
> Only CPU 0's vector is passed to airq_iv_free() here, which clears the
> physical vector bits on CPU 0 but leaves them untouched on remote CPUs.
>
> If a hardware adapter interrupt was pending on a remote CPU in
> zpci_dibv[N]->vector, the bit remains set. Furthermore, there is no
> synchronization (such as synchronize_rcu() or draining) to ensure remote
> CPUs have finished processing the old bit before it is freed.
>
> When a new device allocates the same MSI bit, it will overwrite the ptr and
> data fields across all CPUs without memory barriers. If a remote CPU then
> processes its delayed interrupt, it will read the newly populated ptr and
> data, resulting in a spurious interrupt delivered to the wrong device or a
> potential kernel panic from an inconsistent domain/hwirq pair.
The only change this patch makes to zpci_msi_teardown_directed() is the
rename from zpci_ibv to zpci_dibv. Freeing the directed bits only in
CPU 0's vector goes back to the original commit introducing directed
interrupts. A stale bit on a remote CPU could in theory end up as a
spurious interrupt for a device that later gets the same bit, but until
the bit is reused, the cleared pointer makes the lookup fail harmlessly.
I'll have a look at clearing the bits on all CPUs separately from this
series.
Thanks
Tobias
next prev parent reply other threads:[~2026-10-09 8:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 6:15 [PATCH v3 0/8] s390/pci: Fix bugs in IRQ domain migration and resource cleanup Tobias Schumacher
2026-10-09 6:15 ` [PATCH v3 1/8] s390/pci: Fix double-free and NULL deref in zpci MSI domain cleanup Tobias Schumacher
2026-10-09 6:28 ` sashiko-bot
2026-10-09 6:15 ` [PATCH v3 2/8] s390/pci: Fix resource leak in zpci MSI setup Tobias Schumacher
2026-10-09 6:28 ` sashiko-bot
2026-10-09 6:15 ` [PATCH v3 3/8] s390/pci: Fix MSI directed-mode teardown IRQ bit count Tobias Schumacher
2026-10-09 6:33 ` sashiko-bot
2026-10-09 6:15 ` [PATCH v3 4/8] s390/pci: Fix use-after-free race in zpci floating interrupt cleanup Tobias Schumacher
2026-10-09 6:32 ` sashiko-bot
2026-10-09 8:22 ` Tobias Schumacher [this message]
2026-10-12 8:21 ` Niklas Schnelle
2026-10-09 6:15 ` [PATCH v3 5/8] s390/pci: Add error cleanup in zpci_directed_irq_init() Tobias Schumacher
2026-10-09 6:25 ` sashiko-bot
2026-10-12 8:39 ` Niklas Schnelle
2026-10-09 6:15 ` [PATCH v3 6/8] s390/pci: Set MSI_FLAG_NO_AFFINITY at IRQ init time Tobias Schumacher
2026-10-09 6:26 ` sashiko-bot
2026-10-09 6:15 ` [PATCH v3 7/8] s390/pci: Drop the unused index argument of zpci_msi_clear_airq() Tobias Schumacher
2026-10-09 6:23 ` sashiko-bot
2026-10-09 6:15 ` [PATCH v3 8/8] s390/pci: Unregister the adapter interrupt first in zpci_irq_exit() Tobias Schumacher
2026-10-09 6:29 ` sashiko-bot
2026-10-09 7:10 ` Tobias Schumacher
2026-10-12 8:50 ` Niklas Schnelle
2026-10-12 9:01 ` Niklas Schnelle
2026-10-12 11:22 ` [PATCH v3 0/8] s390/pci: Fix bugs in IRQ domain migration and resource cleanup Heiko Carstens
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=DM05UI42G3Y8.M70PK5HKUNKQ@linux.ibm.com \
--to=ts@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.