mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Steven Rostedt <rostedt@goodmis.org>, Maneesh Soni <maneesh@in.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: What protection does sysfs_readdir have with SMP/Preemption?
Date: Tue, 22 Nov 2005 13:39:47 -0800	[thread overview]
Message-ID: <20051122213947.GB8575@kroah.com> (raw)
In-Reply-To: <1132695202.13395.15.camel@localhost.localdomain>

On Tue, Nov 22, 2005 at 04:33:22PM -0500, Steven Rostedt wrote:
> Hi,
> 
> I'm developing a custom kernel on top of Ingo's -rt patch. My kernel
> makes race conditions in the vanilla kernel show up very well :-)
> 
> I just hit a bug, actually a page fault in fs/sysfs/dir.c in
> sysfs_readdir:
> 
> 
> 
> 			for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
> 				struct sysfs_dirent *next;
> 				const char * name;
> 				int len;
> 
> 				next = list_entry(p, struct sysfs_dirent,
> 						   s_sibling);
> 				if (!next->s_element)
> 					continue;
> 
> 				name = sysfs_get_name(next);
> 				len = strlen(name);
> 				if (next->s_dentry)
> 					ino = next->s_dentry->d_inode->i_ino;
> 
> ^^^^
> This is where I had a bad pointer reference.
> 
> 				else
> 					ino = iunique(sysfs_sb, 2);
> 
> 				if (filldir(dirent, name, len, filp->f_pos, ino,
> 						 dt_type(next)) < 0)
> 					return 0;
> 
> 
> Looking at this code, I don't see anything protecting the s_dentry. For
> example, couldn't the following happen:
> 
> sysfs_create_dir is called, which calls create_dir.  Now we create a
> dentry with no d_inode. In sysfs_make_dirent which calls
> sysfs_new_dirent which adds to the parents s_children. Then
> sysfs_make_dirent sets s_dentry = dentry (the one that was just made
> with no d_inode assigned yet).  Then create_dir calls sysfs_create which
> finally assigns the d_inode.
> 
> So, either there is some hidden protection and my modification to the
> kernel has caused this to bug, or we have just been lucky the whole time
> in the vanilla kernel.

I think we've been lucky :(

Maneesh, any ideas?

thanks,

greg k-h

  reply	other threads:[~2005-11-22 21:41 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 [this message]
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           ` What protection does sysfs_readdir have with SMP/Preemption? Maneesh Soni
2005-11-24 14:32             ` 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=20051122213947.GB8575@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maneesh@in.ibm.com \
    --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

all inboxes | Powered by JetHome®