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: <87pnvhqe3k.fsf@concordia.ellerman.id.au>
Date:   Wed, 07 Nov 2018 23:14:23 +1100
From:   Michael Ellerman <mpe@...erman.id.au>
To:     frowand.list@...il.com, Rob Herring <robh+dt@...nel.org>,
        Pantelis Antoniou <pantelis.antoniou@...sulko.com>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        Alan Tull <atull@...nel.org>, Moritz Fischer <mdf@...nel.org>
Cc:     linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
        devicetree@...r.kernel.org, linux-fpga@...r.kernel.org
Subject: Re: [PATCH v6 03/18] of: overlay: add missing of_node_get() in __of_attach_node_sysfs

frowand.list@...il.com writes:

> From: Frank Rowand <frank.rowand@...y.com>
>
> There is a matching of_node_put() in __of_detach_node_sysfs()
>
> Remove misleading comment from function header comment for
> of_detach_node().
>
> This patch may result in memory leaks from code that directly calls
> the dynamic node add and delete functions directly instead of
> using changesets.
>
> Tested-by: Alan Tull <atull@...nel.org>
> Signed-off-by: Frank Rowand <frank.rowand@...y.com>

This seems sensible to me. I guess we could argue about whether the
sysfs code needs its own reference, but it certainly doesn't hurt that
it does, as long as it's handled symmetrically - which it is now.

Acked-by: Michael Ellerman <mpe@...erman.id.au> (powerpc)

> ---
>
> This patch should result in powerpc systems that dynamically
> allocate a node, then later deallocate the node to have a
> memory leak when the node is deallocated.
>
> The next patch in the series will fix the leak.

I think this should go in the changelog, it's useful information that we
don't want to lose track of once this is applied.

Either that or we actually squash the two patches together when applying
to avoid the bisection break.

cheers

>  drivers/of/dynamic.c | 3 ---
>  drivers/of/kobj.c    | 4 +++-
>  2 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
> index 12c3f9a15e94..146681540487 100644
> --- a/drivers/of/dynamic.c
> +++ b/drivers/of/dynamic.c
> @@ -272,9 +272,6 @@ void __of_detach_node(struct device_node *np)
>  
>  /**
>   * of_detach_node() - "Unplug" a node from the device tree.
> - *
> - * The caller must hold a reference to the node.  The memory associated with
> - * the node is not freed until its refcount goes to zero.
>   */
>  int of_detach_node(struct device_node *np)
>  {
> diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c
> index 7a0a18980b98..c72eef988041 100644
> --- a/drivers/of/kobj.c
> +++ b/drivers/of/kobj.c
> @@ -133,6 +133,9 @@ int __of_attach_node_sysfs(struct device_node *np)
>  	}
>  	if (!name)
>  		return -ENOMEM;
> +
> +	of_node_get(np);
> +
>  	rc = kobject_add(&np->kobj, parent, "%s", name);
>  	kfree(name);
>  	if (rc)
> @@ -159,6 +162,5 @@ void __of_detach_node_sysfs(struct device_node *np)
>  		kobject_del(&np->kobj);
>  	}
>  
> -	/* finally remove the kobj_init ref */
>  	of_node_put(np);
>  }
> -- 
> Frank Rowand <frank.rowand@...y.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ