From: sashiko-bot@kernel.org
To: "Pavol Sakac" <sakacpav@amazon.de>
Cc: linux-pci@vger.kernel.org
Subject: Re: [RFC PATCH 5/8] powerpc/pci: Serialize pcibios_bus_add_device()
Date: Fri, 11 Sep 2026 12:55:05 +0000 [thread overview]
Message-ID: <20260911125505.8F1AB1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911123147.97312-1-sakacpav@amazon.de>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Potential NULL pointer dereference of `pdn` in `pseries_pcibios_bus_add_device`.
- [High] Potential NULL pointer dereference of the physical function's EEH device (`edev`) in `pseries_pcibios_bus_add_device`.
--
commit 7133056da4f8622a96d7696deea5dac9e5c2eeb4
Author: Pavol Sakac <sakacpav@amazon.de>
powerpc/pci: Serialize pcibios_bus_add_device()
This commit serializes the pcibios_bus_add_device platform hook dispatch
with an arch-local mutex to prevent race conditions during concurrent sibling
VF additions. This addresses unlocked list manipulations in the EEH PE tree.
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index 4fc52c21fe5d4..21cccd0e97f8b 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
[ ... ]
> @@ -1068,8 +1077,11 @@ void pcibios_bus_add_device(struct pci_dev *dev)
> if (ppc_md.pci_irq_fixup)
> ppc_md.pci_irq_fixup(dev);
>
> - if (ppc_md.pcibios_bus_add_device)
> + if (ppc_md.pcibios_bus_add_device) {
> + mutex_lock(&pcibios_bus_add_device_lock);
> ppc_md.pcibios_bus_add_device(dev);
[Severity: High]
This isn't a bug introduced by this patch, but can this hook lead to a NULL
pointer dereference if pdn allocation fails?
If add_sriov_vf_pdns() fails (for example, due to memory pressure), it
returns NULL instead of propagating an error. The PCI core proceeds to
instantiate the Virtual Functions and calls this platform hook.
In arch/powerpc/platforms/pseries/eeh_pseries.c:pseries_pcibios_bus_add_device():
pdn = pci_get_pdn(pdev);
pdn->device_id = pdev->device;
Could a privileged user trigger a kernel panic by enabling SR-IOV under
memory pressure, turning a recoverable failure into a DoS?
[Severity: High]
This is also a pre-existing issue, but could this hook dereference a NULL
pointer if the physical function lacks an initialized EEH device?
When adding a Virtual Function, pseries_pcibios_bus_add_device() assumes
the physical function's EEH device pointer is valid:
In arch/powerpc/platforms/pseries/eeh_pseries.c:pseries_pcibios_bus_add_device():
struct eeh_pe *physfn_pe = pci_dev_to_eeh_dev(pdev->physfn)->pe;
If EEH initialization failed for the physical function (for instance, if the
device is not part of a PE or firmware didn't support EEH), its EEH device
pointer remains NULL.
Would writing to the sriov_numvfs sysfs file on such a physical function
cause an unconditional dereference of the NULL edev pointer here?
> + mutex_unlock(&pcibios_bus_add_device_lock);
> + }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911-vfopt-s1-v1-0-693271dc0226@amazon.de?part=5
next prev parent reply other threads:[~2026-09-11 12:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 12:11 [RFC PATCH 0/8] PCI/IOV: Initialize virtual functions in parallel Pavol Sakac
2026-09-11 12:28 ` [RFC PATCH 1/8] PCI/IOV: Split virtfn bus handling out of pci_iov_add_virtfn() Pavol Sakac
2026-09-11 12:45 ` sashiko-bot
2026-09-11 12:29 ` [RFC PATCH 2/8] PCI/IOV: Create virtfn buses up front in sriov_add_vfs() Pavol Sakac
2026-09-11 12:46 ` sashiko-bot
2026-09-11 12:29 ` [RFC PATCH 3/8] PCI/PM: Convert pci_bridge_d3_update() recursion to iteration Pavol Sakac
2026-09-11 12:40 ` sashiko-bot
2026-09-11 12:30 ` [RFC PATCH 4/8] PCI/PM: Serialize pci_bridge_d3_update() Pavol Sakac
2026-09-11 12:47 ` sashiko-bot
2026-09-11 12:31 ` [RFC PATCH 5/8] powerpc/pci: Serialize pcibios_bus_add_device() Pavol Sakac
2026-09-11 12:55 ` sashiko-bot [this message]
2026-09-11 12:32 ` [RFC PATCH 6/8] PCI/IOV: Let sriov_add_vfs() own the failure unwind Pavol Sakac
2026-09-11 12:52 ` sashiko-bot
2026-09-11 12:33 ` [RFC PATCH 7/8] PCI/IOV: Initialize virtual functions in parallel Pavol Sakac
2026-09-11 12:43 ` sashiko-bot
2026-09-11 12:34 ` [RFC PATCH 8/8] PCI: Probe inline from node-local workqueue workers Pavol Sakac
2026-09-11 12:40 ` sashiko-bot
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=20260911125505.8F1AB1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sakacpav@amazon.de \
--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