From: Lukas Wunner <lukas@wunner.de>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: "Marco Nenciarini" <mnencia@kcore.it>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Michał Winiarski" <michal.winiarski@intel.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Eric Chanudet" <echanude@redhat.com>,
"Alex Williamson" <alex@shazbot.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] PCI/IOV: Fix out-of-bounds access in sriov_restore_vf_rebar_state()
Date: Fri, 17 Apr 2026 06:57:21 +0200 [thread overview]
Message-ID: <aeG9sQNwQPSlBCY-@wunner.de> (raw)
In-Reply-To: <20260416225745.GA41850@bhelgaas>
On Thu, Apr 16, 2026 at 05:57:45PM -0500, Bjorn Helgaas wrote:
> And we have this weird retry loop in pci_restore_config_dword():
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/pci/pci.c?id=v7.0#n1766,
> which was originally added by
> https://git.kernel.org/linus/26f41062f28d ("PCI: check for pci bar
> restore completion and retry") to fix an actual problem:
>
> On some OEM systems, pci_restore_state() is called while FLR has not
> yet completed. As a result, PCI BAR register restore is not
> successful. This fix reads back the restored value and compares it
> with saved value and re-tries 10 times before giving up.
>
> This just gives me the heebie-jeebies. If we still need this retry
> loop, it means all the previous state restoration (PCIe, LTR, ASPM,
> IOV, PRI, ATS, DPC, etc.) probably failed, and we end up with a device
> where the BARs got restored but none of the previous stuff. That
> sounds like a mess.
Nowadays we wait for devices to re-appear after reset by polling the
Vendor ID register, see the call to pci_dev_wait() in pcie_flr().
It seems we didn't do that back in the day when 26f41062f28d introduced
the loop. The commit went into v3.4 and back then, pcie_flr() only
waited for 100 msec:
https://elixir.bootlin.com/linux/v3.4/source/drivers/pci/pci.c#L3052
And indeed pci_reset_function() immediately restored config space
afterwards:
https://elixir.bootlin.com/linux/v3.4/source/drivers/pci/pci.c#L3285
So I strongly suspect that the loop no longer has a valid raison d'être.
Maybe remove it early in the next cycle to get linux-next coverage for
8 weeks and see if anything breaks (which I doubt)?
As to validity of cached config space state in general, see this
discussion with Ilpo yesterday, in response to a regression fix
I submitted:
https://lore.kernel.org/all/aeDXktnNLEtmYsbh@wunner.de/
Thanks,
Lukas
next prev parent reply other threads:[~2026-04-17 5:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 16:39 [PATCH] PCI/IOV: Fix out-of-bounds access in sriov_restore_vf_rebar_state() Marco Nenciarini
2026-04-14 13:34 ` Michał Winiarski
2026-04-16 22:42 ` Bjorn Helgaas
2026-04-16 22:57 ` Bjorn Helgaas
2026-04-17 4:57 ` Lukas Wunner [this message]
2026-04-17 13:24 ` [PATCH v2 0/2] PCI: Guard Resizable BAR restore against unreachable devices Marco Nenciarini
2026-04-17 13:24 ` [PATCH v2 1/2] PCI: Skip Resizable BAR restore on read error Marco Nenciarini
2026-04-17 13:24 ` [PATCH v2 2/2] PCI/IOV: Skip VF " Marco Nenciarini
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=aeG9sQNwQPSlBCY-@wunner.de \
--to=lukas@wunner.de \
--cc=alex@shazbot.org \
--cc=bhelgaas@google.com \
--cc=echanude@redhat.com \
--cc=helgaas@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=michal.winiarski@intel.com \
--cc=mnencia@kcore.it \
--cc=rafael@kernel.org \
--cc=stable@vger.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