From: sashiko-bot@kernel.org
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev()
Date: Thu, 16 Jul 2026 14:18:43 +0000 [thread overview]
Message-ID: <20260716141844.4A3171F000E9@smtp.kernel.org> (raw)
In-Reply-To: <3430928.44csPzL39Z@rafael.j.wysocki>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-after-free in acpi_get_pci_dev() due to unpinned acpi_device pointer
--
--- Patch [2]: [PATCH v2 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev() ---
commit 96691f509a95b92252e42efea5c07ebf2acebfd2
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
ACPI: PCI: Introduce acpi_dev_get_pci_dev()
Some acpi_get_pci_dev() callers already have a struct ACPI device for
which they want to get the struct pci_dev pointer of the associated
PCI device. Add acpi_dev_get_pci_dev() to handle this and turn
acpi_get_pci_dev() into a static inline helper.
> diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
> index 402b97d121381..bff2ca035fcf3 100644
> --- a/include/acpi/acpi_drivers.h
> +++ b/include/acpi/acpi_drivers.h
> @@ -59,14 +59,19 @@ int acpi_pci_link_free_irq(acpi_handle handle);
[ ... ]
> +static inline struct pci_dev *acpi_get_pci_dev(acpi_handle handle)
> +{
> + return acpi_dev_get_pci_dev(acpi_fetch_acpi_dev(handle));
> +}
[Severity: High]
This is a pre-existing issue, but does this inline function expose a
race condition with ACPI hot-remove?
acpi_fetch_acpi_dev() returns an unpinned acpi_device pointer without
incrementing its reference count. If a concurrent ACPI hot-remove event
occurs immediately after the lookup, the device object could be destroyed
and freed by the hotplug workqueue.
When the dangling pointer is passed into acpi_dev_get_pci_dev(), it
gets dereferenced here in drivers/acpi/pci_root.c:
acpi_dev_get_pci_dev() {
...
guard(mutex)(&adev->physical_node_lock);
Could this be prevented by using acpi_get_acpi_dev() to acquire a reference
before calling acpi_dev_get_pci_dev(), and then releasing it with
acpi_dev_put()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/12935400.O9o76ZdvQC@rafael.j.wysocki?part=2
next prev parent reply other threads:[~2026-07-16 14:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 13:59 [PATCH v2 0/4] ACPI: Add and use acpi_dev_get_pci_dev() Rafael J. Wysocki
2026-07-16 14:04 ` [PATCH v2 1/4] ACPI: PCI: Use a mutex guard to simplify acpi_get_pci_dev() Rafael J. Wysocki
2026-07-16 14:08 ` sashiko-bot
2026-07-16 18:02 ` Andy Shevchenko
2026-07-20 10:21 ` Ilpo Järvinen
2026-07-16 14:04 ` [PATCH v2 2/4] ACPI: PCI: Introduce acpi_dev_get_pci_dev() Rafael J. Wysocki
2026-07-16 14:18 ` sashiko-bot [this message]
2026-07-16 16:40 ` Rafael J. Wysocki (Intel)
2026-07-16 18:36 ` Andy Shevchenko
2026-07-16 14:05 ` [PATCH v2 3/4] ACPI: video: Drop backlight parent device reference later Rafael J. Wysocki
2026-07-16 14:12 ` sashiko-bot
2026-07-16 14:05 ` [PATCH v2 4/4] ACPI: video: Use acpi_dev_get_pci_dev() instead of acpi_get_pci_dev() Rafael J. Wysocki
2026-07-16 14:28 ` 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=20260716141844.4A3171F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rafael@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.