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: <CO1PR11MB5204FD6B12B682AAFB5B813F8B972@CO1PR11MB5204.namprd11.prod.outlook.com>
Date: Fri, 30 Aug 2024 04:48:26 +0000
From: "Ma, Hao" <hao.ma@...el.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, Mark Brown
	<broonie@...nel.org>, Linus Walleij <linus.walleij@...aro.org>,
	"linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, "linux-spi@...r.kernel.org"
	<linux-spi@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
CC: Daniel Mack <daniel@...que.org>, Haojian Zhuang
	<haojian.zhuang@...il.com>, Robert Jarzmik <robert.jarzmik@...e.fr>, "Li,
 Lili" <lili.li@...el.com>
Subject: RE: [PATCH v1 1/2] spi: pxa2xx: Do not override dev->platform_data on
 probe

Hi,Andriy,

I merged following patches and tested it works.

      [PATCH v1 1/2] spi: pxa2xx: Do not override dev->platform_data on probe
      [PATCH v1 2/2] spi: pxa2xx: Move PM runtime handling to the glue drivers


Tested-by: Hao Ma <hao.ma@...el.com >



Best Regards!
==========================================

> -----Original Message-----
> From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Sent: Thursday, August 22, 2024 7:31 PM
> To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>; Mark Brown <broonie@...nel.org>; Linus Walleij <linus.walleij@...aro.org>;
> linux-arm-kernel@...ts.infradead.org; linux-spi@...r.kernel.org; linux-kernel@...r.kernel.org
> Cc: Daniel Mack <daniel@...que.org>; Haojian Zhuang <haojian.zhuang@...il.com>; Robert Jarzmik <robert.jarzmik@...e.fr>; Ma, Hao
> <hao.ma@...el.com>
> Subject: [PATCH v1 1/2] spi: pxa2xx: Do not override dev->platform_data on probe
> 
> The platform_data field may be supplied by legacy board code.
> In other cases we override it, and module remove and probe cycle will crash the kernel since it will carry a stale pointer.
> 
> Fix this by supplying a third argument to the pxa2xx_spi_probe() and avoid overriding dev->platform_data.
> 
> Reported-by: Hao Ma <hao.ma@...el.com>
> Fixes: cc160697a576 ("spi: pxa2xx: Convert PCI driver to use spi-pxa2xx code directly")
> Fixes: 3d8f037fbcab ("spi: pxa2xx: Move platform driver to a separate file")
> Fixes: 20ade9b9771c ("spi: pxa2xx: Extract pxa2xx_spi_platform_*() callbacks")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
>  drivers/spi/spi-pxa2xx-pci.c      | 2 +-
>  drivers/spi/spi-pxa2xx-platform.c | 6 ++----
>  drivers/spi/spi-pxa2xx.c          | 5 ++---
>  drivers/spi/spi-pxa2xx.h          | 3 ++-
>  4 files changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index 616d032f1a89..c98bb214b6ae 100644
> --- a/drivers/spi/spi-pxa2xx-pci.c
> +++ b/drivers/spi/spi-pxa2xx-pci.c
> @@ -297,7 +297,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
>  		return ret;
>  	ssp->irq = pci_irq_vector(dev, 0);
> 
> -	return pxa2xx_spi_probe(&dev->dev, ssp);
> +	return pxa2xx_spi_probe(&dev->dev, ssp, pdata);
>  }
> 
>  static void pxa2xx_spi_pci_remove(struct pci_dev *dev) diff --git a/drivers/spi/spi-pxa2xx-platform.c b/drivers/spi/spi-pxa2xx-platform.c
> index 98a8ceb7db6f..f9504cddc7ba 100644
> --- a/drivers/spi/spi-pxa2xx-platform.c
> +++ b/drivers/spi/spi-pxa2xx-platform.c
> @@ -63,7 +63,7 @@ static struct ssp_device *pxa2xx_spi_ssp_request(struct platform_device *pdev)
> 
>  	ssp = pxa_ssp_request(pdev->id, pdev->name);
>  	if (!ssp)
> -		return ssp;
> +		return NULL;
> 
>  	status = devm_add_action_or_reset(&pdev->dev, pxa2xx_spi_ssp_release, ssp);
>  	if (status)
> @@ -148,8 +148,6 @@ static int pxa2xx_spi_platform_probe(struct platform_device *pdev)
>  		platform_info = pxa2xx_spi_init_pdata(pdev);
>  		if (IS_ERR(platform_info))
>  			return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n");
> -
> -		dev->platform_data = platform_info;
>  	}
> 
>  	ssp = pxa2xx_spi_ssp_request(pdev);
> @@ -158,7 +156,7 @@ static int pxa2xx_spi_platform_probe(struct platform_device *pdev)
>  	if (!ssp)
>  		ssp = &platform_info->ssp;
> 
> -	return pxa2xx_spi_probe(dev, ssp);
> +	return pxa2xx_spi_probe(dev, ssp, platform_info);
>  }
> 
>  static void pxa2xx_spi_platform_remove(struct platform_device *pdev) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index
> 16b96eb176cd..e3a95adc5279 100644
> --- a/drivers/spi/spi-pxa2xx.c
> +++ b/drivers/spi/spi-pxa2xx.c
> @@ -1277,16 +1277,15 @@ static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi)
>  	return MAX_DMA_LEN;
>  }
> 
> -int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp)
> +int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp,
> +		     struct pxa2xx_spi_controller *platform_info)
>  {
> -	struct pxa2xx_spi_controller *platform_info;
>  	struct spi_controller *controller;
>  	struct driver_data *drv_data;
>  	const struct lpss_config *config;
>  	int status;
>  	u32 tmp;
> 
> -	platform_info = dev_get_platdata(dev);
>  	if (platform_info->is_target)
>  		controller = devm_spi_alloc_target(dev, sizeof(*drv_data));
>  	else
> diff --git a/drivers/spi/spi-pxa2xx.h b/drivers/spi/spi-pxa2xx.h index a470d3d634d3..447be0369384 100644
> --- a/drivers/spi/spi-pxa2xx.h
> +++ b/drivers/spi/spi-pxa2xx.h
> @@ -132,7 +132,8 @@ extern void pxa2xx_spi_dma_stop(struct driver_data *drv_data);  extern int pxa2xx_spi_dma_setup(struct
> driver_data *drv_data);  extern void pxa2xx_spi_dma_release(struct driver_data *drv_data);
> 
> -int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp);
> +int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp,
> +		     struct pxa2xx_spi_controller *platform_info);
>  void pxa2xx_spi_remove(struct device *dev);
> 
>  extern const struct dev_pm_ops pxa2xx_spi_pm_ops;
> --
> 2.43.0.rc1.1336.g36b5255a03ac


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ