From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1DBFC433FE for ; Thu, 30 Sep 2021 14:16:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9599619FA for ; Thu, 30 Sep 2021 14:16:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351836AbhI3OSE (ORCPT ); Thu, 30 Sep 2021 10:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240149AbhI3OSE (ORCPT ); Thu, 30 Sep 2021 10:18:04 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97018C06176A; Thu, 30 Sep 2021 07:16:21 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id BB434703F; Thu, 30 Sep 2021 10:16:20 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org BB434703F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1633011380; bh=d+zTKb1U2WCtpOSHtjtEGCRkMq8DHSFqEIy3a/LI1Dg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XXmkX3d58WdggHN44Xy7qNKKfXsKmNHyNMvAAPA2YwcCJioKbVi4kGKwpMhnz/Fom HHTj+Y056Rsqk6sfgEFNHAy33Y9XbGQYPkNOjDtp3qgXi2VXh5KDXGZ+LwWR7CvwZx yQ55umNNVGHORlMHWXZ363pgwhycuzpc+yVZGbig= Date: Thu, 30 Sep 2021 10:16:20 -0400 From: "J. Bruce Fields" To: "Ho, Patrick" Cc: Chuck Lever , "linux-nfs@vger.kernel.org" , "stable@vger.kernel.org" Subject: Re: [PATCH] nfsd: fix error handling of register_pernet_subsys() in init_nfsd() Message-ID: <20210930141620.GA9422@fieldses.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 > 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 --b. > > Fixes: bd5ae9288d64 ("nfsd: register pernet ops last, unregister first") > Cc: stable@vger.kernel.org > Signed-off-by: Patrick Ho > --- > 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