All of lore.kernel.org
 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: "Alexander Gordeev" <agordeev@linux.ibm.com>,
	<linux-s390@vger.kernel.org>, "Vasily Gorbik" <gor@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH 4/7] s390/pci: fix MSI directed-mode teardown IRQ bit count
Date: Thu, 20 Aug 2026 10:30:19 +0200	[thread overview]
Message-ID: <DKTMPHUMVTGX.XW4LY4FQKDB4@linux.ibm.com> (raw)
In-Reply-To: <20260819090757.3F4051F000E9@smtp.kernel.org>

On Wed Aug 19, 2026 at 11:07 AM CEST, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] Double-addition logic error in `zpci_msi_clear_airq()` causes out-of-bounds memory writes and leaves dangling pointers.

yes, see below.

> - [High] Directed MSI teardown leaks uncleared hardware vector bits on CPUs > 0, causing spurious interrupts.
> - [Medium] Missing RCU pointer assignment when publishing `zdev->aibv` to `zpci_ibv` array.

The last two findings were already discussed for the previous patches,
won't comment again here.

> --- Patch [4]: [PATCH 4/7] s390/pci: fix MSI directed-mode teardown IRQ bit count ---
> commit 061bcdd7920b9b7d42fc840ba0aa403eaf0255a5
> Author: Tobias Schumacher <ts@linux.ibm.com>
>
> s390/pci: fix MSI directed-mode teardown IRQ bit count
>
> This commit updates zpci_msi_teardown_directed() to free the actual number of
> allocated MSI bits (msi_nr_irqs) instead of the maximum supported by the
> platform (max_msi). This prevents freeing bits that were not actually
> allocated, which would corrupt the shared IRQ bitmap.
>
>> diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
>> index 5e934ac990ac1..e9eda846cb2d2 100644
>> --- a/arch/s390/pci/pci_irq.c
>> +++ b/arch/s390/pci/pci_irq.c
>> @@ -349,7 +349,7 @@ 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->max_msi);
>> +	airq_iv_free(zpci_ibv[0], zdev->msi_first_bit, zdev->msi_nr_irqs);
>
> [Severity: High]
> This is a pre-existing issue, but does this leak hardware vector bits on CPUs
> other than 0?
>
> It looks like this only clears the vector bits for zpci_ibv[0]. Since CPUs
> greater than 0 have zpci_ibv[cpu] created without AIRQ_IV_ALLOC, their avail
> mask is NULL, and airq_iv_free() returns immediately without clearing the bits
> in zpci_ibv[cpu]->vector.
>
> If a pending hardware interrupt bit is left set on a CPU greater than 0 after
> device teardown, could reallocating that bit index to a new device trigger a
> spurious interrupt on that CPU?
>
>>  	zdev->msi_first_bit = -1U;
>>  	zdev->msi_nr_irqs = 0;
>>  }

This is correct. The avail mask is NULL on CPUs greater than 0 since all
per-CPU vectors share one bit layout, so a single allocator is
sufficient. To fix this issue, we need to change airq_iv_free() to also
clear leftover interrupts bits if avail is NULL and additionally call
airq_iv_free() for all for each CPU.

Since directed interrupts are currently not used in the field, this
should be analyzed more in-depth sparately and be fixed outside this
series.

Tobias

  reply	other threads:[~2026-08-20  8:30 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
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 [this message]
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=DKTMPHUMVTGX.XW4LY4FQKDB4@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.