Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4048005ybv; Mon, 10 Feb 2020 11:16:24 -0800 (PST) X-Google-Smtp-Source: APXvYqy4V/mqG9pSFOkPBrDwhrFjzUxOU92CAzMNOsvkk/HSiUaXhRfQFRbrUe0BvTb5DzGEeQ/L X-Received: by 2002:a05:6830:612:: with SMTP id w18mr2242217oti.160.1581362183864; Mon, 10 Feb 2020 11:16:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581362183; cv=none; d=google.com; s=arc-20160816; b=uw5PSrjuC6yZKzqm4Y6kbet2TG/SS9Yboe5QSeqep7nSUvIZQOJUhDnWHpxjH0GqQ2 SQJdluQVzrKmG2JGgK43syO7tHZjyETuWZHLihOfHlmmdJl/A6zKFehKShLzxEYVUIpk oZFBDQIx4cwjaK8b/T4EWahMRsPN93DQEY041l+Z++tBQaKLpZuS9tLf/T2vO1ThDJ1n Qpx3zc6ecH7WojOT95MNQIm3fhPFlojOl9CWNIGdsgXaLpS6esKqUexj4egZNKHLQGrs S7xv5cyvwD6QhkEFvvRL2bBwZaNGc+5S+tztdzXSoxh42HDCy6A5ho8GOG+RWDAEMFNL 9HWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FgobD3V7uuOy4LVGAx9rHhnWTaPqCxK05Vocd+6bvMM=; b=qkV37p2Qo4L/kjd0zH+dsJsOem0mvOWhX4QEOnDEgjbQOQcO0Ays6szBFnw81P6iDS UyuCnShf1+/X6t+PBOcfSv9k5FI5qXoD6JNwPO81YWW+50eS6Gz7vefw0/mZpY+vNnk7 z4hJ6NESiYyI+lIRRZs3v28wYFzF8iJw0lwBLUFqEMqeMOLX0yjJ1mEnL1ckyQDqnPNn 1k/SfmP8A2YOfAW2pHQxgEikGYZn7O/1L3GX1d9p+7K6fKZxqe0mrl1xePbwO2KXKZDt JfMJxNbuoC0fb0U87Zb6yAnzur5raOvghKEmAgvSIa/apcOmWog9Vt6Ophpru+hqU+7B uchg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fcApY0O2; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si507360oii.42.2020.02.10.11.16.11; Mon, 10 Feb 2020 11:16:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fcApY0O2; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727538AbgBJTQH (ORCPT + 99 others); Mon, 10 Feb 2020 14:16:07 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:36054 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727029AbgBJTQG (ORCPT ); Mon, 10 Feb 2020 14:16:06 -0500 Received: by mail-yb1-f195.google.com with SMTP id q190so1109437ybg.3 for ; Mon, 10 Feb 2020 11:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FgobD3V7uuOy4LVGAx9rHhnWTaPqCxK05Vocd+6bvMM=; b=fcApY0O2/E2Jfj+xceGJmVwXJ+4x+C6qxz9vcSb2EPwUJfz7bbsS7ojqVLfklGfHss qyanx1f17n9q5CKjoFdjk/A0PgiG+rDaTVSUgBanZUYSKmui9TSFJtmK4r3ojvDoCnnm 1qdIqW3gaCXTbGJE/uVe94DvlG6w8HOzaIrc3H7SrXW9YCK7hkQw3L0RMhMEmQ85x8WM B6r1Hnwhay9EEZkn29iAH2/FzLDzfipIuLNZtxQUiGW3OtomlujnZXoTb8soneL/7/7E 8WUGs8vPWl3wxBaQJjTLZHl4gHjh85Y8Lm5lZ/gXwqGth9enk36Lt0eQTgXyP+xkgBmj mg2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FgobD3V7uuOy4LVGAx9rHhnWTaPqCxK05Vocd+6bvMM=; b=S+cwcHqqTIbZCOQuvg+FyQBMbb6SyoEdPbNtrAxdLPBzFFsJJRsQgbbHd1viIWJGPv RZ6IX1fTM6OKqWtkkPuWRQcbzVAoHqZ9IDS7uKX+sAX8ECeqDAr1Kd5cvaPpwUlT+23z aUR6Y5je0y7jgT3Im4/U4B6+FbjdW+Hr2fzLHpKZK1dV2zQTE6hlInQ0fIibBMNwv7UB m92hZlbFllokt9q8gywx3Ka3Xsew89Ipd2fwsrRuKOOviU+BrvnGlgN8SVjnfuq2gw6a 5LydWg9N8VUIemuQHA0uaWsOLUpvpNVE1dF2V5sGFZeno2tiaIiyeghiEqyk+/TiUT8V i/qw== X-Gm-Message-State: APjAAAVp1AL0k6mLsj6hFM8gfoWT5ZHBmw9J5lTV8pg+MNFMr0eCcVFm 2cLXD7oQB3s+rgedGo+exUtV8+N/gA== X-Received: by 2002:a5b:384:: with SMTP id k4mr2833453ybp.305.1581362165736; Mon, 10 Feb 2020 11:16:05 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o4sm660222ywd.5.2020.02.10.11.16.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 11:16:05 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 1/8] NFS: alloc_nfs_open_context() must use the file cred when available Date: Mon, 10 Feb 2020 14:13:38 -0500 Message-Id: <20200210191345.557460-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200210191345.557460-1-trond.myklebust@hammerspace.com> References: <20200210191345.557460-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If we're creating a nfs_open_context() for a specific file pointer, we must use the cred assigned to that file. Fixes: a52458b48af1 ("NFS/NFSD/SUNRPC: replace generic creds with 'struct cred'.") Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 11bf15800ac9..a10fb87c6ac3 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -959,16 +959,16 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct file *filp) { struct nfs_open_context *ctx; - const struct cred *cred = get_current_cred(); ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); - if (!ctx) { - put_cred(cred); + if (!ctx) return ERR_PTR(-ENOMEM); - } nfs_sb_active(dentry->d_sb); ctx->dentry = dget(dentry); - ctx->cred = cred; + if (filp) + ctx->cred = get_cred(filp->f_cred); + else + ctx->cred = get_current_cred(); ctx->ll_cred = NULL; ctx->state = NULL; ctx->mode = f_mode; -- 2.24.1