Linux s390 Architecture development
 help / color / mirror / Atom feed
From: "Tobias Schumacher" <ts@linux.ibm.com>
To: <sashiko-reviews@lists.linux.dev>,
	"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: Thu, 20 Aug 2026 09:29:39 +0200	[thread overview]
Message-ID: <DKTLF1G2Y3IJ.1BFJVN2AVM17U@linux.ibm.com> (raw)
In-Reply-To: <20260819092018.9658A1F00A3A@smtp.kernel.org>

On Wed Aug 19, 2026 at 11:20 AM CEST, sashiko-bot wrote:
-- snip --

>> 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.

Yes, will fix that.

>> +		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?

Looks like you're right, I'll investigate and fix it in a follow-up
series.

Tobias


  reply	other threads:[~2026-08-20  7:29 UTC|newest]

Thread overview: 22+ 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-20  7:20     ` Tobias Schumacher
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
2026-08-20  7:29     ` Tobias Schumacher [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-20  7:43     ` Tobias Schumacher
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-20  8:30     ` Tobias Schumacher
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-20  8:41     ` Tobias Schumacher
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-20  9:01     ` Tobias Schumacher
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=DKTLF1G2Y3IJ.1BFJVN2AVM17U@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox