linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: miklos@szeredi.hu, raven@themaw.net, viro@ZenIV.linux.org.uk,
	torvalds@linux-foundation.org
Cc: dhowells@redhat.com, jlayton@redhat.com, gregkh@suse.de,
	linux-nfs@vger.kernel.org, leonardo.lists@gmail.com
Subject: [PATCH 1/7] NFS4: Revert commit to make the automount code ignore LOOKUP_FOLLOW
Date: Fri, 23 Sep 2011 17:24:51 +0100	[thread overview]
Message-ID: <20110923162451.13574.33960.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20110923162438.13574.52985.stgit@warthog.procyon.org.uk>

Revert the following change:

	commit 0ec26fd0698285b31248e34bf1abb022c00f23d6
	Author: Miklos Szeredi <mszeredi@suse.cz>
	Date:   Mon Sep 5 18:06:26 2011 +0200
	Subject: vfs: automount should ignore LOOKUP_FOLLOW

which makes stat(), getxattr(), etc. behave as lstat(), lgetxattr(), etc. with
respect to automounting: it prevents them from triggering terminal automounts.

The problem with this is that this breaks nfs_follow_remote_path() used by NFS4
to find the root object to mount for the mount() syscall.

This can be tested by the following procedure:

 (1) Export a directory from an NFS4 server that has something mounted upon it
     and that isn't "/" - say, for example, "/scratch".  It must have a
     different FSID from "/".

 (2) Mount this on the client.

	mount sirius:/scratch /mnt

 (3) List the contents of the client's mountpoint:

	ls /mnt

 (4) Examine /proc/fs/nfsfs/volumes.  You should see one entry (assuming
     nothing else is NFS mounted) :

	NV SERVER   PORT DEV     FSID              FSC
	v4 200108b001940000021125fffe84efad  801 0:34    1:0               no

     which corresponds to the filesystem mounted on /scratch on the server.

     If, however, you see two entries:

	NV SERVER   PORT DEV     FSID              FSC
	v4 200108b001940000021125fffe84efad  801 0:33    0:0               no
	v4 200108b001940000021125fffe84efad  801 0:34    1:0               no

     then it went wrong.

When it goes wrong, what happens is that nfs_follow_remote_path() walks from
the rootfh to the remote directory (/scratch) using vfs_path_lookup().  It
passes LOOKUP_FOLLOW to vfs_path_lookup() to tell it to transit terminal
symlinks and terminal automounts.  Unfortunately, with the problematic commit,
LOOKUP_FOLLOW now expressly does not follow terminal automounts, and so the
dummy automount directory fabricated in fsid 0:0 gets mounted instead of the
root of fsid 1:0.

Reported-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/namei.c |   33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index f478836..c64b81d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -727,22 +727,25 @@ static int follow_automount(struct path *path, unsigned flags,
 	if ((flags & LOOKUP_NO_AUTOMOUNT) && !(flags & LOOKUP_PARENT))
 		return -EISDIR; /* we actually want to stop here */
 
-	/* We don't want to mount if someone's just doing a stat -
-	 * unless they're stat'ing a directory and appended a '/' to
-	 * the name.
-	 *
-	 * We do, however, want to mount if someone wants to open or
-	 * create a file of any type under the mountpoint, wants to
-	 * traverse through the mountpoint or wants to open the
-	 * mounted directory.  Also, autofs may mark negative dentries
-	 * as being automount points.  These will need the attentions
-	 * of the daemon to instantiate them before they can be used.
+	/*
+	 * We don't want to mount if someone's just doing a stat and they've
+	 * set AT_SYMLINK_NOFOLLOW - unless they're stat'ing a directory and
+	 * appended a '/' to the name.
 	 */
-	if (!(flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY |
-		     LOOKUP_OPEN | LOOKUP_CREATE)) &&
-	    path->dentry->d_inode)
-		return -EISDIR;
-
+	if (!(flags & LOOKUP_FOLLOW)) {
+		/* We do, however, want to mount if someone wants to open or
+		 * create a file of any type under the mountpoint, wants to
+		 * traverse through the mountpoint or wants to open the mounted
+		 * directory.
+		 * Also, autofs may mark negative dentries as being automount
+		 * points.  These will need the attentions of the daemon to
+		 * instantiate them before they can be used.
+		 */
+		if (!(flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY |
+			     LOOKUP_OPEN | LOOKUP_CREATE)) &&
+		    path->dentry->d_inode)
+			return -EISDIR;
+	}
 	current->total_link_count++;
 	if (current->total_link_count >= 40)
 		return -ELOOP;


  reply	other threads:[~2011-09-23 16:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-23 16:24 [RFC][PATCH 0/7] Automount behaviour correction David Howells
2011-09-23 16:24 ` David Howells [this message]
2011-09-23 16:35   ` [PATCH 1/7] NFS4: Revert commit to make the automount code ignore LOOKUP_FOLLOW Linus Torvalds
2011-09-23 16:53   ` David Howells
2011-09-23 16:25 ` [PATCH 2/7] VFS: Make chown() and lchown() call fchownat() David Howells
2011-09-23 16:25 ` [PATCH 3/7] VFS: Change LOOKUP_NO_AUTOMOUNT to LOOKUP_AUTOMOUNT David Howells
2011-09-23 16:25 ` [PATCH 4/7] VFS: Move the automount suppression decision out to the initial callers of David Howells
2011-09-23 16:25 ` [PATCH 5/7] VFS: Ignore symlink following advice when pathwalking David Howells
2011-09-23 16:25 ` [PATCH 6/7] VFS: Make stat and xattr calls not automount David Howells
2011-09-23 16:26 ` [PATCH 7/7] VFS: Vary the automounting rules for autofs David Howells
2011-09-23 16:29 ` [RFC][PATCH 0/7] Automount behaviour correction Linus Torvalds

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=20110923162451.13574.33960.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=gregkh@suse.de \
    --cc=jlayton@redhat.com \
    --cc=leonardo.lists@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=raven@themaw.net \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.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;
as well as URLs for NNTP newsgroup(s).