Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: "Ho, Patrick" <Patrick.Ho@netapp.com>
Cc: Chuck Lever <chuck.lever@oracle.com>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] nfsd: fix error handling of register_pernet_subsys() in init_nfsd()
Date: Thu, 30 Sep 2021 10:16:20 -0400	[thread overview]
Message-ID: <20210930141620.GA9422@fieldses.org> (raw)
In-Reply-To: <SJ0PR06MB8327D188504E0F367C8B4E53F4AA9@SJ0PR06MB8327.namprd06.prod.outlook.com>

On Thu, Sep 30, 2021 at 03:48:42AM +0000, Ho, Patrick wrote:
> >From 7417896fcc7aea645fa0b89f39fa55979251dca3 Mon Sep 17 00:00:00 2001
> From: Patrick Ho <Patrick.Ho@netapp.com>
> Date: Sat, 21 Aug 2021 02:56:26 -0400
> Subject: [PATCH] nfsd: fix error handling of register_pernet_subsys() in
>  init_nfsd()
> 
> init_nfsd() should not unregister pernet subsys if the register fails
> but should instead unwind from the last successful operation which is
> register_filesystem().
> 
> Unregistering a failed register_pernet_subsys() call can result in
> a kernel GPF as revealed by programmatically injecting an error in
> register_pernet_subsys().
> 
> Verified the fix handled failure gracefully with no lingering nfsd
> entry in /proc/filesystems.  This change was introduced by the commit
> bd5ae9288d64 ("nfsd: register pernet ops last, unregister first"),
> the original error handling logic was correct.

Whoops, thanks for catching this.  I assume Chuck will pick it up.

Acked-by: J. Bruce Fields <bfields@redhat.com>

--b.

> 
> Fixes: bd5ae9288d64 ("nfsd: register pernet ops last, unregister first")
> Cc: stable@vger.kernel.org
> Signed-off-by: Patrick Ho <Patrick.Ho@netapp.com>
> ---
>  fs/nfsd/nfsctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index c2c3d9077dc5..09ae1a0873d0 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -1545,7 +1545,7 @@ static int __init init_nfsd(void)
>  		goto out_free_all;
>  	return 0;
>  out_free_all:
> -	unregister_pernet_subsys(&nfsd_net_ops);
> +	unregister_filesystem(&nfsd_fs_type);
>  out_free_exports:
>  	remove_proc_entry("fs/nfs/exports", NULL);
>  	remove_proc_entry("fs/nfs", NULL);
> -- 
> 2.17.1

  reply	other threads:[~2021-09-30 14:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30  3:48 [PATCH] nfsd: fix error handling of register_pernet_subsys() in init_nfsd() Ho, Patrick
2021-09-30 14:16 ` J. Bruce Fields [this message]
2021-09-30 15:07   ` Chuck Lever III

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=20210930141620.GA9422@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=Patrick.Ho@netapp.com \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=stable@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