From: ebiederm@xmission.com (Eric W. Biederman)
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
jamie@shareable.org, pavel@ucw.cz, miklos@szeredi.hu,
viro@ZenIV.linux.org.uk, duaneg@dghda.com
Subject: Re: [PATCH 1/2] vfs: force reval of target when following LAST_BIND symlinks
Date: Wed, 02 Dec 2009 15:53:42 -0800 [thread overview]
Message-ID: <m1zl61q6ex.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <1259783983-26884-2-git-send-email-jlayton@redhat.com> (Jeff Layton's message of "Wed\, 2 Dec 2009 14\:59\:42 -0500")
Jeff Layton <jlayton@redhat.com> writes:
> procfs-style symlinks return a last_type of LAST_BIND without an actual
> path string. This causes __follow_link to skip calling __vfs_follow_link
> and so the dentry isn't revalidated.
>
> This is a problem when the link target sits on NFSv4 as it depends on
> the VFS to revalidate the dentry before using it on an open call. Ensure
> that this occurs by forcing a revalidation of the target dentry of
> LAST_BIND symlinks.
This seems reasonable to me, and in a quick run through I can't see any
problems.
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> fs/namei.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 45 insertions(+), 0 deletions(-)
>
> diff --git a/fs/namei.c b/fs/namei.c
> index 3374917..339789e 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -414,6 +414,46 @@ do_revalidate(struct dentry *dentry, struct nameidata *nd)
> }
>
> /*
> + * force_reval_path - force revalidation of a dentry
> + *
> + * In some situations the path walking code will trust dentries without
> + * revalidating them. This causes problems for filesystems that depend on
> + * d_revalidate to handle file opens (e.g. NFSv4). When FS_REVAL_DOT is set
> + * (which indicates that it's possible for the dentry to go stale), force
> + * a d_revalidate call before proceeding.
> + *
> + * Returns 0 if the revalidation was successful. If the revalidation fails,
> + * either return the error returned by d_revalidate or -ESTALE if the
> + * revalidation it just returned 0. If d_revalidate returns 0, we attempt to
> + * invalidate the dentry. It's up to the caller to handle putting references
> + * to the path if necessary.
> + */
> +static int
> +force_reval_path(struct path *path, struct nameidata *nd)
> +{
> + int status;
> + struct dentry *dentry = path->dentry;
> +
> + /*
> + * only check on filesystems where it's possible for the dentry to
> + * become stale. It's assumed that if this flag is set then the
> + * d_revalidate op will also be defined.
> + */
> + if (!(dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT))
> + return 0;
> +
> + status = dentry->d_op->d_revalidate(dentry, nd);
> + if (status > 0)
> + return 0;
> +
> + if (!status) {
> + d_invalidate(dentry);
> + status = -ESTALE;
> + }
> + return status;
> +}
> +
> +/*
> * Internal lookup() using the new generic dcache.
> * SMP-safe
> */
> @@ -641,6 +681,11 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata
> error = 0;
> if (s)
> error = __vfs_follow_link(nd, s);
> + else if (nd->last_type == LAST_BIND) {
> + error = force_reval_path(&nd->path, nd);
> + if (error)
> + path_put(&nd->path);
> + }
> if (dentry->d_inode->i_op->put_link)
> dentry->d_inode->i_op->put_link(dentry, nd, cookie);
> }
> --
> 1.5.5.6
next prev parent reply other threads:[~2009-12-02 23:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-02 19:59 [PATCH 0/2] vfs: plug some holes involving LAST_BIND symlinks and file bind mounts (try #6) Jeff Layton
2009-12-02 19:59 ` [PATCH 1/2] vfs: force reval of target when following LAST_BIND symlinks Jeff Layton
2009-12-02 23:53 ` Eric W. Biederman [this message]
2009-12-03 10:39 ` Miklos Szeredi
2009-12-02 19:59 ` [PATCH 2/2] vfs: force reval on dentry of bind mounted files on FS_REVAL_DOT filesystems Jeff Layton
2009-12-03 0:01 ` Eric W. Biederman
2009-12-03 1:23 ` Jeff Layton
2009-12-03 10:58 ` Miklos Szeredi
2009-12-03 11:11 ` Eric W. Biederman
2009-12-03 11:19 ` Miklos Szeredi
2009-12-03 11:56 ` Eric W. Biederman
2009-12-03 15:21 ` Miklos Szeredi
2009-12-03 15:20 ` Jeff Layton
2009-12-03 18:35 ` Eric W. Biederman
2009-12-03 19:15 ` Jeff Layton
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=m1zl61q6ex.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=duaneg@dghda.com \
--cc=jamie@shareable.org \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=pavel@ucw.cz \
--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