From patchwork Sun Jan 26 22:31:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11351981 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8BD61580 for ; Sun, 26 Jan 2020 22:33:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C11C62071E for ; Sun, 26 Jan 2020 22:33:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mzAEGXl8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726703AbgAZWd1 (ORCPT ); Sun, 26 Jan 2020 17:33:27 -0500 Received: from mail-yb1-f193.google.com ([209.85.219.193]:36965 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgAZWd0 (ORCPT ); Sun, 26 Jan 2020 17:33:26 -0500 Received: by mail-yb1-f193.google.com with SMTP id o199so4082062ybc.4 for ; Sun, 26 Jan 2020 14:33:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=201xjImaASiL/S3OCOy34vVYWoLo+clrKIFQeL/lNoY=; b=mzAEGXl8WIQKO8ddD1GcxWZAKSe6H5WkGJZpIAR/1eNt8CCmqD+1B1jS+UPypdzOdO tZWtw2j6O9KBJI5A54IjD4D7LMuG8YWzGN8NgGrPcNKIg91mQrBqLi9EUbAFV5QNNzvC QNcR/1PxqUXGs5Hk/06pGZyrcrFUHkLATNuLcYF05Hr6131WV1gWdR2TlTKAfSpNE82a 7MRubDSTsxxrKD8N2r5x6K6Mq6gx94PonpbsjcSl1eI4/S3Nw/N2yfFFQCuwMBq8mBaJ jBTP+M8x9a9RWKG7yQ0zeLKXdYKfuxd3rYVuHSO49ZwL0c2QVAXfHiAlASIVJaMZmDHS VC0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=201xjImaASiL/S3OCOy34vVYWoLo+clrKIFQeL/lNoY=; b=QZRIN9XYuNwHTRSKgHOtnLNMxMXfIThfZg4EPC0g/fDBszWIAsn0qlyJwx2q9OkhAc Himkq8XD5qaLg+mGmll12K9tWLPPjzh3qRJCaOj6uw38XDC62eotbV3qlU6Bk2+PQ46i PNiWd8sz1Q+2sd8JpreN1Tv0fT2uzfznoUockYQ0d/tabX08Kiqhuc/G1ApKG1d5Z5TH b/8UuRxprnQcq+Kz3cLW2lysFGkkRBvfxosQTYUckqTJdEtMD+vbbbr65UwCpHZLPmE5 5CDBKmF9UJRkogSAEEXSTRIql5A6irTM/YlrLbNmzU+uYU5X9Wfw4MgKO449uc5TwAZR mrnA== X-Gm-Message-State: APjAAAWsesNt7T1ZvSZVy1ht5zIGdjDFg0gslA0Vq9hyr3/hWsWBOZv7 Hap7PXwmWe3mN4szhPncjfpV5VIgZg== X-Google-Smtp-Source: APXvYqyp7Qy4ziU/wqw/fEUsMyDu8fY5Xq7K1UWXd5JYZOp+QFIhebwt0gxj7FTvPzDvmMkz2hZszA== X-Received: by 2002:a25:ab07:: with SMTP id u7mr10701417ybi.308.1580078005838; Sun, 26 Jan 2020 14:33:25 -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 d66sm4233951ywc.16.2020.01.26.14.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 14:33:25 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/3] NFSv4: pnfs_roc() must use cred_fscmp() to compare creds Date: Sun, 26 Jan 2020 17:31:13 -0500 Message-Id: <20200126223115.40476-1-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When comparing two 'struct cred' for equality w.r.t. behaviour under filesystem access, we need to use cred_fscmp(). Fixes: a52458b48af1 ("NFS/NFSD/SUNRPC: replace generic creds with 'struct cred'.") Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index cec3070ab577..39bbc335679e 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1425,7 +1425,7 @@ bool pnfs_roc(struct inode *ino, /* lo ref dropped in pnfs_roc_release() */ layoutreturn = pnfs_prepare_layoutreturn(lo, &stateid, &iomode); /* If the creds don't match, we can't compound the layoutreturn */ - if (!layoutreturn || cred != lo->plh_lc_cred) + if (!layoutreturn || cred_fscmp(cred, lo->plh_lc_cred) != 0) goto out_noroc; roc = layoutreturn; From patchwork Sun Jan 26 22:31:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11351983 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7A72139A for ; Sun, 26 Jan 2020 22:33:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9608620716 for ; Sun, 26 Jan 2020 22:33:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sAF5t3bH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727107AbgAZWd2 (ORCPT ); Sun, 26 Jan 2020 17:33:28 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:36904 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgAZWd1 (ORCPT ); Sun, 26 Jan 2020 17:33:27 -0500 Received: by mail-yw1-f68.google.com with SMTP id l5so3919931ywd.4 for ; Sun, 26 Jan 2020 14:33:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=70ZBGN+N/QUee/VfGr8lfobsKfqqRkcAwoqpkBMlYD8=; b=sAF5t3bHuqvI4mWymCyDyvdaY5KJjvEg/mn+nx9E7FI5mUAo/XYdjQ4Ayj62YLqBLq VJZfD9HBGdq/aV/aMb9OzWdFJqSDObTSfHKj5v6uiHEEboXo5fDBChaGKV4RPcIDdogD OV5mvzmGP4EY5l78G3sW4U9WnjESXb1JJfwxNkDXXyjiTdixzheIgt1/rq0WaUNJy/2Z Pn43mx4vTn1oH203d2TwG0MuRby6GCILmGqWet8LyoSo0qMeoEn5cfMbmxBQ1ha0Lfsk YGCaI/bPj0xQimCNmTU8DWZiu8siZdIqRGrGeEjhZFDdctdAhHucYrG5wMLkyOAt5+YD rAXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=70ZBGN+N/QUee/VfGr8lfobsKfqqRkcAwoqpkBMlYD8=; b=ocIxNL+qa8rQ7iOhQ7z3aWVQ6DiSW9/HB8iXGgusJ5W+2C91AHJ+xEOjrOndVulUBU woGycqypsXEvo/jQLPbUaGTQOV9jKfuP4rGiuIANRQyHMi+Nub8j1OFm7uprjlfrDtK+ rAk+0u2oh7LoNMFbuUt86rW7qAqhq2kVFMDXL74g7Wgl7KaxgPB8N+15EnaKShT4rraU lnJlX3OVVXms2oRce8vTaMrXSg4yfyz0QV+Nqm1F39qtfJlRtW0B6eC6GA1kL1LqS7yd 3FlxMgSdzCIfWrj8K8HerLbCmnU/LpLki6FJ3ulpp1bTo+DrYhxoxFKjgf8e9GGQ411S ua+A== X-Gm-Message-State: APjAAAVoKinElzZZyyCDcxsxTJBKVEicVL8yUpy7vDt9QdFTjXUEoAfG yg3GjJ+K88Mn4xHVH5+gXQ== X-Google-Smtp-Source: APXvYqwW/2blSiG3geVJaytpEAF9cH/IbwaYOXd7+k6mUQRDJQj9OspXxlozhAyH7ZhKrBunmJGmCQ== X-Received: by 2002:a0d:ffc2:: with SMTP id p185mr9968268ywf.256.1580078006842; Sun, 26 Jan 2020 14:33:26 -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 d66sm4233951ywc.16.2020.01.26.14.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 14:33:26 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/3] NFS: nfs_access_get_cached_rcu() should use cred_fscmp() Date: Sun, 26 Jan 2020 17:31:14 -0500 Message-Id: <20200126223115.40476-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200126223115.40476-1-trond.myklebust@hammerspace.com> References: <20200126223115.40476-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org We do not need to have the rcu lookup method fail in the case where the fsuid/fsgid and supplemental groups match. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index bfc66f3f00e1..6427a8a8d61a 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2360,7 +2360,7 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre lh = rcu_dereference(nfsi->access_cache_entry_lru.prev); cache = list_entry(lh, struct nfs_access_entry, lru); if (lh == &nfsi->access_cache_entry_lru || - cred != cache->cred) + cred_fscmp(cred, cache->cred) != 0) cache = NULL; if (cache == NULL) goto out; From patchwork Sun Jan 26 22:31:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11351985 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A94E4139A for ; Sun, 26 Jan 2020 22:33:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 885112071E for ; Sun, 26 Jan 2020 22:33:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="raPfpYXh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727166AbgAZWd3 (ORCPT ); Sun, 26 Jan 2020 17:33:29 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:43301 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgAZWd2 (ORCPT ); Sun, 26 Jan 2020 17:33:28 -0500 Received: by mail-yw1-f67.google.com with SMTP id v126so3901809ywc.10 for ; Sun, 26 Jan 2020 14:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s9RDIMLtbcWBx2VkDk/Gm5VggXtsfniEimljSxvmt64=; b=raPfpYXhUyVn721GT0PtXDe0UKqvSpmUcd/mqbT+zs7JZLs9Swyi9IENCXQlcVmfwa pX9WgIaTR4hFQUgfD/mLN/i22IyM1Pay8puKrECiUbjsYGUPUzYqVeRS6hLIrSfb0GDY ovv7d1EkiPvnGaJTMCLyQ5Q97Q2hesjl/2Uxr7MHG/ewI47YoJTxWkUJvDUMe7VT3N7q SSm9tWJ24uoxWKzxW1YukU8wiM3XFM9AJYcjye0O2it5FWplJ1BnncPUDtIIyxQffpS+ Z5hGc9qB2khbSWlkJJesWffiA9cJ/Jgd8zz1g+JYwOEEInaOkCGTR37D7pB3Pp//bYOB C7ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s9RDIMLtbcWBx2VkDk/Gm5VggXtsfniEimljSxvmt64=; b=BuygqcK1Fo7G6P8TCIdg6KMwvJHrrRiEgZu9EEhX8fx41bG1LjzleoXpvMWnCgrOwJ fb6eLKUmoMQJfqFX9BNryyKLki/pqtE7aGd3omedzvSkcf5dESJNiWzHASN7zTGP9BVz jsOAN4jsgB1Cb2f2/EzRfHPBi7pCNwyIA6X0ZCiy5f6sQhz+j4LTt9yJntQsvPqgyRCm 6oWkYCqEtjVqUkt+1yCeFtjcsa7ZnJ0TP1OITj4QUT0T6PdUWhaFLL4TLv+Pe0fT6Zt6 0Jq/WlgxDTYAZJjPixc2+WIxFHZX6N2Ma/8+LvZVWXxudbGUKJg3U/tiSgKokuG3tA/B 2oJQ== X-Gm-Message-State: APjAAAXGmKCUesf2aJM33nseEIsFYPPE5CNANyWtv8TlOzhbx6XU4ZzA y/vd15oQd+HAqpsHOEFOoQ== X-Google-Smtp-Source: APXvYqx7yl4w7uYCr08OEXeCrYC7wOQKZ3jkptor4XU6voFbc/Uuy8TMZWbRT2OKK1fECrPvnfsAUw== X-Received: by 2002:a81:a00a:: with SMTP id x10mr9984648ywg.475.1580078007765; Sun, 26 Jan 2020 14:33:27 -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 d66sm4233951ywc.16.2020.01.26.14.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jan 2020 14:33:27 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 3/3] NFS: nfs_find_open_context() should use cred_fscmp() Date: Sun, 26 Jan 2020 17:31:15 -0500 Message-Id: <20200126223115.40476-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200126223115.40476-2-trond.myklebust@hammerspace.com> References: <20200126223115.40476-1-trond.myklebust@hammerspace.com> <20200126223115.40476-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org We want to find open contexts that match our filesystem access properties. They don't have to exactly match the cred. Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 71dfc9d2fc3d..1309e6f47f3d 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1061,7 +1061,7 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct rcu_read_lock(); list_for_each_entry_rcu(pos, &nfsi->open_files, list) { - if (cred != NULL && pos->cred != cred) + if (cred != NULL && cred_fscmp(pos->cred, cred) != 0) continue; if ((pos->mode & (FMODE_READ|FMODE_WRITE)) != mode) continue;