Skip to contentSkip to conversation

SUNRPC: check current nsproxy before set of node name on client creation

PATCH Superseded Stanislav Kinsbursky 2 participants 3 messages Aug 13, 2012

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SUNRPC: check current nsproxy before set of node name on client creation

When child reaper exits, it can destroy mount namespace it belong to, and if there are NFS mounts inside, then it will try to umount them. But in this point current->nsproxy is set to NULL and all namespaces will be destroyed one by one. I.e. we can't dereference current->nsproxy to obtain uts namespace.

---
 net/sunrpc/clnt.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
net/sunrpc/clnt.c +12 -2
index 9a9676e..28ac940 100644
@@ -279,6 +279,16 @@ void rpc_clients_notifier_unregister(void)
 
 static void rpc_clnt_set_nodename(struct rpc_clnt *clnt, const char *nodename)
 {
+	const char *nodename;
+
+	/*
+	 * We have to protect against dying chilp reaper, which has released
+	 * it's nsproxy already and is trying to destroy mount namespace.
+	 */
+	if (current->nsproxy == NULL)
+		return;
+
+	nodename = utsname()->nodename;
 	clnt->cl_nodelen = strlen(nodename);
 	if (clnt->cl_nodelen > UNX_MAXNODENAME)
 		clnt->cl_nodelen = UNX_MAXNODENAME;
@@ -365,7 +375,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
 	}
 
 	/* save the nodename */
-	rpc_clnt_set_nodename(clnt, utsname()->nodename);
+	rpc_clnt_set_nodename(clnt);
 	rpc_register_client(clnt);
 	return clnt;
 
@@ -524,7 +534,7 @@ rpc_clone_client(struct rpc_clnt *clnt)
 	err = rpc_setup_pipedir(new, clnt->cl_program->pipe_dir_name);
 	if (err != 0)
 		goto out_no_path;
-	rpc_clnt_set_nodename(new, utsname()->nodename);
+	rpc_clnt_set_nodename(new);
 	if (new->cl_auth)
 		atomic_inc(&new->cl_auth->au_count);
 	atomic_inc(&clnt->cl_count);
#1 lore raw
Quoted 15 lines · On Mon, 13 Aug 2012 15:21:56 +0400 Stanislav Kinsbursky…

When child reaper exits, it can destroy mount namespace it belong to, and if there are NFS mounts inside, then it will try to umount them. But in this point current->nsproxy is set to NULL and all namespaces will be destroyed one by one. I.e. we can't dereference current->nsproxy to obtain uts namespace.

---
 net/sunrpc/clnt.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
net/sunrpc/clnt.c +0 -0
index 9a9676e..28ac940 100644

net/sunrpc/clnt.c void rpc_clients_notifier_unregister(void) · line 280

Quoted 2 lines
net/sunrpc/clnt.c +0 -0
@@ -279,6 +279,16 @@ void rpc_clients_notifier_unregister(void)
 
 static void rpc_clnt_set_nodename(struct rpc_clnt *clnt, const char *nodename)

Don't you need to change the prototype of the function here too?

net/sunrpc/clnt.c void rpc_clients_notifier_unregister(void) · line 285

Quoted 5 lines
net/sunrpc/clnt.c +4 -0
 {
+	const char *nodename;
+
+	/*
+	 * We have to protect against dying chilp reaper, which has released

nit: "dying child reaper" ?

net/sunrpc/clnt.c void rpc_clients_notifier_unregister(void) · line 286

Quoted 1 line
net/sunrpc/clnt.c +1 -0
+	 * it's nsproxy already and is trying to destroy mount namespace.
	nit: "its"
Quoted 31 lines
net/sunrpc/clnt.c +7 -3
+	 */
+	if (current->nsproxy == NULL)
+		return;
+
+	nodename = utsname()->nodename;
 	clnt->cl_nodelen = strlen(nodename);
 	if (clnt->cl_nodelen > UNX_MAXNODENAME)
 		clnt->cl_nodelen = UNX_MAXNODENAME;
@@ -365,7 +375,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
 	}
 
 	/* save the nodename */
-	rpc_clnt_set_nodename(clnt, utsname()->nodename);
+	rpc_clnt_set_nodename(clnt);
 	rpc_register_client(clnt);
 	return clnt;
 
@@ -524,7 +534,7 @@ rpc_clone_client(struct rpc_clnt *clnt)
 	err = rpc_setup_pipedir(new, clnt->cl_program->pipe_dir_name);
 	if (err != 0)
 		goto out_no_path;
-	rpc_clnt_set_nodename(new, utsname()->nodename);
+	rpc_clnt_set_nodename(new);
 	if (new->cl_auth)
 		atomic_inc(&new->cl_auth->au_count);
 	atomic_inc(&clnt->cl_count);
 
--

To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Jeff Layton <[email protected]>
#2 lore raw

Thanks, Jeff. Will fix.

13.08.2012 15:35, Jeff Layton пишет:

Quoted 68 lines
Quoted 15 lines · On Mon, 13 Aug 2012 15:21:56 +0400 Stanislav Kinsbursky…

When child reaper exits, it can destroy mount namespace it belong to, and if there are NFS mounts inside, then it will try to umount them. But in this point current->nsproxy is set to NULL and all namespaces will be destroyed one by one. I.e. we can't dereference current->nsproxy to obtain uts namespace.

---
  net/sunrpc/clnt.c |   14 ++++++++++++--
  1 files changed, 12 insertions(+), 2 deletions(-)
net/sunrpc/clnt.c +0 -0
index 9a9676e..28ac940 100644

net/sunrpc/clnt.c void rpc_clients_notifier_unregister(void) · line 280

Quoted 2 lines
net/sunrpc/clnt.c +0 -0
@@ -279,6 +279,16 @@ void rpc_clients_notifier_unregister(void)
 
  static void rpc_clnt_set_nodename(struct rpc_clnt *clnt, const char *nodename)

Don't you need to change the prototype of the function here too?

net/sunrpc/clnt.c void rpc_clients_notifier_unregister(void) · line 285

Quoted 5 lines
net/sunrpc/clnt.c +4 -0
  {
+	const char *nodename;
+
+	/*
+	 * We have to protect against dying chilp reaper, which has released

nit: "dying child reaper" ?

net/sunrpc/clnt.c void rpc_clients_notifier_unregister(void) · line 286

Quoted 1 line
net/sunrpc/clnt.c +1 -0
+	 * it's nsproxy already and is trying to destroy mount namespace.
	nit: "its"
Quoted 31 lines
net/sunrpc/clnt.c +7 -3
+	 */
+	if (current->nsproxy == NULL)
+		return;
+
+	nodename = utsname()->nodename;
  	clnt->cl_nodelen = strlen(nodename);
  	if (clnt->cl_nodelen > UNX_MAXNODENAME)
  		clnt->cl_nodelen = UNX_MAXNODENAME;
@@ -365,7 +375,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
  	}
 
  	/* save the nodename */
-	rpc_clnt_set_nodename(clnt, utsname()->nodename);
+	rpc_clnt_set_nodename(clnt);
  	rpc_register_client(clnt);
  	return clnt;
 
@@ -524,7 +534,7 @@ rpc_clone_client(struct rpc_clnt *clnt)
  	err = rpc_setup_pipedir(new, clnt->cl_program->pipe_dir_name);
  	if (err != 0)
  		goto out_no_path;
-	rpc_clnt_set_nodename(new, utsname()->nodename);
+	rpc_clnt_set_nodename(new);
  	if (new->cl_auth)
  		atomic_inc(&new->cl_auth->au_count);
  	atomic_inc(&clnt->cl_count);
 
--

To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Best regards,
Stanislav Kinsbursky