From patchwork Wed Feb 22 13:36:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 9586845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4BB0D602A7 for ; Wed, 22 Feb 2017 13:36:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D6D82869B for ; Wed, 22 Feb 2017 13:36:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 116EC286C2; Wed, 22 Feb 2017 13:36:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85F262869B for ; Wed, 22 Feb 2017 13:36:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754689AbdBVNgh (ORCPT ); Wed, 22 Feb 2017 08:36:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56910 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754652AbdBVNgf (ORCPT ); Wed, 22 Feb 2017 08:36:35 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F2FDC054C31; Wed, 22 Feb 2017 13:36:35 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-66.rdu2.redhat.com [10.10.120.66] (may be forged)) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1MDaXB2031510; Wed, 22 Feb 2017 08:36:34 -0500 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH] vfs: Partially revert addition of cred override in follow_automount() From: David Howells To: viro@ZenIV.linux.org.uk Cc: linux-kernel@vger.kernel.org, dhowells@redhat.com, Seth Forshee , "Eric W. Biederman" , linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org Date: Wed, 22 Feb 2017 13:36:32 +0000 Message-ID: <148777059228.7183.7698026974948697349.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 22 Feb 2017 13:36:35 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The following commit: commit aeaa4a79ff6a5ed912b7362f206cf8576fca538b Author: Eric W. Biederman 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 cc: Seth Forshee cc: "Eric W. Biederman" cc: Al Viro --- 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