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: <20231204174330.rjwxenuuxcimbzce@skbuf>
Date: Mon, 4 Dec 2023 19:43:30 +0200
From: Vladimir Oltean <olteanv@...il.com>
To: Daniel Danzberger <dd@...edd.com>
Cc: woojung.huh@...rochip.com, UNGLinuxDriver@...rochip.com,
	netdev@...r.kernel.org, Andrew Lunn <andrew@...n.ch>,
	Florian Fainelli <f.fainelli@...il.com>
Subject: Re: [PATCH] net: dsa: microchip: fix NULL pointer dereference on
 platform init

Hello Daniel,

On Mon, Dec 04, 2023 at 04:43:15PM +0100, Daniel Danzberger wrote:
> Fixes a NULL pointer access when registering a switch device that has
> not been defined via DTS.
> 
> This might happen when the switch is used on a platform like x86 that
> doesn't use DTS and instantiates devices in platform specific init code.
> 
> Signed-off-by: Daniel Danzberger <dd@...edd.com>
> ---
>  drivers/net/dsa/microchip/ksz_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 9545aed905f5..525e13d9e39c 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -1678,7 +1678,7 @@ static int ksz_check_device_id(struct ksz_device *dev)
>  	dt_chip_data = of_device_get_match_data(dev->dev);
>  
>  	/* Check for Device Tree and Chip ID */
> -	if (dt_chip_data->chip_id != dev->chip_id) {
> +	if (dt_chip_data && dt_chip_data->chip_id != dev->chip_id) {
>  		dev_err(dev->dev,
>  			"Device tree specifies chip %s but found %s, please fix it!\n",
>  			dt_chip_data->dev_name, dev->info->dev_name);
> -- 
> 2.39.2
> 
> 

Is this all that's necessary for instantiating the ksz driver through
ds->dev->platform_data? I suppose not, so can you post it all, please?

Looking at dsa_switch_probe() -> dsa_switch_parse(), it expects
ds->dev->platform_data to contain a struct dsa_chip_data. This is in
contrast with ksz_spi.c, ksz9477_i2c.c and ksz8863_smi.c, which expect
the dev->platform_data to have the struct ksz_platform_data type.
But struct ksz_platform_data does not contain struct dsa_chip_data as
first element.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ