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]
Date:	Fri, 30 Mar 2007 10:41:58 -0700
From:	Greg KH <gregkh@...e.de>
To:	Tejun Heo <htejun@...il.com>
Cc:	James Bottomley <James.Bottomley@...elEye.com>, hugh@...itas.com,
	cornelia.huck@...ibm.com, dmitry.torokhov@...il.com,
	oneukum@...e.de, maneesh@...ibm.com, rpurdie@...ys.net,
	Jeff Garzik <jgarzik@...ox.com>,
	lkml <linux-kernel@...r.kernel.org>,
	"linux-ide@...r.kernel.org" <linux-ide@...r.kernel.org>,
	SCSI Mailing List <linux-scsi@...r.kernel.org>
Subject: Re: [RFD driver-core] Lifetime problems of the current driver model

On Fri, Mar 30, 2007 at 10:38:00PM +0900, Tejun Heo wrote:
> James Bottomley wrote:
> > On Fri, 2007-03-30 at 18:43 +0900, Tejun Heo wrote:
> >> Orphaning sysfs nodes on unregistration is a big step in this
> >> direction.  With sysfs reference counting out of the picture,
> >> implementing 'disconnect immediate' interface only on a few components
> >> (including request_queue) should suffice for most block device
> >> drivers.  I'm not familiar with other drivers but I don't think
> >> they'll be very different.
> > 
> > I agree with this statement.  The big question in my mind is how do we
> > do it?
> > 
> > The essential problem, and the reason why the lifetime rules are
> > entangled is that fundamentally, sysfs entries are managed by kobjects.
> > The things the device drivers are interested in is struct device, which
> > is usually embedded in driver data structures.  Unfortunately, the
> > required kobject is usually embedded in struct device meaning that the
> > relevant driver structure cannot be freed while the sysfs entry still
> > exists.
> > 
> > It seems to me that the only way to Orphan the sysfs entries is to
> > separate the kobject and the struct device so their lifetime rules are
> > no longer entangled.  Then we can free the driver structure with the
> > embedded struct device while still keeping the necessary kobject around
> > to perform orphaned sysfs operations.
> > 
> > So it seems to me that what we need to do is to give struct device its
> > own kref and a pointer to a kobject.  Then we can manage the separate
> > lifetimes independently.  The device would basically allocate and take a
> > reference to the kobject on device_add() and relinquish it again (and
> > null out the kobject pointer) on device_del().  The complexity here is
> > that we now have to allocate the kobject somewhere else ... probably in
> > device_add() (it doesn't come for free with the device structures).
> 
> My plan was to make sysfs more independent from struct device/kobject.
> e.g. Something like the following.
> 
> * kobject_get() on attr/symlink creation
> * open() doesn't need extra kobject reference
> * deleting a node makes it release the kobject reference and the kobject
> pointer is nullified.

Hm, this sounds good, but I think it will be racy.

Although separating the very tight tie between sysfs and kobject would
be very good to have.  Pat originally wanted to do that years ago,
but he's now lost to the land of a million sheep...

So I don't object to this goal at all.

> This way the sysfs reference counting can be put completely out of
> picture without impacting the rest of code.  Handling symlink and
> suicidal attributes might need some extra attention but I think they can
> be done.

Ok, I'll but I really want to see that code :)

> In the long term, I think sysfs should be independent from driver model
> and kobject such that an entity which wants to use sysfs but is not a
> device doesn't have to dance with kobject just to use sysfs.

I agree.

thanks,

greg k-h
-
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