Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tobias Schumacher" <ts@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH v2 5/7] s390/pci: Add error cleanup in zpci_directed_irq_init
Date: Mon, 05 Oct 2026 12:16:23 +0000	[thread overview]
Message-ID: <20261005121624.3B38B1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261005-s390_irq_domain_fixes-v2-5-d45b824874c0@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] s390/pci: hardware use-after-free via dangling DMA pointer on init failure
- [Low] mm: unnecessary complex error handling for __init memory allocation
--

commit 3f6f1514864f283bcc9b6097b32ff020d51e4124
Author: Tobias Schumacher <ts@linux.ibm.com>

s390/pci: Add error cleanup in zpci_directed_irq_init

If per-CPU airq_iv allocation fails in the loop, previously allocated
vectors and arrays leak. Add proper error path to release all resources
on failure.

> diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
> index 81a27bf756a3a..682bceb6525e2 100644
> --- a/arch/s390/pci/pci_irq.c
> +++ b/arch/s390/pci/pci_irq.c

[ ... ]

> @@ -576,7 +576,7 @@ static int __init zpci_directed_irq_init(void)
>  
>  	zpci_dibv = kzalloc_objs(*zpci_dibv, num_possible_cpus());
>  	if (!zpci_dibv)
> -		return -ENOMEM;
> +		goto out_free_sbv;
>  
>  	for_each_possible_cpu(cpu) {
>  		/*
> @@ -589,13 +589,25 @@ static int __init zpci_directed_irq_init(void)
>  						AIRQ_IV_CACHELINE |
>  						(!cpu ? AIRQ_IV_ALLOC : 0), NULL);
>  		if (!zpci_dibv[cpu])
> -			return -ENOMEM;
> +			goto out_free_dibv;
>  	}
>  	on_each_cpu(cpu_enable_directed_irq, NULL, 1);
>  
>  	zpci_irq_chip.irq_set_affinity = zpci_set_irq_affinity;
>  
>  	return 0;
> +
> +out_free_dibv:
> +	for_each_possible_cpu(cpu) {
> +		if (zpci_dibv[cpu])
> +			airq_iv_release(zpci_dibv[cpu]);
> +	}
> +	kfree(zpci_dibv);
> +	zpci_dibv = NULL;

[Severity: Low]
Since zpci_directed_irq_init() is an __init function, is this complex error
handling for early boot memory allocation failures necessary?

Functions executed only early in the boot process generally do not need to
handle memory allocation failures gracefully, as physical memory should be
available and a failure typically means the system cannot boot anyway. This
could be unnecessary dead code.

> +out_free_sbv:
> +	airq_iv_release(zpci_sbv);
> +	zpci_sbv = NULL;
> +	return -ENOMEM;

[Severity: High]
Does this error path leave a dangling physical memory address programmed into
the hardware?

Earlier in zpci_directed_irq_init(), the hardware is programmed to use the
physical address of zpci_sbv->vector:

	iib.diib.disb_addr = virt_to_phys(zpci_sbv->vector);
	zpci_set_irq_ctrl(SIC_IRQ_MODE_DIRECT, 0, &iib);

If a subsequent allocation fails and we take this out_free_sbv path, zpci_sbv
is freed without unregistering the address from the hardware. Could a
subsequent spurious adapter interrupt cause the hardware to write to the freed
memory and corrupt it?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261005-s390_irq_domain_fixes-v2-0-d45b824874c0@linux.ibm.com?part=5

  reply	other threads:[~2026-10-05 12:16 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05 12:03 [PATCH v2 0/7] s390/pci: Fix bugs in IRQ domain migration and resource cleanup Tobias Schumacher
2026-10-05 12:03 ` [PATCH v2 1/7] s390/pci: Fix double-free and NULL deref in zpci MSI domain cleanup Tobias Schumacher
2026-10-05 12:12   ` sashiko-bot
2026-10-06  9:42   ` Niklas Schnelle
2026-10-05 12:03 ` [PATCH v2 2/7] s390/pci: Fix resource leak in zpci MSI setup Tobias Schumacher
2026-10-05 12:17   ` sashiko-bot
2026-10-06  9:55   ` Niklas Schnelle
2026-10-05 12:03 ` [PATCH v2 3/7] s390/pci: Fix MSI directed-mode teardown IRQ bit count Tobias Schumacher
2026-10-05 12:15   ` sashiko-bot
2026-10-06 11:10   ` Niklas Schnelle
2026-10-05 12:03 ` [PATCH v2 4/7] s390/pci: Fix use-after-free race in zpci floating interrupt cleanup Tobias Schumacher
2026-10-05 12:14   ` sashiko-bot
2026-10-06 15:18   ` Niklas Schnelle
2026-10-07  5:50     ` Tobias Schumacher
2026-10-06 19:23   ` Niklas Schnelle
2026-10-07  6:02     ` Tobias Schumacher
2026-10-05 12:03 ` [PATCH v2 5/7] s390/pci: Add error cleanup in zpci_directed_irq_init Tobias Schumacher
2026-10-05 12:16   ` sashiko-bot [this message]
2026-10-06 13:32   ` Niklas Schnelle
2026-10-07  6:04     ` Tobias Schumacher
2026-10-06 19:19   ` Niklas Schnelle
2026-10-07  6:10     ` Tobias Schumacher
2026-10-05 12:03 ` [PATCH v2 6/7] s390/pci: Set MSI_FLAG_NO_AFFINITY at IRQ init time Tobias Schumacher
2026-10-05 12:08   ` sashiko-bot
2026-10-06 15:33   ` Niklas Schnelle
2026-10-05 12:03 ` [PATCH v2 7/7] s390/pci: Drop the unused index argument of zpci_msi_clear_airq() Tobias Schumacher
2026-10-05 12:08   ` sashiko-bot
2026-10-06 15:28   ` 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=20261005121624.3B38B1F000FF@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