public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-fsdevel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	xfs@oss.sgi.com
Subject: Re: inode_permission NULL pointer dereference in 3.13-rc1
Date: Thu, 28 Nov 2013 21:23:01 +0000	[thread overview]
Message-ID: <20131128212301.GP10323@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20131128162618.GO10323@ZenIV.linux.org.uk>

On Thu, Nov 28, 2013 at 04:26:18PM +0000, Al Viro wrote:
> On Wed, Nov 27, 2013 at 02:09:06AM -0800, Christoph Hellwig wrote:
> 
> > Also if you want to look me into something else feel free - it's very
> > reproducable here.  Wish I could be more help here, but with all the
> > RCU and micro optimizations in the path lookup code I can't claim to
> > really understand it anymore.
> 
> OK, I've been able to reproduce it and I see at least a part of what's
> going on, but...
> 
> What happens is that we get path_init() race with something and leave
> us with nd->path pointing to what used to be pwd but has become a
> negative dentry in process.
> 
> AFAICS, it *was* borderline possible to hit before now:
> 
> process A and B are CLONE_FS threads and are chdired to /tmp/foo
> A asks for e.g. readlink() on bar
> 	in path_init() we'd got nd->path (at /tmp/foo) and nd->seq; we are
> 	in LOOKUP_RCU mode, so nd->path isn't pinned.
> B chdirs them both to /tmp, leaving /tmp/foo not busy
> C rmdirs /tmp/foo
> A sets nd->inode to nd->path.dentry->d_inode, but this sucker has gone
> negative now.  Sure, nd->seq doesn't match anymore, but that doesn't
> do us any good - the first thing we'll do in link_path_walk() is
> may_lookup(nd) and it'll blow on attempt to call inode_permission() for
> nd->inode.
> 
> What I still do not understand is how the devil is similar race actually
> triggered during shutdown.  Digging through that right now...
> 
> Anyway, verifying that this is what's going on for particular reproducer
> is easy - add WARN_ON(!nd->inode) in the very end of path_init() and
> see if it triggers.

*grumble*

Looks like adding if (!nd->inode) { a bunch of printks } in the end of
path_init() makes the sucker disappear (so far 2 times out of 2, and
with a test run taking a bit under two hours, well...)  The plain
WARN_ON(!nd->inode) in that place triggers just fine.

Another interesting bit of data is that a few minutes delay between ./check
and halt and oops doesn't happen.

So far the catch I've got is:
	* a regression in follow_dotdot_rcu(), closed by checking nd->m_seq
in the very end of it.  Fix is obvious, obviously needed and it has nothing
to do with that oops.
	* a long-standing three-way race in path_init()/chdir(2)/rmdir(2)
(see upthread); it (and its analog for absolute paths, with s/chdir/chroot/)
needs fixing and backporting the fix, the easiest fix probably being "check
nd->seq in the end of LOOKUP_RCU path_init(), fail with -ECHILD on unlikely
mismatch).  That one would hit the place where that oops on halt seems to
live, but it's not what we step upon.

What I am seeing (OK, had been seeing until adding those printks) is very
odd - it looks like root and/or pwd of startpar running /etc/rc6.d/* stuff
slaps some negative dentry into nd->path when the shit hits the fan.  Right
in path_init()...

Any suggestions re debugging that are welcome; for now I've moved those extra
printks into link_path_walk() (where I already had some, under if (!nd->inode))
and I'm trying to trigger the sucker again ;-/

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2013-11-28 21:23 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-24 14:04 inode_permission NULL pointer dereference in 3.13-rc1 Christoph Hellwig
2013-11-24 15:27 ` Al Viro
2013-11-25 16:06   ` Christoph Hellwig
2013-11-26 13:11     ` Al Viro
2013-11-26 14:12       ` Christoph Hellwig
2013-11-27  6:43         ` Al Viro
2013-11-27 10:09           ` Christoph Hellwig
2013-11-28 16:26             ` Al Viro
2013-11-28 21:23               ` Al Viro [this message]
2013-11-28 22:51                 ` Dave Chinner
2013-11-28 23:44                   ` Al Viro
2013-11-29  1:46                     ` Dave Chinner
2013-11-29  2:07                       ` Al Viro
2013-11-29  2:17                         ` Linus Torvalds
2013-11-29  2:07                     ` Linus Torvalds
2013-11-29  2:41                       ` Al Viro
2013-11-29  3:59                         ` Al Viro
2013-11-29  4:06                           ` Al Viro
2013-11-29  4:14                             ` Al Viro
2013-11-29  6:59                               ` Al Viro
2013-11-29 19:44                                 ` Greg KH
2013-11-29 20:17                                   ` Linus Torvalds
2013-11-29 23:55                                     ` Al Viro
2013-11-30  0:18                                       ` Linus Torvalds
2013-11-30 15:09                                 ` [GIT PULL] " Theodore Ts'o
2013-11-30 15:13                                   ` Theodore Ts'o
2013-11-27 21:51           ` Dave Chinner
2013-11-28 15:21 ` Theodore Ts'o
2013-11-28 15:36   ` Theodore Ts'o

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=20131128212301.GP10323@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=xfs@oss.sgi.com \
    /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