From: Stanislav Kinsbursky <skinsbursky@parallels.com>
To: stable@vger.kernel.org
Cc: linux-nfs@vger.kernel.org, bfields@redhat.com,
viro@zeniv.linux.org.uk, jbottomley@parallels.com
Subject: [PATCH 2/2] NFSd: set nfsd_serv to NULL after service destruction
Date: Fri, 14 Sep 2012 12:25:56 +0400 [thread overview]
Message-ID: <20120914082550.14353.46041.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20120914082201.14353.83847.stgit@localhost6.localdomain6>
upstream commit 57c8b13e3cd0f94944c9691ce7f58e5fcef8a12d
In nfsd_destroy():
if (destroy)
svc_shutdown_net(nfsd_serv, net);
svc_destroy(nfsd_server);
svc_shutdown_net(nfsd_serv, net) calls nfsd_last_thread(), which sets
nfsd_serv to NULL, causing a NULL dereference on the following line.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
fs/nfsd/nfsd.h | 2 ++
fs/nfsd/nfssvc.c | 10 +++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index e3339ca..1336a65 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -80,6 +80,8 @@ static inline void nfsd_destroy(struct net *net)
if (destroy)
svc_shutdown_net(nfsd_serv, net);
svc_destroy(nfsd_serv);
+ if (destroy)
+ nfsd_serv = NULL;
}
#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index e866af4..5f4b8f2 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -256,8 +256,6 @@ static void nfsd_shutdown(void)
static void nfsd_last_thread(struct svc_serv *serv, struct net *net)
{
- /* When last nfsd thread exits we need to do some clean-up */
- nfsd_serv = NULL;
nfsd_shutdown();
svc_rpcb_cleanup(serv, net);
@@ -334,6 +332,7 @@ static int nfsd_get_default_max_blksize(void)
int nfsd_create_serv(void)
{
int error;
+ struct net *net = current->nsproxy->net_ns;
WARN_ON(!mutex_is_locked(&nfsd_mutex));
if (nfsd_serv) {
@@ -348,7 +347,7 @@ int nfsd_create_serv(void)
if (nfsd_serv == NULL)
return -ENOMEM;
- error = svc_bind(nfsd_serv, current->nsproxy->net_ns);
+ error = svc_bind(nfsd_serv, net);
if (error < 0) {
svc_destroy(nfsd_serv);
return error;
@@ -559,12 +558,13 @@ nfsd(void *vrqstp)
nfsdstats.th_cnt --;
out:
- if (rqstp->rq_server->sv_nrthreads == 1)
- svc_shutdown_net(rqstp->rq_server, &init_net);
+ rqstp->rq_server = NULL;
/* Release the thread */
svc_exit_thread(rqstp);
+ nfsd_destroy(&init_net);
+
/* Release module */
mutex_unlock(&nfsd_mutex);
module_put_and_exit(0);
next prev parent reply other threads:[~2012-09-14 8:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-14 8:25 [PATCH 0/2] nfsd: backport fixes for 3.5 kernel Stanislav Kinsbursky
2012-09-14 8:25 ` [PATCH 1/2] NFSd: introduce nfsd_destroy() helper Stanislav Kinsbursky
2012-09-14 8:25 ` Stanislav Kinsbursky [this message]
2012-09-17 15:01 ` [PATCH 0/2] nfsd: backport fixes for 3.5 kernel J. Bruce Fields
2012-09-28 0:13 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120914082550.14353.46041.stgit@localhost6.localdomain6 \
--to=skinsbursky@parallels.com \
--cc=bfields@redhat.com \
--cc=jbottomley@parallels.com \
--cc=linux-nfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).