From: sashiko-bot@kernel.org
To: "Tobias Schumacher" <ts@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [PATCH 6/7] s390/pci: add error cleanup in zpci_directed_irq_init
Date: Wed, 19 Aug 2026 09:02:37 +0000 [thread overview]
Message-ID: <20260819090237.E61621F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260819-s390_irq_domain_fixes-v1-6-826ff27b6e97@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The newly added error cleanup path in `zpci_directed_irq_init` introduces a DMA use-after-free vulnerability.
--
--- Patch [6]: [PATCH 6/7] s390/pci: add error cleanup in zpci_directed_irq_init ---
commit 5a0360870b410d13391fe09d0a8840ffaa9cb9be
Author: Tobias Schumacher <ts@linux.ibm.com>
s390/pci: add error cleanup in zpci_directed_irq_init
This commit adds an error cleanup path to zpci_directed_irq_init to release
airq_iv resources if per-CPU allocation fails, preventing a memory leak.
> diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
> index 1515d8d7460ea..1ddf6b3625a26 100644
> --- a/arch/s390/pci/pci_irq.c
> +++ b/arch/s390/pci/pci_irq.c
> @@ -586,7 +586,7 @@ static int __init zpci_directed_irq_init(void)
>
> zpci_ibv = kzalloc_objs(*zpci_ibv, num_possible_cpus());
> if (!zpci_ibv)
> - return -ENOMEM;
> + goto out_free_sbv;
>
> for_each_possible_cpu(cpu) {
[ ... ]
> @@ -599,13 +599,25 @@ static int __init zpci_directed_irq_init(void)
> AIRQ_IV_CACHELINE |
> (!cpu ? AIRQ_IV_ALLOC : 0), NULL);
> if (!zpci_ibv[cpu])
> - return -ENOMEM;
> + goto out_free_ibv;
> }
> on_each_cpu(cpu_enable_directed_irq, NULL, 1);
>
> zpci_irq_chip.irq_set_affinity = zpci_set_irq_affinity;
>
> return 0;
> +
> +out_free_ibv:
> + for_each_possible_cpu(cpu) {
> + if (zpci_ibv[cpu])
> + airq_iv_release(zpci_ibv[cpu]);
> + }
> + kfree(zpci_ibv);
> + zpci_ibv = NULL;
> +out_free_sbv:
> + airq_iv_release(zpci_sbv);
[Severity: High]
Does this new error path introduce a potential DMA use-after-free?
Just before the allocation of zpci_ibv, the hardware is configured with the
physical address of zpci_sbv->vector:
arch/s390/pci/pci_irq.c:zpci_directed_irq_init() {
...
iib.diib.disb_addr = virt_to_phys(zpci_sbv->vector);
zpci_set_irq_ctrl(SIC_IRQ_MODE_DIRECT, 0, &iib);
zpci_ibv = kzalloc_objs(*zpci_ibv, num_possible_cpus());
if (!zpci_ibv)
goto out_free_sbv;
...
}
If we jump to out_free_sbv and free zpci_sbv via airq_iv_release(zpci_sbv)
without resetting the hardware configuration first, could the adapter
corrupt memory by writing to the freed physical page during a spurious
interrupt?
Would it make sense to either defer the zpci_set_irq_ctrl() hardware
configuration until all software allocations succeed, or unregister the
hardware in the out_free_sbv error path?
> + zpci_sbv = NULL;
> + return -ENOMEM;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260819-s390_irq_domain_fixes-v1-0-826ff27b6e97@linux.ibm.com?part=6
next prev parent reply other threads:[~2026-08-19 9:02 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
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 [this message]
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=20260819090237.E61621F00A3A@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox