From: sashiko-bot@kernel.org
To: "Herve Codina" <herve.codina@bootlin.com>
Cc: linux-gpio@vger.kernel.org, linux-cxl@vger.kernel.org,
linux-pci@vger.kernel.org
Subject: Re: [PATCH v13 08/10] PCI: of: Set fwnode device of newly created PCI device nodes
Date: Mon, 12 Oct 2026 14:44:48 +0000 [thread overview]
Message-ID: <sashiko-outbox-168281@kernel.org> (raw)
In-Reply-To: <20261012142826.159178-9-herve.codina@bootlin.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] base: TOCTOU data race and UAF on fwnode->dev access
--
commit dc94be607770b564614555ac56ea83f070fa3dd4
Author: Herve Codina <herve.codina@bootlin.com>
PCI: of: Set fwnode device of newly created PCI device nodes
Device-tree node can be created when CONFIG_PCI_DYNAMIC_OF_NODES. Those
nodes are created and filled based on PCI core information but the
fwnode device field is not set.
> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> index 29b63a9090ae3..8914bfa25dc11 100644
> --- a/drivers/pci/of.c
> +++ b/drivers/pci/of.c
> @@ -736,6 +736,7 @@ void of_pci_remove_node(struct pci_dev *pdev)
> if (!np || !of_node_check_flag(np, OF_DYNAMIC))
> return;
>
> + fw_devlink_set_device(&np->fwnode, NULL);
[Severity: High]
Does this locklessly clear the fwnode device while another traversal might be
reading it?
If a PCI device is concurrently removed while a driver is being bound to
another device on the same system, of_pci_remove_node() clears fwnode->dev
locklessly here.
Concurrently, __fw_devlink_pickup_dangling_consumers() in drivers/base/core.c
can traverse the fwnode tree and read it locklessly:
if (fwnode->dev && fwnode->dev->bus)
return;
Can this lead to a NULL pointer dereference if the compiler emits two loads
and the pointer is cleared in between?
Can this also cause a use-after-free if the pointer is read, then the device
is concurrently unregistered and freed before the bus field is accessed, as
no reference count is held during the lockless read?
> device_remove_of_node(&pdev->dev);
> of_changeset_revert(np->data);
> of_changeset_destroy(np->data);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012142826.159178-1-herve.codina@bootlin.com?part=8
next prev parent reply other threads:[~2026-10-12 14:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 14:28 [PATCH v13 00/10] lan966x pci device: Add support for SFPs, PCI part Herve Codina
2026-10-12 14:28 ` [PATCH v13 01/10] driver core: fw_devlink: Introduce fw_devlink_set_device() Herve Codina
2026-10-12 14:34 ` sashiko-bot
2026-10-12 14:28 ` [PATCH v13 02/10] drivers: core: Use fw_devlink_set_device() Herve Codina
2026-10-12 14:33 ` sashiko-bot
2026-10-12 14:28 ` [PATCH v13 03/10] pinctrl: cs42l43: " Herve Codina
2026-10-12 14:32 ` sashiko-bot
2026-10-12 14:28 ` [PATCH v13 04/10] cxl/test: Use device_set_node() Herve Codina
2026-10-12 14:34 ` sashiko-bot
2026-10-12 14:28 ` [PATCH v13 05/10] cxl/test: Use fw_devlink_set_device() Herve Codina
2026-10-12 14:32 ` sashiko-bot
2026-10-12 14:28 ` [PATCH v13 06/10] PCI: of: " Herve Codina
2026-10-12 14:36 ` sashiko-bot
2026-10-12 14:28 ` [PATCH v13 07/10] PCI: of: Clear fwnode->dev during root bridge node removal and error path Herve Codina
2026-10-12 14:37 ` sashiko-bot
2026-10-12 14:28 ` [PATCH v13 08/10] PCI: of: Set fwnode device of newly created PCI device nodes Herve Codina
2026-10-12 14:44 ` sashiko-bot [this message]
2026-10-12 15:18 ` Herve Codina
2026-10-12 14:28 ` [PATCH v13 09/10] PCI: of: Remove fwnode_dev_initialized() call for a PCI root bridge node Herve Codina
2026-10-12 14:42 ` sashiko-bot
2026-10-12 14:28 ` [PATCH v13 10/10] PCI: of: Avoid np->data usage for the node changeset Herve Codina
2026-10-12 14:42 ` sashiko-bot
2026-10-12 22:18 ` Bjorn Helgaas
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=sashiko-outbox-168281@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=herve.codina@bootlin.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-pci@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.