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: <1196367597.7903.25.camel@lov.site>
Date:	Thu, 29 Nov 2007 21:19:57 +0100
From:	Kay Sievers <kay.sievers@...y.org>
To:	Alan Stern <stern@...land.harvard.edu>
Cc:	Cornelia Huck <cornelia.huck@...ibm.com>, Greg KH <greg@...ah.com>,
	Kernel development list <linux-kernel@...r.kernel.org>,
	Jonathan Corbet <corbet@....net>,
	Randy Dunlap <randy.dunlap@...cle.com>
Subject: Re: [PATCH] kobject: make sure kobj->ktype is set before
	kobject_init

On Thu, 2007-11-29 at 15:09 -0500, Alan Stern wrote:
> On Thu, 29 Nov 2007, Kay Sievers wrote:
> 
> > > My conclusion is different.  We should make kobject_init() not consume
> > > any resources at all; just initialize various fields.  That way it
> > > would be okay to call either kfree() or kobject_put() on an initialized
> > > kobject.  And then when something like device_register() fails, the
> > > caller would know the proper thing to do would be to call the put()  
> > > routine, always.
> > > 
> > > Of course, once the name has been assigned, only kobject_put() should
> > > be used.
> > 
> > Now we just move the exactly the same problem from _init() to
> > _set_name(). To free the name of an unregistered we would need to call
> > _put() which free()'s the whole object again. :) 
> 
> I don't see that as a problem and it's not clear why you do.
> 
> It doesn't matter whether a kobject has been registered or not; once
> it has been initialized you _should_ call kobject_put().  (Although
> it's okay to call kfree() if the name hasn't been set yet.)

I just say, it's exactly the same problem and it does not really make a
difference that kobject_init() does not do anything, if we require
another function to be called before we can call kobject_add(). A
kobject without a name will not be valid, and we will need a way for an
easy cleanup of allocated resources I think.

> The same is true of larger objects.  Once you have called
> device_initialize(), you _should_ call device_put() (although it's okay
> to call kfree()).  Provided init routines don't consume resources, this
> will work.
> 
> The only remaining problem is that somebody might set the name first
> and then decide to abandon the object before calling kobject_init().  
> However this probably never happens anywhere.

What is the whole point of kobject_init() then? You can just do the same
stuff in kobject_add() if you require not to allocate anything there. 

None of the initialized fields can be used before we have called
kobject_add(), right?

> > > There's another good reason for not assigning the name in
> > > kobject_init(): Code that uses kobjects (like the driver core) doesn't
> > > set the name until later.
> > 
> > That can be done at any stage, I guess. We will rip out the name in the
> > struct device anyway.
> 
> Are you also going to change all the places in the kernel where the
> device name (.bus_id) isn't set until after device_initialize() has
> been called?

Yes, I already have a patch that does that for all stuff that was needed
on my boxes.

Kay

-
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