linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] NFSv4: pnfs_roc() must use cred_fscmp() to compare creds
@ 2020-01-26 22:31 Trond Myklebust
  2020-01-26 22:31 ` [PATCH 2/3] NFS: nfs_access_get_cached_rcu() should use cred_fscmp() Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2020-01-26 22:31 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: linux-nfs

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 <trond.myklebust@hammerspace.com>
---
 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;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] NFS: nfs_access_get_cached_rcu() should use cred_fscmp()
  2020-01-26 22:31 [PATCH 1/3] NFSv4: pnfs_roc() must use cred_fscmp() to compare creds Trond Myklebust
@ 2020-01-26 22:31 ` Trond Myklebust
  2020-01-26 22:31   ` [PATCH 3/3] NFS: nfs_find_open_context() " Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2020-01-26 22:31 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: linux-nfs

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 <trond.myklebust@hammerspace.com>
---
 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;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] NFS: nfs_find_open_context() should use cred_fscmp()
  2020-01-26 22:31 ` [PATCH 2/3] NFS: nfs_access_get_cached_rcu() should use cred_fscmp() Trond Myklebust
@ 2020-01-26 22:31   ` Trond Myklebust
  0 siblings, 0 replies; 3+ messages in thread
From: Trond Myklebust @ 2020-01-26 22:31 UTC (permalink / raw)
  To: Anna Schumaker; +Cc: linux-nfs

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 <trond.myklebust@hammerspace.com>
---
 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;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-26 22:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-26 22:31 [PATCH 1/3] NFSv4: pnfs_roc() must use cred_fscmp() to compare creds Trond Myklebust
2020-01-26 22:31 ` [PATCH 2/3] NFS: nfs_access_get_cached_rcu() should use cred_fscmp() Trond Myklebust
2020-01-26 22:31   ` [PATCH 3/3] NFS: nfs_find_open_context() " Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).