Skip to contentSkip to conversation

NFSD: Decrease nfsd_users in nfsd_startup_generic fail

PATCH In review Kinglong Mee 2 participants 4 messages Jul 30, 2014 – Aug 1, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFSD: Decrease nfsd_users in nfsd_startup_generic fail

If nfsd_startup_generic fail, nfsd_users isn't decreased right now.

NFSD restarts will return 0 at the first nfsd_users checking, after that, nfs4_state_start_net() will meet a bad laundry_wq (I meet NULL), after nfsd4_grace timeout, the kernel will crash.

---
 fs/nfsd/nfssvc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfsd/nfssvc.c +4 -1
index 5d026dc..752d56b 100644
@@ -221,7 +221,8 @@ static int nfsd_startup_generic(int nrservs)
 	 */
 	ret = nfsd_racache_init(2*nrservs);
 	if (ret)
-		return ret;
+		goto dec_users;
+
 	ret = nfs4_state_start();
 	if (ret)
 		goto out_racache;
@@ -229,6 +230,8 @@ static int nfsd_startup_generic(int nrservs)
 
 out_racache:
 	nfsd_racache_shutdown();
+dec_users:
+	nfsd_users--;
 	return ret;
 }
 
Signature · 1 line
1.9.3
#1 lore raw

Thanks!

Quoted 1 line · Kinglong Mee

If nfsd_startup_generic fail, nfsd_users isn't decreased right now.

Looks like that should only fail in out of memory cases?

Quoted 3 lines

NFSD restarts will return 0 at the first nfsd_users checking, after that, nfs4_state_start_net() will meet a bad laundry_wq (I meet NULL), after nfsd4_grace timeout, the kernel will crash.

So this was introduced with 4539f14981ce02d48b212786a41c8bcfb62851b4 "nfsd: replace boolean nfsd_up flag by users counter".

--b.

Quoted 32 lines
---
 fs/nfsd/nfssvc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfsd/nfssvc.c +4 -1
index 5d026dc..752d56b 100644
@@ -221,7 +221,8 @@ static int nfsd_startup_generic(int nrservs)
 	 */
 	ret = nfsd_racache_init(2*nrservs);
 	if (ret)
-		return ret;
+		goto dec_users;
+
 	ret = nfs4_state_start();
 	if (ret)
 		goto out_racache;
@@ -229,6 +230,8 @@ static int nfsd_startup_generic(int nrservs)
 
 out_racache:
 	nfsd_racache_shutdown();
+dec_users:
+	nfsd_users--;
 	return ret;
 }
 
Signature · 1 line
1.9.3
#2 lore raw
Quoted 6 lines · J. Bruce Fields

Thanks!

Quoted 1 line · Kinglong Mee

If nfsd_startup_generic fail, nfsd_users isn't decreased right now.

Looks like that should only fail in out of memory cases?

Yes, it is.
I found this problem through reviewing code.

Quoted 7 lines
Quoted 4 lines

NFSD restarts will return 0 at the first nfsd_users checking, after that, nfs4_state_start_net() will meet a bad laundry_wq (I meet NULL), after nfsd4_grace timeout, the kernel will crash.

So this was introduced with 4539f14981ce02d48b212786a41c8bcfb62851b4 "nfsd: replace boolean nfsd_up flag by users counter".

Yes, I forget adding it.

thanks,
Kinglong Mee

Quoted 32 lines
Quoted 31 lines
---
 fs/nfsd/nfssvc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfsd/nfssvc.c +4 -1
index 5d026dc..752d56b 100644
@@ -221,7 +221,8 @@ static int nfsd_startup_generic(int nrservs)
 	 */
 	ret = nfsd_racache_init(2*nrservs);
 	if (ret)
-		return ret;
+		goto dec_users;
+
 	ret = nfs4_state_start();
 	if (ret)
 		goto out_racache;
@@ -229,6 +230,8 @@ static int nfsd_startup_generic(int nrservs)
 
 out_racache:
 	nfsd_racache_shutdown();
+dec_users:
+	nfsd_users--;
 	return ret;
 }
 
Signature · 1 line
1.9.3
#3 lore raw
Quoted 10 lines · Kinglong Mee
Quoted 6 lines · J. Bruce Fields

Thanks!

Quoted 1 line · Kinglong Mee

If nfsd_startup_generic fail, nfsd_users isn't decreased right now.

Looks like that should only fail in out of memory cases?

Yes, it is.
I found this problem through reviewing code.

Got it, thanks! Applying for 3.17 and stable.

--b.

Quoted 46 lines
Quoted 8 lines
Quoted 5 lines

NFSD restarts will return 0 at the first nfsd_users checking, after that, nfs4_state_start_net() will meet a bad laundry_wq (I meet NULL), after nfsd4_grace timeout, the kernel will crash.

So this was introduced with 4539f14981ce02d48b212786a41c8bcfb62851b4 "nfsd: replace boolean nfsd_up flag by users counter".

Yes, I forget adding it.

thanks,
Kinglong Mee

Quoted 32 lines
Quoted 31 lines
---
 fs/nfsd/nfssvc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfsd/nfssvc.c +4 -1
index 5d026dc..752d56b 100644
@@ -221,7 +221,8 @@ static int nfsd_startup_generic(int nrservs)
 	 */
 	ret = nfsd_racache_init(2*nrservs);
 	if (ret)
-		return ret;
+		goto dec_users;
+
 	ret = nfs4_state_start();
 	if (ret)
 		goto out_racache;
@@ -229,6 +230,8 @@ static int nfsd_startup_generic(int nrservs)
 
 out_racache:
 	nfsd_racache_shutdown();
+dec_users:
+	nfsd_users--;
 	return ret;
 }
 
Signature · 1 line
1.9.3