All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Nick Piggin <npiggin@gmail.com>
Cc: David Howells <dhowells@redhat.com>,
	raven@themaw.net, npiggin@kernel.dk, autofs@linux.kernel.org,
	linux-fsdevel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 19/18] Unexport do_add_mount() and add in follow_automount(), not ->d_automount()
Date: Sat, 15 Jan 2011 13:30:30 +0000	[thread overview]
Message-ID: <20110115133029.GN19804@ZenIV.linux.org.uk> (raw)
In-Reply-To: <AANLkTimMVF7HSOqJGWphY2fbaXDbegppe+Vug8e5V1HN@mail.gmail.com>


> > AFAICS, it keeps your write-free objectives and gets much saner API.
> > Shout if you have problems with that...
> 
> No that sounds good, I don't have a problem with it, although I don't
> exactly understand what you're getting at in the second paragraph.

OK, I have a hopefully sane implementation in tip of #untested.

There's a fun problem with what you do in do_lookup(), BTW.  Look:
we enter do_lookup() with LOOKUP_RCU.  We find dentry in dcache,
everything's beautiful.  The sucker has ->d_revalidate().  We go
to need_revalidate.  There we call do_revalidate().  It calls
d_revalidate(), which calls ->d_revalidate() and instead of spitting
into your eye and returning -ECHILD it happily returns 1.  So
do d_revalidate() and then do_revalidate(), without any further
actions.  do_revalidate() has returned our dentry, which is neither
NULL nor ERR_PTR(), so back in do_lookup() we go to done.

There we set path->mnt and path->dentry and call __follow_mount().
And damn, it *is* a mountpoint.  So we
	* do dput() on dentry we'd never grabbed a reference to
	* grab a reference to a different dentry (and remain in happy
belief that we are in LOOKUP_RCU mode, and thus don't need to drop it)
	* grab a reference to vfsmount (via lookup_mnt()).  Ditto (and
I haven't checked if grabbing vfsmount_lock twice shared isn't a recipe
for a deadlocky race with something grabbing it exclusive between these
nested shared grabs).
	* if we are really unlucky and that mountpoint is, in turn,
overmounted, we'll hit mntput().  While under vfsmount_lock.

AFAICS, it's badly b0rken.  And autofs really steps into that mess.

As minimum, we'd need to split need_revalidate: and done: in RCU and non-RCU
variants.  I'm about to fall down right now after an all-nighter (and then
some); if you put something together before I get up, please throw it
my way.

Note that the problem exists both in mainline and in mainline+automount
patches; in the latter it's a bit nastier, but in principle the situation
is the same, so I'd rather see a fix for that in front of automount queue.

  reply	other threads:[~2011-01-15 13:30 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-13 21:53 [PATCH 00/18] Introduce automount support in the VFS [ver #4] David Howells
2011-01-13 21:54 ` [PATCH 01/18] Add a dentry op to handle automounting rather than abusing follow_link() " David Howells
2011-01-16  0:09   ` Al Viro
2011-01-16  1:17     ` Al Viro
2011-01-16 18:12       ` David Howells
2011-01-13 21:54 ` [PATCH 02/18] Add a dentry op to allow processes to be held during pathwalk transit " David Howells
2011-01-13 21:54 ` [PATCH 03/18] From: David Howells <dhowells@redhat.com> " David Howells
2011-01-13 21:54 ` [PATCH 04/18] AFS: Use d_automount() rather than abusing follow_link() " David Howells
2011-01-13 21:54 ` [PATCH 05/18] NFS: " David Howells
2011-01-13 21:54 ` [PATCH 06/18] CIFS: " David Howells
2011-01-13 21:54 ` [PATCH 07/18] Remove the automount through follow_link() kludge code from pathwalk " David Howells
2011-01-13 21:54 ` [PATCH 08/18] autofs4: Add d_automount() dentry operation " David Howells
2011-01-13 21:54 ` [PATCH 09/18] autofs4: Add d_manage() " David Howells
2011-01-14 13:51   ` Ian Kent
2011-01-14 14:37     ` Nick Piggin
2011-01-14 15:35       ` David Howells
2011-01-14 15:46         ` Nick Piggin
2011-01-14 15:47       ` Nick Piggin
2011-01-13 21:54 ` [PATCH 10/18] autofs4: Remove unused code " David Howells
2011-01-13 21:54 ` [PATCH 11/18] autofs4: Clean up inode operations " David Howells
2011-01-13 21:55 ` [PATCH 12/18] autofs4: Clean up dentry " David Howells
2011-01-13 21:55 ` [PATCH 13/18] autofs4: Clean up autofs4_free_ino() " David Howells
2011-01-14 16:03   ` Al Viro
2011-01-13 21:55 ` [PATCH 14/18] autofs4: Fix wait validation " David Howells
2011-01-13 21:55 ` [PATCH 15/18] autofs4: Add v4 pseudo direct mount support " David Howells
2011-01-13 21:55 ` [PATCH 16/18] autofs4: Bump version " David Howells
2011-01-13 21:55 ` [PATCH 17/18] Remove a further kludge from __do_follow_link() " David Howells
2011-01-13 21:55 ` [PATCH 18/18] Allow d_manage() to be used in RCU-walk mode " David Howells
2011-01-14  7:02 ` [PATCH 00/18] Introduce automount support in the VFS " Al Viro
2011-01-14  7:05   ` Al Viro
2011-01-14 11:20     ` David Howells
2011-01-14 11:43   ` David Howells
2011-01-14 11:54     ` David Howells
2011-01-14 11:54       ` David Howells
2011-01-14 15:46     ` Al Viro
2011-01-14 17:26       ` [PATCH 19/18] Unexport do_add_mount() and add in follow_automount(), not ->d_automount() David Howells
2011-01-14 17:30         ` David Howells
2011-01-14 17:43         ` Al Viro
2011-01-14 17:56           ` Al Viro
2011-01-14 18:06             ` Al Viro
2011-01-14 22:07               ` Nick Piggin
2011-01-15 13:30                 ` Al Viro [this message]
2011-01-15 18:33                   ` Nick Piggin
2011-01-16  0:24                     ` Al Viro
2011-01-16  1:21                       ` Nick Piggin
2011-01-15 18:46                   ` Nick Piggin

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=20110115133029.GN19804@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=autofs@linux.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=npiggin@gmail.com \
    --cc=npiggin@kernel.dk \
    --cc=raven@themaw.net \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.