Thread (2 messages) 2 messages, 2 authors, 2022-10-31
STALE1324d

[PATCH] nfsd: fix net-namespace logic in __nfsd_file_cache_purge

From: Jeff Layton <jlayton@kernel.org>
Date: 2022-10-31 15:36:03
Subsystem: filesystems (vfs and infrastructure), kernel nfsd, sunrpc, and lockd servers, the rest · Maintainers: Alexander Viro, Christian Brauner, Chuck Lever, Jeff Layton, Linus Torvalds

If the namespace doesn't match the one in "net", then we'll continue,
but that doesn't cause another rhashtable_walk_next call, so it will
loop infinitely.

Fixes: ce502f81ba88 ("NFSD: Convert the filecache to use rhashtable")
Reported-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nfsd/filecache.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

This should probably go to stable too.
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
index eeed4ae5b4ad..f9ea89057ae8 100644
--- a/fs/nfsd/filecache.c
+++ b/fs/nfsd/filecache.c
@@ -908,19 +908,17 @@ __nfsd_file_cache_purge(struct net *net)
 
 		nf = rhashtable_walk_next(&iter);
 		while (!IS_ERR_OR_NULL(nf)) {
-			if (net && nf->nf_net != net)
-				continue;
-			del = nfsd_file_unhash_and_dispose(nf, &dispose);
-
-			/*
-			 * Deadlock detected! Something marked this entry as
-			 * unhased, but hasn't removed it from the hash list.
-			 */
-			WARN_ON_ONCE(!del);
-
+			if (!net || nf->nf_net == net) {
+				del = nfsd_file_unhash_and_dispose(nf, &dispose);
+
+				/*
+				 * Deadlock detected! Something marked this entry as
+				 * unhased, but hasn't removed it from the hash list.
+				 */
+				WARN_ON_ONCE(!del);
+			}
 			nf = rhashtable_walk_next(&iter);
 		}
-
 		rhashtable_walk_stop(&iter);
 	} while (nf == ERR_PTR(-EAGAIN));
 	rhashtable_walk_exit(&iter);
-- 
2.38.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help