Skip to contentSkip to conversation

nfsd: fix net-namespace logic in __nfsd_file_cache_purge

PATCH Applied Jeff Layton 4 participants 8 messages Oct 31, 2022 – Nov 9, 2022

Subsystems (3)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

PATCH v2 1/1 nfsd: fix net-namespace logic in __nfsd_file_cache_purge

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")
---
 fs/nfsd/filecache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

The v1 patch applies cleanly to v6.0, but not to Chuck's for-next branch. This one should be suitable there.

fs/nfsd/filecache.c +2 -3
index 98c6b5f51bc8..4a8aa7cd8354 100644
@@ -890,9 +890,8 @@ __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;
-			nfsd_file_unhash_and_dispose(nf, &dispose);
+			if (!net || nf->nf_net == net)
+				nfsd_file_unhash_and_dispose(nf, &dispose);
 			nf = rhashtable_walk_next(&iter);
 		}
 
Signature · 1 line
2.38.1
#1 lore raw
Quoted 8 lines · Jeff Layton

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.

Quoted 6 lines
Fixes ce502f81ba88 ("NFSD: Convert the filecache to use rhashtable")

---
fs/nfsd/filecache.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)

Thank you! Applied and pushed to for-rc. I'll send a PR in a few days.

Quoted 21 lines

The v1 patch applies cleanly to v6.0, but not to Chuck's for-next branch. This one should be suitable there.

fs/nfsd/filecache.c +2 -3
index 98c6b5f51bc8..4a8aa7cd8354 100644
@@ -890,9 +890,8 @@ __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;
-			nfsd_file_unhash_and_dispose(nf, &dispose);
+			if (!net || nf->nf_net == net)
+				nfsd_file_unhash_and_dispose(nf, &dispose);
 			nf = rhashtable_walk_next(&iter);
 		}
 
Signature · 1 line
2.38.1

--
Chuck Lever

#2 lore raw
Quoted 8 lines
Quoted 7 lines · Jeff Layton

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.

Quoted 8 lines
Quoted 6 lines
Fixes ce502f81ba88 ("NFSD: Convert the filecache to use rhashtable")

---
fs/nfsd/filecache.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)

Thank you! Applied and pushed to for-rc. I'll send a PR in a few days.

Thanks for a quick action!

What a shame you didn't put link to the report, which contains reproducer.
https://lore.kernel.org/ltp/Y1%2FP8gDAcWC%2F+VR3@pevik/

Kind regards,
Petr

Quoted 20 lines
Quoted 20 lines

The v1 patch applies cleanly to v6.0, but not to Chuck's for-next branch. This one should be suitable there.

fs/nfsd/filecache.c +2 -3
index 98c6b5f51bc8..4a8aa7cd8354 100644
@@ -890,9 +890,8 @@ __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;
-			nfsd_file_unhash_and_dispose(nf, &dispose);
+			if (!net || nf->nf_net == net)
+				nfsd_file_unhash_and_dispose(nf, &dispose);
 			nf = rhashtable_walk_next(&iter);
 		}
 
Signature · 1 line
2.38.1
author maintainer
#3 lore raw
Quoted 14 lines · Petr Vorel
Quoted 13 lines
Quoted 13 lines · Jeff Layton

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")

---
fs/nfsd/filecache.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 4 lines
Quoted 1 line

Thank you! Applied and pushed to for-rc. I'll send a PR in a few days.

Thanks for a quick action!

No problem.

Quoted 6 lines

What a shame you didn't put link to the report, which contains reproducer.
https://lore.kernel.org/ltp/Y1%2FP8gDAcWC%2F+VR3@pevik/

Kind regards,
Petr

Chuck, could you add that link to the changelog when you merge it?

Thanks,
Jeff

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

The v1 patch applies cleanly to v6.0, but not to Chuck's for-next branch. This one should be suitable there.

fs/nfsd/filecache.c +2 -3
index 98c6b5f51bc8..4a8aa7cd8354 100644
@@ -890,9 +890,8 @@ __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;
-			nfsd_file_unhash_and_dispose(nf, &dispose);
+			if (!net || nf->nf_net == net)
+				nfsd_file_unhash_and_dispose(nf, &dispose);
 			nf = rhashtable_walk_next(&iter);
 		}
 
Signature · 1 line
2.38.1
Signature · 1 line
Jeff Layton <[email protected]>
#4 lore raw
Quoted 26 lines · Jeff Layton
Quoted 14 lines · Petr Vorel
Quoted 13 lines
Quoted 13 lines · Jeff Layton

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")

---
fs/nfsd/filecache.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 4 lines
Quoted 1 line

Thank you! Applied and pushed to for-rc. I'll send a PR in a few days.

Thanks for a quick action!

No problem.

Quoted 8 lines
Quoted 6 lines

What a shame you didn't put link to the report, which contains reproducer.
https://lore.kernel.org/ltp/Y1%2FP8gDAcWC%2F+VR3@pevik/

Kind regards,
Petr

Chuck, could you add that link to the changelog when you merge it?

In progress, I'll push the update in a moment.

Quoted 22 lines

Thanks,
Jeff

Quoted 18 lines
Quoted 17 lines
Quoted 17 lines

The v1 patch applies cleanly to v6.0, but not to Chuck's for-next branch. This one should be suitable there.

fs/nfsd/filecache.c +2 -3
index 98c6b5f51bc8..4a8aa7cd8354 100644
@@ -890,9 +890,8 @@ __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;
-			nfsd_file_unhash_and_dispose(nf, &dispose);
+			if (!net || nf->nf_net == net)
+				nfsd_file_unhash_and_dispose(nf, &dispose);
 			nf = rhashtable_walk_next(&iter);
 		}
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signature · 1 line
2.38.1
Signature · 1 line
Jeff Layton <[email protected]>

--
Chuck Lever

#5 lore raw
Quoted 29 lines
Quoted 28 lines · Jeff Layton
Quoted 13 lines · Petr Vorel
Quoted 12 lines
Quoted 12 lines · Jeff Layton

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")

---
fs/nfsd/filecache.c | 5 ++---

1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 3 lines
Quoted 1 line

Thank you! Applied and pushed to for-rc. I'll send a PR in a few days.

Thanks for a quick action!

No problem.

Quoted 2 lines

What a shame you didn't put link to the report, which contains reproducer.
https://lore.kernel.org/ltp/Y1%2FP8gDAcWC%2F+VR3@pevik/

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Kind regards,
Petr

Chuck, could you add that link to the changelog when you merge it?

In progress, I'll push the update in a moment.

Thanks a lot!

Kind regards,
Petr

Quoted 26 lines
Quoted 26 lines

Thanks,
Jeff

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

The v1 patch applies cleanly to v6.0, but not to Chuck's for-next branch. This one should be suitable there.

fs/nfsd/filecache.c +2 -3
index 98c6b5f51bc8..4a8aa7cd8354 100644
@@ -890,9 +890,8 @@ __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;
-			nfsd_file_unhash_and_dispose(nf, &dispose);
+			if (!net || nf->nf_net == net)
+				nfsd_file_unhash_and_dispose(nf, &dispose);
 			nf = rhashtable_walk_next(&iter);
 		}
 
Signature · 1 line
2.38.1
Signature · 1 line
Jeff Layton <[email protected]>
#6 lore raw
In reply to Jeff Layton

Hi all,

Quoted 5 lines

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")

Adding this to regression tracker.
https://linux-regtracking.leemhuis.info/tracked-regression/

#regzbot ^introduced ce502f81ba88
#regzbot ignore-activity

Kind regards,
Petr

Quoted 23 lines
---
 fs/nfsd/filecache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

The v1 patch applies cleanly to v6.0, but not to Chuck's for-next branch. This one should be suitable there.

fs/nfsd/filecache.c +2 -3
index 98c6b5f51bc8..4a8aa7cd8354 100644
@@ -890,9 +890,8 @@ __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;
-			nfsd_file_unhash_and_dispose(nf, &dispose);
+			if (!net || nf->nf_net == net)
+				nfsd_file_unhash_and_dispose(nf, &dispose);
 			nf = rhashtable_walk_next(&iter);
 		}
#7 lore raw

Re: [PATCH v2] nfsd: fix net-namespace logic in __nfsd_file_cache_purge #forregzbot

[Note: this mail is primarily send for documentation purposes and/or for regzbot, my Linux kernel regression tracking bot. That's why I removed most or all folks from the list of recipients, but left any that looked like a mailing lists. These mails usually contain '#forregzbot' in the subject, to make them easy to spot and filter out.]

Quoted 6 lines · Petr Vorel

Hi all,

Quoted 3 lines

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.

Quoted 7 lines
Quoted 1 line
Fixes ce502f81ba88 ("NFSD: Convert the filecache to use rhashtable")

Adding this to regression tracker.
https://linux-regtracking.leemhuis.info/tracked-regression/

#regzbot ^introduced ce502f81ba88
#regzbot ignore-activity

#regzbot fixed-by: d3aefd2b29ff5