From: Valerie Aurora <vaurora@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: Jan Blunck <jblunck@suse.de>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Valerie Aurora <vaurora@redhat.com>, Ian Kent <raven@themaw.net>,
autofs@linux.kernel.org
Subject: [PATCH 1/7] autofs4: Save autofs trigger's vfsmount in super block info
Date: Wed, 23 Dec 2009 15:36:57 -0800 [thread overview]
Message-ID: <1261611423-4396-2-git-send-email-vaurora@redhat.com> (raw)
In-Reply-To: <1261611423-4396-1-git-send-email-vaurora@redhat.com>
From: Jan Blunck <jblunck@suse.de>
This is a bugfix/replacement for commit
051d381259eb57d6074d02a6ba6e90e744f1a29f:
During a path walk if an autofs trigger is mounted on a dentry,
when the follow_link method is called, the nameidata struct
contains the vfsmount and mountpoint dentry of the parent mount
while the dentry that is passed in is the root of the autofs
trigger mount. I believe it is impossible to get the vfsmount of
the trigger mount, within the follow_link method, when only the
parent vfsmount and the root dentry of the trigger mount are
known.
The solution in this commit was to replace the path embedded in the
parent's nameidata with the path of the link itself in
__do_follow_link(). This is a relatively harmless misuse of the
field, but union mounts ran into a bug during follow_link() caused by
the nameidata containing the wrong path (we count on it being what it
is all other places - the path of the parent).
A cleaner and easier to understand solution is to save the necessary
vfsmount in the autofs superblock info when it is mounted. Then we
can easily update the vfsmount in autofs4_follow_link().
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Valerie Aurora <vaurora@redhat.com>
Cc: Ian Kent <raven@themaw.net>
Cc: autofs@linux.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
---
fs/autofs4/autofs_i.h | 1 +
fs/autofs4/init.c | 11 ++++++++++-
fs/autofs4/root.c | 6 ++++++
fs/namei.c | 7 ++-----
4 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 8f7cdde..db2bfce 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -130,6 +130,7 @@ struct autofs_sb_info {
int reghost_enabled;
int needs_reghost;
struct super_block *sb;
+ struct vfsmount *mnt;
struct mutex wq_mutex;
spinlock_t fs_lock;
struct autofs_wait_queue *queues; /* Wait queue pointer */
diff --git a/fs/autofs4/init.c b/fs/autofs4/init.c
index 9722e4b..5e0dcd7 100644
--- a/fs/autofs4/init.c
+++ b/fs/autofs4/init.c
@@ -17,7 +17,16 @@
static int autofs_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
{
- return get_sb_nodev(fs_type, flags, data, autofs4_fill_super, mnt);
+ struct autofs_sb_info *sbi;
+ int ret;
+
+ ret = get_sb_nodev(fs_type, flags, data, autofs4_fill_super, mnt);
+ if (ret)
+ return ret;
+
+ sbi = autofs4_sbi(mnt->mnt_sb);
+ sbi->mnt = mnt;
+ return 0;
}
static struct file_system_type autofs_fs_type = {
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index b96a3c5..cb991b8 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -179,6 +179,12 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
DPRINTK("dentry=%p %.*s oz_mode=%d nd->flags=%d",
dentry, dentry->d_name.len, dentry->d_name.name, oz_mode,
nd->flags);
+
+ dput(nd->path.dentry);
+ mntput(nd->path.mnt);
+ nd->path.mnt = mntget(sbi->mnt);
+ nd->path.dentry = dget(dentry);
+
/*
* For an expire of a covered direct or offset mount we need
* to break out of follow_down() at the autofs mount trigger
diff --git a/fs/namei.c b/fs/namei.c
index d11f404..c768444 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -629,11 +629,8 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata
touch_atime(path->mnt, dentry);
nd_set_link(nd, NULL);
- if (path->mnt != nd->path.mnt) {
- path_to_nameidata(path, nd);
- dget(dentry);
- }
- mntget(path->mnt);
+ if (path->mnt == nd->path.mnt)
+ mntget(nd->path.mnt);
cookie = dentry->d_inode->i_op->follow_link(dentry, nd);
error = PTR_ERR(cookie);
if (!IS_ERR(cookie)) {
--
1.5.6.5
next prev parent reply other threads:[~2009-12-23 23:37 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-23 23:36 [PATCH 0/7] VFS prep for union mounts/writable overlays Valerie Aurora
2009-12-23 23:36 ` Valerie Aurora [this message]
2009-12-23 23:36 ` [PATCH 2/7] VFS: Make lookup_hash() return a struct path Valerie Aurora
2009-12-23 23:36 ` [PATCH 3/7] VFS: Make real_lookup() " Valerie Aurora
2009-12-23 23:37 ` [PATCH 4/7] VFS: Propagate mnt_flags into do_loopback Valerie Aurora
2009-12-23 23:37 ` [PATCH 5/7] VFS: Add read-only users count to superblock Valerie Aurora
2009-12-23 23:37 ` [PATCH 6/7] VFS: BUG_ON() rehash of an already hashed dentry Valerie Aurora
2009-12-23 23:37 ` [PATCH 7/7] VFS: Remove unnecessary micro-optimization in cached_lookup() Valerie Aurora
2010-01-02 0:44 ` [PATCH 1/7] autofs4: Save autofs trigger's vfsmount in super block info Ian Kent
2010-01-14 5:43 ` Al Viro
2010-01-14 19:18 ` Valerie Aurora
2010-01-15 6:05 ` Ian Kent
2010-01-15 8:03 ` Al Viro
2010-01-15 17:36 ` Steve French
2010-01-18 5:08 ` Ian Kent
2010-01-15 14:55 ` David Howells
2010-01-15 16:58 ` Al Viro
2010-01-15 17:08 ` David Howells
2010-01-15 17:26 ` Al Viro
2010-01-16 10:17 ` Al Viro
2010-01-17 17:57 ` Al Viro
2010-01-18 4:21 ` Ian Kent
2010-01-18 5:59 ` Al Viro
2010-01-18 9:14 ` Ian Kent
2010-01-18 10:27 ` Al Viro
2010-01-18 19:35 ` Trond Myklebust
2010-01-19 7:05 ` Ian Kent
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=1261611423-4396-2-git-send-email-vaurora@redhat.com \
--to=vaurora@redhat.com \
--cc=autofs@linux.kernel.org \
--cc=jblunck@suse.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=raven@themaw.net \
--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).