* [PATCH] nfsd: fix error handling of register_pernet_subsys() in init_nfsd()
@ 2021-09-30 3:48 Ho, Patrick
2021-09-30 14:16 ` J. Bruce Fields
0 siblings, 1 reply; 3+ messages in thread
From: Ho, Patrick @ 2021-09-30 3:48 UTC (permalink / raw)
To: J. Bruce Fields, Chuck Lever, linux-nfs; +Cc: stable
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.
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nfsd: fix error handling of register_pernet_subsys() in init_nfsd()
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
2021-09-30 15:07 ` Chuck Lever III
0 siblings, 1 reply; 3+ messages in thread
From: J. Bruce Fields @ 2021-09-30 14:16 UTC (permalink / raw)
To: Ho, Patrick; +Cc: Chuck Lever, linux-nfs, stable
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nfsd: fix error handling of register_pernet_subsys() in init_nfsd()
2021-09-30 14:16 ` J. Bruce Fields
@ 2021-09-30 15:07 ` Chuck Lever III
0 siblings, 0 replies; 3+ messages in thread
From: Chuck Lever III @ 2021-09-30 15:07 UTC (permalink / raw)
To: Bruce Fields, Ho, Patrick; +Cc: Linux NFS Mailing List, stable
> On Sep 30, 2021, at 10:16 AM, J. Bruce Fields <bfields@fieldses.org> wrote:
>
> 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.
Applied to the for-next branch at
git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git
> 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
--
Chuck Lever
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-30 15:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-09-30 15:07 ` Chuck Lever III
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).