All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: viro@ZenIV.linux.org.uk
Cc: linux-kernel@vger.kernel.org, dhowells@redhat.com,
	Seth Forshee <seth.forshee@canonical.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org
Subject: [PATCH] vfs: Partially revert addition of cred override in follow_automount()
Date: Wed, 22 Feb 2017 13:36:32 +0000	[thread overview]
Message-ID: <148777059228.7183.7698026974948697349.stgit@warthog.procyon.org.uk> (raw)

The following commit:

	commit aeaa4a79ff6a5ed912b7362f206cf8576fca538b
	Author: Eric W. Biederman <ebiederm@xmission.com>
	Date:   Sat Jul 23 11:20:44 2016 -0500
	fs: Call d_automount with the filesystems creds

brackets the call to ->d_automount() with override_creds() and
revert_creds(), setting the initial credentials for use whilst
automounting.

This, however, breaks AFS as it's no longer able to access the calling
process's keyrings to read the destination on a mountpoint.  This has gone
unnoticed till now because, to this point, stat'ing or validating the inode
caused the body of the mountpoint to be read into the pagecache (so that we
could determine whether what we were looking at was really a mountpoint).

However, the page containing the mountpoint destination is merely *cached*
and not pinned.  If it gets discarded and we try to read it in d_automount,
we may fail because we have no authentication tokens available.

So, for the moment, revert the addition of override_creds() and
revert_creds() and their variable.

Fixes: aeaa4a79ff6a ("fs: Call d_automount with the filesystems creds")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Seth Forshee <seth.forshee@canonical.com>
cc: "Eric W. Biederman" <ebiederm@xmission.com>
cc: Al Viro <viro@ZenIV.linux.org.uk>
---

 fs/namei.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index ad74877e1442..dff5cd3b556f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1100,7 +1100,6 @@ static int follow_automount(struct path *path, struct nameidata *nd,
 			    bool *need_mntput)
 {
 	struct vfsmount *mnt;
-	const struct cred *old_cred;
 	int err;
 
 	if (!path->dentry->d_op || !path->dentry->d_op->d_automount)
@@ -1129,9 +1128,7 @@ static int follow_automount(struct path *path, struct nameidata *nd,
 	if (nd->total_link_count >= 40)
 		return -ELOOP;
 
-	old_cred = override_creds(&init_cred);
 	mnt = path->dentry->d_op->d_automount(path);
-	revert_creds(old_cred);
 	if (IS_ERR(mnt)) {
 		/*
 		 * The filesystem is allowed to return -EISDIR here to indicate

             reply	other threads:[~2017-02-22 13:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 13:36 David Howells [this message]
2017-02-22 15:17 ` [PATCH] vfs: Partially revert addition of cred override in follow_automount() David Howells
2017-02-22 15:17 ` Seth Forshee

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=148777059228.7183.7698026974948697349.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seth.forshee@canonical.com \
    --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 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.