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: <20140815104507.E6F84C40A89@trevor.secretlab.ca>
Date:	Fri, 15 Aug 2014 11:45:07 +0100
From:	Grant Likely <grant.likely@...aro.org>
To:	Stephen Boyd <sboyd@...eaurora.org>,
	Stepan Moskovchenko <stepanm@...eaurora.org>
Cc:	robh+dt@...nel.org, devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH] of: Deep-copy names of platform devices

On Tue, 12 Aug 2014 18:46:36 -0700, Stephen Boyd <sboyd@...eaurora.org> wrote:
> On 08/12/14 17:57, Stepan Moskovchenko wrote:
> > diff --git a/drivers/of/device.c b/drivers/of/device.c
> > index f685e55..3e116f6 100644
> > --- a/drivers/of/device.c
> > +++ b/drivers/of/device.c
> > @@ -54,7 +54,7 @@ int of_device_add(struct platform_device *ofdev)
> >
> >  	/* name and id have to be set so that the platform bus doesn't get
> >  	 * confused on matching */
> > -	ofdev->name = dev_name(&ofdev->dev);
> > +	ofdev->name = kstrdup(dev_name(&ofdev->dev), GFP_KERNEL);
> >  	ofdev->id = -1;
> >
> >  	/* device_add will assume that this device is on the same node as
> > @@ -76,6 +76,7 @@ EXPORT_SYMBOL(of_device_register);
> >  void of_device_unregister(struct platform_device *ofdev)
> >  {
> >  	device_unregister(&ofdev->dev);
> > +	kfree(ofdev->name);
> 
> This probably ought to be swapped because we don't know if ofdev isn't
> pointing to freed memory after device_unregister().

Actually, the only safe place to free the memory is inside the
platform_device release function. platform_device_release() in
drivers/base/platform.c. Unfortunately there isn't a good way from that
function to figure out if the name has been allocated the 'OF' way.

It is not safe to free it here because there could still be references
to the platform_device after device_unregister exits.

g.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ