From patchwork Mon Aug 13 11:37:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Kinsbursky X-Patchwork-Id: 1312251 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B575EDF223 for ; Mon, 13 Aug 2012 11:39:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599Ab2HMLjy (ORCPT ); Mon, 13 Aug 2012 07:39:54 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:20944 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751109Ab2HMLjy (ORCPT ); Mon, 13 Aug 2012 07:39:54 -0400 Received: from localhost.localdomain ([10.30.21.131]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id q7DBdaHT000832; Mon, 13 Aug 2012 15:39:36 +0400 (MSK) Subject: [PATCH v2] SUNRPC: check current nsproxy before set of node name on client creation To: Trond.Myklebust@netapp.com From: Stanislav Kinsbursky Cc: bfields@fieldses.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, devel@openvz.org Date: Mon, 13 Aug 2012 15:37:31 +0400 Message-ID: <20120813113731.9629.31906.stgit@localhost.localdomain> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org v2: 1) rpc_clnt_set_nodename() prototype updated. 2) fixed errors in comment. When child reaper exits, it can destroy mount namespace it belongs 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 Acked-by: Jeff Layton --- net/sunrpc/clnt.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) -- 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 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 9a9676e..8fbcbc8 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -277,8 +277,18 @@ void rpc_clients_notifier_unregister(void) return rpc_pipefs_notifier_unregister(&rpc_clients_block); } -static void rpc_clnt_set_nodename(struct rpc_clnt *clnt, const char *nodename) +static void rpc_clnt_set_nodename(struct rpc_clnt *clnt) { + const char *nodename; + + /* + * We have to protect against dying child reaper, which has released + * its 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);