All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.16 01/52] NFS: change nfs_access_get_cached to only report the mask
@ 2022-02-03 20:28 Sasha Levin
  2022-02-03 20:28 ` [PATCH AUTOSEL 5.16 02/52] NFSv4 only print the label when its queried Sasha Levin
                   ` (50 more replies)
  0 siblings, 51 replies; 74+ messages in thread
From: Sasha Levin @ 2022-02-03 20:28 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: NeilBrown, Anna Schumaker, Sasha Levin, trond.myklebust,
	anna.schumaker, linux-nfs

From: NeilBrown <neilb@suse.de>

[ Upstream commit b5e7b59c3480f355910f9d2c6ece5857922a5e54 ]

Currently the nfs_access_get_cached family of functions report a
'struct nfs_access_entry' as the result, with both .mask and .cred set.
However the .cred is never used.  This is probably good and there is no
guarantee that it won't be freed before use.

Change to only report the 'mask' - as this is all that is used or needed.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/nfs/dir.c           | 20 +++++++++-----------
 fs/nfs/nfs4proc.c      | 18 +++++++++---------
 include/linux/nfs_fs.h |  4 ++--
 3 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 731d31015b6aa..8487a6d691167 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2673,7 +2673,7 @@ static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, co
 	return NULL;
 }
 
-static int nfs_access_get_cached_locked(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res, bool may_block)
+static int nfs_access_get_cached_locked(struct inode *inode, const struct cred *cred, u32 *mask, bool may_block)
 {
 	struct nfs_inode *nfsi = NFS_I(inode);
 	struct nfs_access_entry *cache;
@@ -2703,8 +2703,7 @@ static int nfs_access_get_cached_locked(struct inode *inode, const struct cred *
 		spin_lock(&inode->i_lock);
 		retry = false;
 	}
-	res->cred = cache->cred;
-	res->mask = cache->mask;
+	*mask = cache->mask;
 	list_move_tail(&cache->lru, &nfsi->access_cache_entry_lru);
 	err = 0;
 out:
@@ -2716,7 +2715,7 @@ static int nfs_access_get_cached_locked(struct inode *inode, const struct cred *
 	return -ENOENT;
 }
 
-static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res)
+static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cred, u32 *mask)
 {
 	/* Only check the most recently returned cache entry,
 	 * but do it without locking.
@@ -2738,22 +2737,21 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre
 		goto out;
 	if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS))
 		goto out;
-	res->cred = cache->cred;
-	res->mask = cache->mask;
+	*mask = cache->mask;
 	err = 0;
 out:
 	rcu_read_unlock();
 	return err;
 }
 
-int nfs_access_get_cached(struct inode *inode, const struct cred *cred, struct
-nfs_access_entry *res, bool may_block)
+int nfs_access_get_cached(struct inode *inode, const struct cred *cred,
+			  u32 *mask, bool may_block)
 {
 	int status;
 
-	status = nfs_access_get_cached_rcu(inode, cred, res);
+	status = nfs_access_get_cached_rcu(inode, cred, mask);
 	if (status != 0)
-		status = nfs_access_get_cached_locked(inode, cred, res,
+		status = nfs_access_get_cached_locked(inode, cred, mask,
 		    may_block);
 
 	return status;
@@ -2874,7 +2872,7 @@ static int nfs_do_access(struct inode *inode, const struct cred *cred, int mask)
 
 	trace_nfs_access_enter(inode);
 
-	status = nfs_access_get_cached(inode, cred, &cache, may_block);
+	status = nfs_access_get_cached(inode, cred, &cache.mask, may_block);
 	if (status == 0)
 		goto out_cached;
 
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ee3bc79f6ca3a..322ff45ad15ca 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -7611,7 +7611,7 @@ static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler,
 				    const char *key, const void *buf,
 				    size_t buflen, int flags)
 {
-	struct nfs_access_entry cache;
+	u32 mask;
 	int ret;
 
 	if (!nfs_server_capable(inode, NFS_CAP_XATTR))
@@ -7626,8 +7626,8 @@ static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler,
 	 * do a cached access check for the XA* flags to possibly avoid
 	 * doing an RPC and getting EACCES back.
 	 */
-	if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) {
-		if (!(cache.mask & NFS_ACCESS_XAWRITE))
+	if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) {
+		if (!(mask & NFS_ACCESS_XAWRITE))
 			return -EACCES;
 	}
 
@@ -7648,14 +7648,14 @@ static int nfs4_xattr_get_nfs4_user(const struct xattr_handler *handler,
 				    struct dentry *unused, struct inode *inode,
 				    const char *key, void *buf, size_t buflen)
 {
-	struct nfs_access_entry cache;
+	u32 mask;
 	ssize_t ret;
 
 	if (!nfs_server_capable(inode, NFS_CAP_XATTR))
 		return -EOPNOTSUPP;
 
-	if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) {
-		if (!(cache.mask & NFS_ACCESS_XAREAD))
+	if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) {
+		if (!(mask & NFS_ACCESS_XAREAD))
 			return -EACCES;
 	}
 
@@ -7680,13 +7680,13 @@ nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len)
 	ssize_t ret, size;
 	char *buf;
 	size_t buflen;
-	struct nfs_access_entry cache;
+	u32 mask;
 
 	if (!nfs_server_capable(inode, NFS_CAP_XATTR))
 		return 0;
 
-	if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) {
-		if (!(cache.mask & NFS_ACCESS_XALIST))
+	if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) {
+		if (!(mask & NFS_ACCESS_XALIST))
 			return 0;
 	}
 
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 05f249f20f55d..f33559acbcc28 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -533,8 +533,8 @@ extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh,
 			struct nfs_fattr *fattr);
 extern int nfs_may_open(struct inode *inode, const struct cred *cred, int openflags);
 extern void nfs_access_zap_cache(struct inode *inode);
-extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred, struct nfs_access_entry *res,
-				 bool may_block);
+extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred,
+				 u32 *mask, bool may_block);
 
 /*
  * linux/fs/nfs/symlink.c
-- 
2.34.1


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

end of thread, other threads:[~2022-02-11 14:42 UTC | newest]

Thread overview: 74+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03 20:28 [PATCH AUTOSEL 5.16 01/52] NFS: change nfs_access_get_cached to only report the mask Sasha Levin
2022-02-03 20:28 ` [PATCH AUTOSEL 5.16 02/52] NFSv4 only print the label when its queried Sasha Levin
2022-02-03 20:28 ` [PATCH AUTOSEL 5.16 03/52] nfs: nfs4clinet: check the return value of kstrdup() Sasha Levin
2022-02-03 20:28 ` [PATCH AUTOSEL 5.16 04/52] NFSv4.1: Fix uninitialised variable in devicenotify Sasha Levin
2022-02-03 20:28 ` [PATCH AUTOSEL 5.16 05/52] netfilter: nf_conntrack_netbios_ns: fix helper module alias Sasha Levin
2022-02-03 21:46   ` Jakub Kicinski
2022-02-03 22:23     ` Florian Westphal
2022-02-11 14:41       ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 06/52] NFSv4 remove zero number of fs_locations entries error check Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 07/52] NFSv4 store server support for fs_location attribute Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 08/52] NFSv4.1 query for fs_location attr on a new file system Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 09/52] NFSv4 expose nfs_parse_server_name function Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 10/52] NFSv4 handle port presence in fs_location server string Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 11/52] SUNRPC allow for unspecified transport time in rpc_clnt_add_xprt Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 12/52] net/sunrpc: fix reference count leaks in rpc_sysfs_xprt_state_change Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 13/52] sunrpc: Fix potential race conditions in rpc_sysfs_xprt_state_change() Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 14/52] irqchip/realtek-rtl: Service all pending interrupts Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 15/52] perf/x86/rapl: fix AMD event handling Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 16/52] x86/perf: Avoid warning for Arch LBR without XSAVE Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 17/52] sched/pelt: Relax the sync of runnable_sum with runnable_avg Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 18/52] sched: Avoid double preemption in __cond_resched_*lock*() Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 19/52] drm/vc4: Fix deadlock on DSI device attach error Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 20/52] drm: panel-orientation-quirks: Add quirk for the 1Netbook OneXPlayer Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 21/52] net: sched: Clarify error message when qdisc kind is unknown Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 22/52] powerpc/fixmap: Fix VM debug warning on unmap Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 23/52] s390/module: test loading modules with a lot of relocations Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 24/52] arm64: Add Cortex-X2 CPU part definition Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 25/52] arm64: errata: Update ARM64_ERRATUM_[2119858|2224489] with Cortex-X2 ranges Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 26/52] scsi: target: iscsi: Make sure the np under each tpg is unique Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 27/52] scsi: ufs: ufshcd-pltfrm: Check the return value of devm_kstrdup() Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 28/52] scsi: qedf: Add stag_work to all the vports Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 29/52] scsi: qedf: Fix refcount issue when LOGO is received during TMF Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 30/52] scsi: qedf: Change context reset messages to ratelimited Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 31/52] scsi: pm8001: Fix bogus FW crash for maxcpus=1 Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 32/52] scsi: ufs: Use generic error code in ufshcd_set_dev_pwr_mode() Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 33/52] scsi: ufs: Treat link loss as fatal error Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 34/52] scsi: myrs: Fix crash in error case Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 35/52] net: stmmac: reduce unnecessary wakeups from eee sw timer Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 36/52] PM: wakeup: simplify the output logic of pm_show_wakelocks() Sasha Levin
2022-02-04  8:29   ` Greg Kroah-Hartman
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 37/52] PM: hibernate: Remove register_nosave_region_late() Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 38/52] drm/amd/display: Correct MPC split policy for DCN301 Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 39/52] drm/amdgpu/display: adjust msleep limit in dp_wait_for_training_aux_rd_interval Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 40/52] drm/amdgpu/display: use msleep rather than udelay for long delays Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 41/52] usb: dwc2: gadget: don't try to disable ep0 in dwc2_hsotg_suspend Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 42/52] perf: Always wake the parent event Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 43/52] nvme-pci: add the IGNORE_DEV_SUBNQN quirk for Intel P4500/P4600 SSDs Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 44/52] MIPS: Fix build error due to PTR used in more places Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 45/52] net: stmmac: dwmac-sun8i: use return val of readl_poll_timeout() Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 46/52] arm64: Add Cortex-A510 CPU part definition Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 47/52] arm64: errata: Add detection for TRBE ignored system register writes Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 48/52] arm64: errata: Add detection for TRBE invalid prohibited states Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 49/52] arm64: errata: Add detection for TRBE trace data corruption Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 50/52] arm64: cpufeature: List early Cortex-A510 parts as having broken dbm Sasha Levin
2022-02-03 20:29   ` Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 51/52] block: add bio_start_io_acct_time() to control start_time Sasha Levin
2022-02-03 20:29 ` [PATCH AUTOSEL 5.16 52/52] kasan: test: fix compatibility with FORTIFY_SOURCE Sasha Levin

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.