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: <ZN9NPiOscOPXJom+@smile.fi.intel.com>
Date:   Fri, 18 Aug 2023 13:51:42 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     "Peng Fan (OSS)" <peng.fan@....nxp.com>
Cc:     robh+dt@...nel.org, krzysztof.kozlowski+dt@...aro.org,
        conor+dt@...nel.org, frowand.list@...il.com,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        isaacmanjarres@...gle.com, rmk+kernel@...linux.org.uk,
        hdegoede@...hat.com, ulf.hansson@...aro.org, rafael@...nel.org,
        Peng Fan <peng.fan@....com>
Subject: Re: [PATCH V2] of/platform: increase refcount of fwnode

On Fri, Aug 18, 2023 at 09:59:32AM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@....com>
> 
> commit 0f8e5651095b
> ("of/platform: Propagate firmware node by calling device_set_node()")
> use of_fwnode_handle to replace of_node_get, which introduces a side
> effect that the refcount is not increased. Then the out of tree
> jailhouse hypervisor enable/disable test will trigger kernel dump in
> of_overlay_remove, with the following sequence
> "
>    of_changeset_revert(&overlay_changeset);
>    of_changeset_destroy(&overlay_changeset);
>    of_overlay_remove(&overlay_id);
> "
> 
> So increase the refcount to avoid issues.

...

> This patch also release the refcount when releasing amba device to avoid
> refcount leakage.

> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -528,6 +528,7 @@ static void amba_device_release(struct device *dev)
>  {
>  	struct amba_device *d = to_amba_device(dev);
>  
> +	of_node_put(d->dev.of_node);
>  	if (d->res.parent)
>  		release_resource(&d->res);
>  	mutex_destroy(&d->periphid_lock);

As I said, this change should be in a separate patch with the correct Fixes tag.

> index 267d8c9a5612..d328bbb679c7 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -175,7 +175,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
>  	}
>  
>  	/* setup generic device info */
> -	device_set_node(&dev->dev, of_fwnode_handle(np));
> +	device_set_node(&dev->dev, of_fwnode_handle(of_node_get(np)));
>  	dev->dev.parent = parent ? : &platform_bus;
>  
>  	if (bus_id)
> @@ -273,7 +273,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
>  	dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
>  
>  	/* setup generic device info */
> -	device_set_node(&dev->dev, of_fwnode_handle(node));
> +	device_set_node(&dev->dev, of_fwnode_handle(of_node_get(node)));
>  	dev->dev.parent = parent ? : &platform_bus;
>  	dev->dev.platform_data = platform_data;
>  	if (bus_id)

Without AMBA changes,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
thank you for fixing this!

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ