From: "J. Bruce Fields" <bfields@fieldses.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
jlayton@redhat.com
Subject: Re: linux-next NFSD: NULL pointer dereference at nfsd_svc()
Date: Fri, 6 Aug 2010 18:10:00 -0400 [thread overview]
Message-ID: <20100806221000.GF29536@fieldses.org> (raw)
In-Reply-To: <20100806220537.GE29536@fieldses.org>
On Fri, Aug 06, 2010 at 06:05:37PM -0400, J. Bruce Fields wrote:
> On Fri, Aug 06, 2010 at 05:27:28PM -0400, J. Bruce Fields wrote:
> > Bah, so what you were hitting was simple--I just moved the
> > nfsd_reset_versions() call to the wrong place; the below should fix it.
> >
> > There's also a couple other bugs in the area.
And also there was one more problem with my original "nfsd: fix
startup/shutdown order bug": it doesn't work to use sv_nrthreads
changing from zero to nonzero as the signal for when to do all this
startup, because write_pool_threads() adjusts the number of threads
without calling nfsd_svc(). (Maybe that should be fixed.)
For now, just use the nfsd_up variable to keep track of this (which is a
little closer to Jeff's original solution).
This is a replacement.
--b.
commit 4cd7eb015e92f7cefb43eaab3e111d1b3c7b3cbf
Author: J. Bruce Fields <bfields@redhat.com>
Date: Mon Aug 2 14:12:44 2010 -0400
nfsd: fix startup/shutdown order bug
We must create the server before we can call init_socks or check the
number of threads.
Symptoms were a NULL pointer dereference in nfsd_svc(). Problem
identified by Jeff Layton.
Also fix a minor cleanup-on-error case in nfsd_startup().
Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 92173bd..2a20f89 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -204,6 +204,9 @@ static bool nfsd_up = false;
static int nfsd_startup(unsigned short port, int nrservs)
{
int ret;
+
+ if (nfsd_up)
+ return 0;
/*
* Readahead param cache - will no-op if it already exists.
* (Note therefore results will be suboptimal if number of
@@ -217,7 +220,7 @@ static int nfsd_startup(unsigned short port, int nrservs)
goto out_racache;
ret = lockd_up();
if (ret)
- return ret;
+ goto out_racache;
ret = nfs4_state_start();
if (ret)
goto out_lockd;
@@ -420,7 +423,7 @@ int
nfsd_svc(unsigned short port, int nrservs)
{
int error;
- bool first_thread;
+ bool nfsd_up_before;
mutex_lock(&nfsd_mutex);
dprintk("nfsd: creating service\n");
@@ -432,29 +435,29 @@ nfsd_svc(unsigned short port, int nrservs)
if (nrservs == 0 && nfsd_serv == NULL)
goto out;
- first_thread = (nfsd_serv->sv_nrthreads == 0) && (nrservs != 0);
-
- if (first_thread) {
- error = nfsd_startup(port, nrservs);
- if (error)
- goto out;
- }
error = nfsd_create_serv();
if (error)
- goto out_shutdown;
- error = svc_set_num_threads(nfsd_serv, NULL, nrservs);
+ goto out;
+
+ nfsd_up_before = nfsd_up;
+
+ error = nfsd_startup(port, nrservs);
if (error)
goto out_destroy;
+ }
+ error = svc_set_num_threads(nfsd_serv, NULL, nrservs);
+ if (error)
+ goto out_shutdown;
/* We are holding a reference to nfsd_serv which
* we don't want to count in the return value,
* so subtract 1
*/
error = nfsd_serv->sv_nrthreads - 1;
-out_destroy:
- svc_destroy(nfsd_serv); /* Release server */
out_shutdown:
- if (error < 0 && first_thread)
+ if (error < 0 && !nfsd_up_before)
nfsd_shutdown();
+out_destroy:
+ svc_destroy(nfsd_serv); /* Release server */
out:
mutex_unlock(&nfsd_mutex);
return error;
next prev parent reply other threads:[~2010-08-06 22:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <201008020747.o727lqXs064715@www262.sakura.ne.jp>
2010-08-02 14:32 ` linux-next NFSD: NULL pointer dereference at nfsd_svc() Jeff Layton
2010-08-02 14:36 ` Jeff Layton
2010-08-02 18:16 ` J. Bruce Fields
2010-08-02 18:53 ` Jeff Layton
2010-08-03 1:09 ` Tetsuo Handa
2010-08-03 15:48 ` J. Bruce Fields
2010-08-03 16:24 ` J. Bruce Fields
2010-08-04 0:13 ` Tetsuo Handa
[not found] ` <201008040013.o740DmYK024832-etx+eQDEXHD7nzcFbJAaVXf5DAMn2ifp@public.gmane.org>
2010-08-04 19:40 ` J. Bruce Fields
2010-08-05 1:10 ` Tetsuo Handa
2010-08-05 20:46 ` J. Bruce Fields
2010-08-05 21:31 ` J. Bruce Fields
2010-08-06 1:37 ` Tetsuo Handa
2010-08-06 21:27 ` J. Bruce Fields
2010-08-06 22:05 ` J. Bruce Fields
2010-08-06 22:10 ` J. Bruce Fields [this message]
2010-08-07 1:48 ` Tetsuo Handa
2010-08-07 2:33 ` J. Bruce Fields
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=20100806221000.GF29536@fieldses.org \
--to=bfields@fieldses.org \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
/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).