public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: maneesh@in.ibm.com
Cc: Ethan Solomita <solo@google.com>,
	Dipankar Sarma <dipankar@in.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Greg KH <greg@kroah.com>, Martin Bligh <mbligh@google.com>,
	Rohit Seth <rohitseth@google.com>,
	viro@ftp.linux.org.uk, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fix sysfs_readdir oops (was Re: sysfs reclaim crash)
Date: Sat, 07 Apr 2007 17:31:20 +0900	[thread overview]
Message-ID: <461756D8.8070002@gmail.com> (raw)
In-Reply-To: <20070403073830.GA9796@in.ibm.com>

Hello, Maneesh.

Maneesh Soni wrote:
> o sysfs_d_iput() is invoked in dentry reclaim path under memory pressure. This
>   happens without i_mutex. It also nullifies s_dentry to indicate that
>   the associated dentry is evicted. sysfs_readdir() accesses the s_dentry,
>   and gets the inode number from the associated dentry->d_inode, if 
>   there is one, else it invokes iunique(). This can create a race situation,
>   and crash while accessing the d_inode in sysfs_readdir(). 
> 
> o The race happens when the dentry is getting reclaimed and detached from
>   the corresponding sysfs_dirent though sysfs_dirent is still a valid
>   node. Accessing dentry fields are ok as it is under RCU but the inode is
>   not hence we may see oops accessing dentry->d_inode->i_no.
> 
> o The following patch always use i_unique() to get the inode number in
>   sysfs_readdir. This is ok as sysfs doesnot have permanent inode numbering.
>   It could be slower but avoids the oops. 

This isn't correct as i_unique() assumes the inode is in inode hash
table which isn't true for sysfs.  This can result in duplicate inode
numbers.  Please take a look at the following alternative fix.

  http://article.gmane.org/gmane.linux.kernel/513325

Thanks.

-- 
tejun

      parent reply	other threads:[~2007-04-07  8:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070319140238.cbf28b2b.akpm@linux-foundation.org>
     [not found] ` <20070321134654.5wkqpfbpk0ggwks8@imap.linux.ibm.com>
     [not found]   ` <20070321182123.GA12602@in.ibm.com>
     [not found]     ` <20070323043047.GA5641@in.ibm.com>
     [not found]       ` <20070322210504.3b052139.akpm@linux-foundation.org>
     [not found]         ` <46042DDF.5060000@google.com>
2007-03-24  3:05           ` sysfs reclaim crash Maneesh Soni
2007-03-27 18:27             ` Ethan Solomita
2007-03-27 18:49               ` Maneesh Soni
2007-04-03  7:38             ` [PATCH] fix sysfs_readdir oops (was Re: sysfs reclaim crash) Maneesh Soni
2007-04-03 20:46               ` Ethan Solomita
2007-04-07  8:31               ` Tejun Heo [this message]

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=461756D8.8070002@gmail.com \
    --to=htejun@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dipankar@in.ibm.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maneesh@in.ibm.com \
    --cc=mbligh@google.com \
    --cc=rohitseth@google.com \
    --cc=solo@google.com \
    --cc=viro@ftp.linux.org.uk \
    /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