From: Maneesh Soni <maneesh@in.ibm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Greg KH <greg@kroah.com>, LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: What protection does sysfs_readdir have with SMP/Preemption?
Date: Thu, 24 Nov 2005 09:46:08 +0530 [thread overview]
Message-ID: <20051124041608.GA16502@in.ibm.com> (raw)
In-Reply-To: <1132755344.13395.32.camel@localhost.localdomain>
On Wed, Nov 23, 2005 at 09:15:44AM -0500, Steven Rostedt wrote:
> On Wed, 2005-11-23 at 19:28 +0530, Maneesh Soni wrote:
>
> >
> > hmm looks like we got some situation which is not desirable and could lead
> > to bogus sysfs_dirent in the parent list. It may not be the exact problem
> > in this case though, but needs fixing IMO.
> >
> > After sysfs_make_dirent(), the ref count for sysfs dirent will be 2.
> > (one from allocation, and after linking the new dentry to it). On
> > error from sysfs_create(), we do sysfs_put() once, decrementing the
> > ref count to 1. And again when the new dentry for which we couldn't
> > allocate the d_inode, is d_drop()'ed. In sysfs_d_iput() we again
> > sysfs_put(), and decrement the sysfs dirent's ref count to 0, which will
> > be the final sysfs_put(), and it will free the sysfs_dirent but never
> > unlinks it from the parent list. So, parent list could still will having
> > links to the freed sysfs_dirent in its s_children list.
> >
> > so basically list_del_init(&sd->s_sibling) should be done in error path
> > in create_dir().
> >
> > Could you also put the appended patch in your trial runs..
> >
>
> I'm already playing around with this. You might want this patch instead.
> I noticed that if sysfs_make_dirent fails to allocate the sd, then a
> null will be passed to sysfs_put.
>
> But this is not the end of the problems. I'll follow up on that comment
> right after this.
>
> -- Steve
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
>
> Index: linux-2.6.15-rc2-git2/fs/sysfs/dir.c
> ===================================================================
> --- linux-2.6.15-rc2-git2.orig/fs/sysfs/dir.c 2005-11-23 08:40:33.000000000 -0500
> +++ linux-2.6.15-rc2-git2/fs/sysfs/dir.c 2005-11-23 08:52:57.000000000 -0500
> @@ -112,7 +112,11 @@
> }
> }
> if (error && (error != -EEXIST)) {
> - sysfs_put((*d)->d_fsdata);
> + struct sysfs_dirent *sd = (*d)->d_fsdata;
> + if (sd) {
> + list_del_init(&sd->s_sibling);
> + sysfs_put(sd);
> + }
> d_drop(*d);
> }
> dput(*d);
>
>
Agreed. This makes more sense.
Thanks
Maneesh
--
Maneesh Soni
Linux Technology Center,
IBM India Software Labs,
Bangalore, India
email: maneesh@in.ibm.com
Phone: 91-80-25044990
next prev parent reply other threads:[~2005-11-24 4:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-22 21:33 Steven Rostedt
2005-11-22 21:39 ` Greg KH
2005-11-23 4:50 ` Maneesh Soni
2005-11-23 8:18 ` Ingo Molnar
2005-11-23 12:35 ` Steven Rostedt
2005-11-23 12:54 ` Maneesh Soni
2005-11-23 12:50 ` Maneesh Soni
2005-11-23 12:52 ` [OOPS] sysfs_hash_and_remove (was Re: What protection ....) Maneesh Soni
2005-11-24 12:26 ` Maneesh Soni
2005-11-24 14:34 ` Ingo Molnar
2005-11-26 22:26 ` James Bottomley
2006-02-11 0:33 ` Greg KH
2006-02-11 15:46 ` Steven Rostedt
2006-02-24 1:04 ` Greg KH
2005-11-23 12:56 ` What protection does sysfs_readdir have with SMP/Preemption? Steven Rostedt
2005-11-23 13:58 ` Maneesh Soni
2005-11-23 14:15 ` Steven Rostedt
2005-11-23 14:20 ` Steven Rostedt
2005-11-23 15:24 ` kobject_register needs return value checks (was: What protection does sysfs_readdir have with SMP/Preemption?) Steven Rostedt
2005-11-24 4:16 ` Maneesh Soni [this message]
2005-11-24 14:32 ` What protection does sysfs_readdir have with SMP/Preemption? Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051124041608.GA16502@in.ibm.com \
--to=maneesh@in.ibm.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome