Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Herve Codina <herve.codina@bootlin.com>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev, 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 17:18:11 +0200	[thread overview]
Message-ID: <20261012171811.50f6cb9f@bootlin.com> (raw)
In-Reply-To: <sashiko-outbox-168281@kernel.org>

On Mon, 12 Oct 2026 14:44:48 +0000
sashiko-bot@kernel.org wrote:

> 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;

I don't think so.

__fw_devlink_pickup_dangling_consumers() can look at fwnode->dev but those
fwnode->dev are not in the same branch in the tree as the one where the fwnode
being modified is located.

I don't see any cases where __fw_devlink_pickup_dangling_consumers() can
reach our fwnode.

In other word I don't see any race condition on my side and so I will not try
to fix that point except if this "potential" issue is confirmed by other people.
Indeed, I could be wrong in my analysis but without further details, I don't
think the issue reported here can happen.

Best regards,
Hervé

  reply	other threads:[~2026-10-12 15:18 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
2026-10-12 15:18     ` Herve Codina [this message]
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=20261012171811.50f6cb9f@bootlin.com \
    --to=herve.codina@bootlin.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-bot@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox