linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
Cc: Jeff Layton <jlayton@kernel.org>,
	linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: NFSd: NULL-dereference when writing to v4_end_grace when server is not yet started
Date: Tue, 27 Nov 2018 20:19:23 -0500	[thread overview]
Message-ID: <20181128011923.GB15237@fieldses.org> (raw)
In-Reply-To: <20181127205849.GB12810@fieldses.org>

On Tue, Nov 27, 2018 at 03:58:49PM -0500, J. Bruce Fields wrote:
> On Sun, Nov 25, 2018 at 09:17:10AM +0300, Anatoly Trosinenko wrote:
> > When manually exploring the kernel NFSd feature, I have stumbled upon
> > a NULL-dereference when writing to v4_end_grace when server is not yet
> > started.
> 
> Thanks for the report!
> 
> I think this is what we want--it's what a lot of the other nfsctl
> methods do.

Hm, no, I'm getting a hang.  It looks like in the nfsd4 state startup we
call a cltrack upcall while holding the nfsd_mutex, then nfsdcltrack
tries to write to end_grace.  That's kind of ugly.

--b.

> commit ad5fdf47b4e3
> Author: J. Bruce Fields <bfields@redhat.com>
> Date:   Tue Nov 27 15:54:17 2018 -0500
> 
>     nfsd4: fix crash on writing v4_end_grace before nfsd startup
>     
>     Anatoly Trosinenko reports that this:
>     
>     1) Checkout fresh master Linux branch (tested with commit e195ca6cb)
>     2) Copy x84_64-config-4.14 to .config, then enable NFS server v4 and build
>     3) From `kvm-xfstests shell`:
>     
>     results in NULL dereference in locks_end_grace.
>     
>     Check that nfsd has been started before trying to end the grace period.
>     
>     Reported-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
>     Signed-off-by: J. Bruce Fields <bfields@redhat.com>
> 
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index 6384c9b94898..38b223c1378e 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -1126,7 +1126,13 @@ static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
>  		case 'Y':
>  		case 'y':
>  		case '1':
> +			mutex_lock(&nfsd_mutex);
> +			if (nn->nfsd_serv) {
> +				mutex_unlock(&nfsd_mutex);
> +				return -EBUSY;
> +			}
>  			nfsd4_end_grace(nn);
> +			mutex_unlock(&nfsd_mutex);
>  			break;
>  		default:
>  			return -EINVAL;

      reply	other threads:[~2018-11-28  1:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-25  6:17 NFSd: NULL-dereference when writing to v4_end_grace when server is not yet started Anatoly Trosinenko
2018-11-27 20:58 ` J. Bruce Fields
2018-11-28  1:19   ` J. Bruce Fields [this message]

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=20181128011923.GB15237@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=anatoly.trosinenko@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    /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).