From: sashiko-bot@kernel.org
To: "Tobias Schumacher" <ts@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH 2/7] s390/pci: fix use-after-free race in zpci floating interrupt cleanup
Date: Wed, 19 Aug 2026 09:20:18 +0000 [thread overview]
Message-ID: <20260819092018.9658A1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260819-s390_irq_domain_fixes-v1-2-826ff27b6e97@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Teardown order creates a race condition that can overwrite a concurrently allocated IRQ vector pointer with NULL, leading to permanently lost interrupts.
- [Medium] Missing RCU publication mechanism (`rcu_assign_pointer`) for `zpci_ibv` writes creates a potential data race where the IRQ handler could read uninitialized adapter interrupt vectors.
--
--- Patch [2]: [PATCH 2/7] s390/pci: fix use-after-free race in zpci floating interrupt cleanup ---
commit 2b99a8a1009855b33744de14f0b8b1c8afadae39
Author: Tobias Schumacher <ts@linux.ibm.com>
s390/pci: fix use-after-free race in zpci floating interrupt cleanup
The interrupt handler reads zpci_ibv[si] without synchronization while
concurrent teardown can release this memory, creating a race. The fix
protects the array access with RCU synchronization.
> diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
> index c9520a16ca753..94b03d16006ba 100644
> --- a/arch/s390/pci/pci_irq.c
> +++ b/arch/s390/pci/pci_irq.c
> @@ -278,8 +278,14 @@ static void zpci_floating_irq_handler(struct airq_struct *airq,
> continue;
> }
>
> + rcu_read_lock();
> +
> /* Scan the adapter interrupt vector for this device. */
> - aibv = zpci_ibv[si];
> + aibv = rcu_dereference(zpci_ibv[si]);
[Severity: Medium]
I see that rcu_dereference() is used here to read from the array.
Does the write side in __alloc_airq() also need to be updated to use
rcu_assign_pointer()?
arch/s390/pci/pci_irq.c:__alloc_airq() {
...
/* Wire up shortcut pointer */
zpci_ibv[*bit] = zdev->aibv;
...
}
Without rcu_assign_pointer(), the required memory release barrier is missing
when the interrupt vector is published to the RCU-protected array.
> + if (!aibv) {
> + rcu_read_unlock();
> + continue;
> + }
[ ... ]
> @@ -346,9 +353,12 @@ static void zpci_msi_teardown_directed(struct zpci_dev *zdev)
>
> static void zpci_msi_teardown_floating(struct zpci_dev *zdev)
> {
> + airq_iv_free_bit(zpci_sbv, zdev->aisb);
> + zpci_ibv[zdev->aisb] = NULL;
> + synchronize_rcu();
[Severity: High]
Does freeing the bit before clearing the array pointer create a race condition?
If Thread A (teardown) frees the bit, Thread B (initializing a new device)
could allocate the exact same bit from zpci_sbv. Thread B would then allocate
its vector and assign it to zpci_ibv[bit]. When Thread A continues, it clears
zpci_ibv[zdev->aisb], overwriting Thread B's valid pointer with NULL.
Could this overwrite lead to permanently lost interrupts and a memory leak for
the new device?
> +
> airq_iv_release(zdev->aibv);
> zdev->aibv = NULL;
> - airq_iv_free_bit(zpci_sbv, zdev->aisb);
> zdev->aisb = -1UL;
> zdev->msi_first_bit = -1U;
> zdev->msi_nr_irqs = 0;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260819-s390_irq_domain_fixes-v1-0-826ff27b6e97@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-08-19 9:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 8:50 [PATCH 0/7] s390/pci: Fix multiple bugs in IRQ domain migration Tobias Schumacher
2026-08-19 8:50 ` [PATCH 1/7] s390/pci: fix double-free in zpci MSI cleanup Tobias Schumacher
2026-08-19 9:03 ` sashiko-bot
2026-08-19 8:50 ` [PATCH 2/7] s390/pci: fix use-after-free race in zpci floating interrupt cleanup Tobias Schumacher
2026-08-19 9:20 ` sashiko-bot [this message]
2026-08-19 8:50 ` [PATCH 3/7] s390/pci: fix resource leak in zpci MSI setup Tobias Schumacher
2026-08-19 9:05 ` sashiko-bot
2026-08-19 8:50 ` [PATCH 4/7] s390/pci: fix MSI directed-mode teardown IRQ bit count Tobias Schumacher
2026-08-19 9:07 ` sashiko-bot
2026-08-19 8:50 ` [PATCH 5/7] s390/pci: add NULL check in zpci_msi_clear_airq() Tobias Schumacher
2026-08-19 9:14 ` sashiko-bot
2026-08-19 8:50 ` [PATCH 6/7] s390/pci: add error cleanup in zpci_directed_irq_init Tobias Schumacher
2026-08-19 9:02 ` sashiko-bot
2026-08-19 8:51 ` [PATCH 7/7] s390/pci: move MSI affinity flag initialization to boot time Tobias Schumacher
2026-08-19 9:06 ` sashiko-bot
2026-08-19 9:24 ` [PATCH 0/7] s390/pci: Fix multiple bugs in IRQ domain migration Niklas Schnelle
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=20260819092018.9658A1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--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 \
--cc=ts@linux.ibm.com \
/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.