linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SUNRPC: check current nsproxy before set of node name on client creation
@ 2012-08-13 11:21 Stanislav Kinsbursky
  2012-08-13 11:35 ` Jeff Layton
  0 siblings, 1 reply; 3+ messages in thread
From: Stanislav Kinsbursky @ 2012-08-13 11:21 UTC (permalink / raw)
  To: Trond.Myklebust; +Cc: bfields, linux-nfs, linux-kernel, devel

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.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
---
 net/sunrpc/clnt.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 9a9676e..28ac940 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -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);


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

* Re: [PATCH] SUNRPC: check current nsproxy before set of node name on client creation
  2012-08-13 11:21 [PATCH] SUNRPC: check current nsproxy before set of node name on client creation Stanislav Kinsbursky
@ 2012-08-13 11:35 ` Jeff Layton
  2012-08-13 11:37   ` Stanislav Kinsbursky
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Layton @ 2012-08-13 11:35 UTC (permalink / raw)
  To: Stanislav Kinsbursky
  Cc: Trond.Myklebust, bfields, linux-nfs, linux-kernel, devel

On Mon, 13 Aug 2012 15:21:56 +0400
Stanislav Kinsbursky <skinsbursky@parallels.com> wrote:

> 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.
> 
> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
> ---
>  net/sunrpc/clnt.c |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
> index 9a9676e..28ac940 100644
> --- a/net/sunrpc/clnt.c
> +++ b/net/sunrpc/clnt.c
> @@ -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?

>  {
> +	const char *nodename;
> +
> +	/*
> +	 * We have to protect against dying chilp reaper, which has released

	nit: "dying child reaper" ?

> +	 * it's nsproxy already and is trying to destroy mount namespace.

	nit: "its"

> +	 */
> +	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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Jeff Layton <jlayton@poochiereds.net>

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

* Re: [PATCH] SUNRPC: check current nsproxy before set of node name on client creation
  2012-08-13 11:35 ` Jeff Layton
@ 2012-08-13 11:37   ` Stanislav Kinsbursky
  0 siblings, 0 replies; 3+ messages in thread
From: Stanislav Kinsbursky @ 2012-08-13 11:37 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Trond.Myklebust@netapp.com, bfields@fieldses.org,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	devel@openvz.org

Thanks, Jeff. Will fix.

13.08.2012 15:35, Jeff Layton пишет:
> On Mon, 13 Aug 2012 15:21:56 +0400
> Stanislav Kinsbursky <skinsbursky@parallels.com> wrote:
>
>> 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.
>>
>> Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
>> ---
>>   net/sunrpc/clnt.c |   14 ++++++++++++--
>>   1 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
>> index 9a9676e..28ac940 100644
>> --- a/net/sunrpc/clnt.c
>> +++ b/net/sunrpc/clnt.c
>> @@ -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?
>
>>   {
>> +	const char *nodename;
>> +
>> +	/*
>> +	 * We have to protect against dying chilp reaper, which has released
>
> 	nit: "dying child reaper" ?
>
>> +	 * it's nsproxy already and is trying to destroy mount namespace.
>
> 	nit: "its"
>
>> +	 */
>> +	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 majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>


-- 
Best regards,
Stanislav Kinsbursky

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

end of thread, other threads:[~2012-08-13 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-13 11:21 [PATCH] SUNRPC: check current nsproxy before set of node name on client creation Stanislav Kinsbursky
2012-08-13 11:35 ` Jeff Layton
2012-08-13 11:37   ` Stanislav Kinsbursky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).