]> git.baikalelectronics.ru Git - kernel.git/commit
nfsd: fix error handling of register_pernet_subsys() in init_nfsd()
authorPatrick Ho <Patrick.Ho@netapp.com>
Sat, 21 Aug 2021 06:56:26 +0000 (02:56 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Oct 2021 08:08:17 +0000 (10:08 +0200)
commit621f3b333c5d4a0f9f1143809929477db8bfab75
treef4931a739224cd7f40eb53b5652832409198fce2
parent7c57ab1976ac5ac334b0ececaf89fa73a3379088
nfsd: fix error handling of register_pernet_subsys() in init_nfsd()

commit 1d625050c7c2dd877e108e382b8aaf1ae3cfe1f4 upstream.

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>
Acked-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfsd/nfsctl.c