lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0292a3331a61a77fb05d44ba6d298baaf8a7265a.camel@redhat.com>
Date: Tue, 18 Mar 2025 13:21:13 +0100
From: Philipp Stanner <pstanner@...hat.com>
To: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,  Bjorn
 Helgaas <bhelgaas@...gle.com>, Alex Williamson
 <alex.williamson@...hat.com>, Christian König
 <christian.koenig@....com>, linux-pci@...r.kernel.org, 
 linux-kernel@...r.kernel.org
Cc: Michał Winiarski <michal.winiarski@...el.com>
Subject: Re: [PATCH v2 1/1] PCI: Fix BAR resizing when VF BARs are assigned

On Fri, 2025-03-07 at 16:03 +0200, Ilpo Järvinen wrote:
> __resource_resize_store() attempts to release all resources of the
> device before attempting the resize. The loop, however, only covers
> standard BARs (< PCI_STD_NUM_BARS). If a device has VF BARs that are
> assigned, pci_reassign_bridge_resources() finds the bridge window
> still
> has some assigned child resources and returns -NOENT which makes
> pci_resize_resource() to detect an error and abort the resize.
> 
> Change the release loop to cover all resources up to VF BARs which
> allows the resize operation to release the bridge windows and attempt
> to assigned them again with the different size.
> 
> As __resource_resize_store() checks first that no driver is bound to
> the PCI device before resizing is allowed, SR-IOV cannot be enabled
> during resize so it is safe to release also the IOV resources.
> 
> Fixes: 91fa127794ac ("PCI: Expose PCIe Resizable BAR support via
> sysfs")
> Reported-by: Michał Winiarski <michal.winiarski@...el.com>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> ---
> 
> v2:
> - Removed language about expansion ROMs
> 
>  drivers/pci/pci-sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index b46ce1a2c554..0c16751bab40 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -1578,7 +1578,7 @@ static ssize_t __resource_resize_store(struct
> device *dev, int n,
>  
>  	pci_remove_resource_files(pdev);
>  
> -	for (i = 0; i < PCI_STD_NUM_BARS; i++) {
> +	for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) {

I, just recently, fixed a similar bug (assuming it is one in this
particular case here) [1].

I think it would be great if someone who has the knowledge could
improve the documentation in linux/pci.h where those constants are
defined.

PCI_STD_NUM_BARS is even defined in a different header, hinting at a
different background.


P.

[1] https://lore.kernel.org/all/20250312080634.13731-2-phasta@kernel.org/


>  		if (pci_resource_len(pdev, i) &&
>  		    pci_resource_flags(pdev, i) == flags)
>  			pci_release_resource(pdev, i);
> 
> base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ