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: <555d7fb6-091e-4c10-bfea-85898e644481@lunn.ch>
Date: Mon, 14 Jul 2025 20:39:04 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Alok Tiwari <alok.a.tiwari@...cle.com>
Cc: sayantan.nandy@...oha.com, lorenzo@...nel.org, andrew+netdev@...n.ch,
	davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
	pabeni@...hat.com, horms@...nel.org, netdev@...r.kernel.org,
	linux-mediatek@...ts.infradead.org,
	linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH net] net: airoha: fix potential use-after-free in
 airoha_npu_get()

On Mon, Jul 14, 2025 at 10:57:17AM -0700, Alok Tiwari wrote:
> np->name was being used after calling of_node_put(np), which
> releases the node and can lead to a use-after-free bug.
> Store the name in a local variable before releasing the
> node to avoid potential issues.

The description does not match the patch. You are not storing the
name, you are storing a pointer to the name.

> diff --git a/drivers/net/ethernet/airoha/airoha_npu.c b/drivers/net/ethernet/airoha/airoha_npu.c
> index 0e5b8c21b9aa8..30cd617232244 100644
> --- a/drivers/net/ethernet/airoha/airoha_npu.c
> +++ b/drivers/net/ethernet/airoha/airoha_npu.c
> @@ -400,11 +400,12 @@ struct airoha_npu *airoha_npu_get(struct device *dev, dma_addr_t *stats_addr)
>  	if (!np)
>  		return ERR_PTR(-ENODEV);
>  
> +	const char *np_name = np->name;
>  	pdev = of_find_device_by_node(np);
>  	of_node_put(np);
>  
>  	if (!pdev) {
> -		dev_err(dev, "cannot find device node %s\n", np->name);
> +		dev_err(dev, "cannot find device node %s\n", np_name);

What you don't describe in the commit message is why the pointer to
the name is valid. After the of_node_put(), the node could be freed,
and i would assume if the node has gone, the name has gone as well.

I think a better fix for this is to move the of_node_put(np) to later.

    Andrew

---
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ