mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Hans Zhang <18255117159@163.com>
Cc: bhelgaas@google.com, lpieralisi@kernel.org,
	kwilczynski@kernel.org, mani@kernel.org, robh@kernel.org,
	a-garg7@ti.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/9] PCI: controller: Add missing rescan lock around root bus removal
Date: Mon, 22 Jun 2026 12:12:59 -0500	[thread overview]
Message-ID: <20260622171259.GA677910@bhelgaas> (raw)
In-Reply-To: <f6a9a0f9-b331-48d8-be86-64471b9ea4fb@163.com>

On Fri, Jun 19, 2026 at 11:20:33PM +0800, Hans Zhang wrote:
> On 6/19/26 00:59, Bjorn Helgaas wrote:
> > On Fri, May 22, 2026 at 12:18:13AM +0800, Hans Zhang wrote:
> > > Several PCIe host controller drivers call pci_stop_root_bus() and
> > > pci_remove_root_bus() without holding the global PCI rescan lock
> > > (pci_rescan_remove_global_lock). This can cause race conditions with
> > > concurrent PCI rescan or hotplug operations triggered via sysfs,
> > > potentially leading to use-after-free or system crashes.
> ...

> > Thanks for this work.  I amended the commit logs of the eight applied
> > patches so they're all the same (since all the patches do exactly the
> > same thing) and so they all mention the reason for the change.
> > 
> > There are only four callers of pci_stop_root_bus() and
> > pci_remove_root_bus() that would not be able to use a trivial helper
> > function that does the lock/stop/remove/unlock internally:
> > 
> >    zpci_bus_release
> >    acpi_pci_root_remove
> >    hv_pci_remove
> >    vmd_remove
> > 
> > It would be nice to analyze those to see if they could use the same
> > pattern, which could be done inside a helper function that would avoid
> > the possibility of adding the same bug elsewhere.
> 
> Thank you for reviewing the series and for the constructive suggestion
> regarding the common helper function.
> 
> I fully agree that introducing a helper (e.g., pci_remove_root_bus_safe())
> to encapsulate the lock/unlock logic is a cleaner and more maintainable
> approach, and it would help prevent similar issues in the future.
> 
> Since we are now in the merge window, I would prefer to hold off on this
> further refactoring until the next cycle to avoid introducing any
> unnecessary risks or conflicts at this late stage.

Definitely.  This series is already merged, so this is just potential
future work.  I'm not sure I would even add such a helper unless those
last four cases (zpci, acpi, etc) could also use it.  Having two
patterns would be only a marginal benefit.

      reply	other threads:[~2026-06-22 17:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21 16:18 Hans Zhang
2026-05-21 16:18 ` [PATCH 1/9] PCI: cadence: Protect root bus removal with rescan lock Hans Zhang
2026-05-21 16:18 ` [PATCH 2/9] PCI: dwc: " Hans Zhang
2026-05-21 16:18 ` [PATCH 3/9] PCI: altera: " Hans Zhang
2026-05-21 16:18 ` [PATCH 4/9] PCI: brcmstb: " Hans Zhang
2026-05-21 16:18 ` [PATCH 5/9] PCI: iproc: " Hans Zhang
2026-05-21 16:18 ` [PATCH 6/9] PCI: mediatek: " Hans Zhang
2026-05-21 16:18 ` [PATCH 7/9] PCI: rockchip: " Hans Zhang
2026-05-21 16:18 ` [PATCH 8/9] PCI: vmd: " Hans Zhang
2026-05-21 16:18 ` [PATCH 9/9] PCI: plda: " Hans Zhang
2026-06-11  7:04 ` (subset) [PATCH 0/9] PCI: controller: Add missing rescan lock around root bus removal Manivannan Sadhasivam
2026-06-18 16:59 ` Bjorn Helgaas
2026-06-19 15:20   ` Hans Zhang
2026-06-22 17:12     ` Bjorn Helgaas [this message]

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=20260622171259.GA677910@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=18255117159@163.com \
    --cc=a-garg7@ti.com \
    --cc=bhelgaas@google.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=robh@kernel.org \
    /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

all inboxes | Powered by JetHome®