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] [day] [month] [year] [list]
Message-ID: <Zs3FPsfjnO5+6QcT@duo.ucw.cz>
Date: Tue, 27 Aug 2024 14:23:26 +0200
From: Pavel Machek <pavel@...x.de>
To: Sasha Levin <sashal@...nel.org>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
	Aleksandr Mishin <amishin@...rgos.ru>,
	Bjorn Helgaas <helgaas@...nel.org>,
	Krzysztof WilczyƄski <kwilczynski@...nel.org>,
	Bjorn Helgaas <bhelgaas@...gle.com>, jonnyc@...zon.com,
	lpieralisi@...nel.org, kw@...ux.com, linux-pci@...r.kernel.org
Subject: Re: [PATCH AUTOSEL 5.15 25/47] PCI: al: Check IORESOURCE_BUS
 existence during probe

Hi!

> [ Upstream commit a9927c2cac6e9831361e43a14d91277818154e6a ]
> 
> If IORESOURCE_BUS is not provided in Device Tree it will be fabricated in
> of_pci_parse_bus_range(), so NULL pointer dereference should not happen
> here.
> 
> But that's hard to verify, so check for NULL anyway.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.

If the NULL can't happen, we should not really apply this to -stable.

Best regards,
								Pavel
								
> +++ b/drivers/pci/controller/dwc/pcie-al.c
> @@ -242,18 +242,24 @@ static struct pci_ops al_child_pci_ops = {
>  	.write = pci_generic_config_write,
>  };
>  
> -static void al_pcie_config_prepare(struct al_pcie *pcie)
> +static int al_pcie_config_prepare(struct al_pcie *pcie)
>  {
>  	struct al_pcie_target_bus_cfg *target_bus_cfg;
>  	struct pcie_port *pp = &pcie->pci->pp;
>  	unsigned int ecam_bus_mask;
> +	struct resource_entry *ft;
>  	u32 cfg_control_offset;
> +	struct resource *bus;
>  	u8 subordinate_bus;
>  	u8 secondary_bus;
>  	u32 cfg_control;
>  	u32 reg;
> -	struct resource *bus = resource_list_first_type(&pp->bridge->windows, IORESOURCE_BUS)->res;
>  
> +	ft = resource_list_first_type(&pp->bridge->windows, IORESOURCE_BUS);
> +	if (!ft)
> +		return -ENODEV;
> +
> +	bus = ft->res;
>  	target_bus_cfg = &pcie->target_bus_cfg;
>  
>  	ecam_bus_mask = (pcie->ecam_size >> PCIE_ECAM_BUS_SHIFT) - 1;
> @@ -287,6 +293,8 @@ static void al_pcie_config_prepare(struct al_pcie *pcie)
>  	       FIELD_PREP(CFG_CONTROL_SEC_BUS_MASK, secondary_bus);
>  
>  	al_pcie_controller_writel(pcie, cfg_control_offset, reg);
> +
> +	return 0;
>  }
>  
>  static int al_pcie_host_init(struct pcie_port *pp)
> @@ -305,7 +313,9 @@ static int al_pcie_host_init(struct pcie_port *pp)
>  	if (rc)
>  		return rc;
>  
> -	al_pcie_config_prepare(pcie);
> +	rc = al_pcie_config_prepare(pcie);
> +	if (rc)
> +		return rc;
>  
>  	return 0;
>  }

-- 
DENX Software Engineering GmbH,        Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ