Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2208700iof; Tue, 7 Jun 2022 23:15:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1A4Js9yCwdPZivx9qOFf1otQ3YbH/Q8x78922Ou1AbZikPzkwuPdStO5KCGVRnetktErH X-Received: by 2002:a17:903:210a:b0:167:78c0:dd70 with SMTP id o10-20020a170903210a00b0016778c0dd70mr15117404ple.157.1654668923839; Tue, 07 Jun 2022 23:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668923; cv=none; d=google.com; s=arc-20160816; b=owtgaou8xaxp3E8HGi2A6Cc/+Gerj/2dAinHtgWHnxuVFtboCvifI0ljXTOBSFwlcw U0o2qBOLZsR/BCyNZS/G4Mypj5DHJKkyjfvDUBo5itdzEhiXw/jSam91sGuJ03Ym0mPN iuUiPB+4d8plSTOufdasGm2RQW0i87agdnJzRFfQDaWeQcJJ++xTsRNmOSDRnFxc0Gez tEUkwRYmKm3U+oPf60GyzpniElMLu9Vtqx6eRSGZS4sgAZIcd3TTy2WuskB1BIONx+xR 6u1bmRWr6bSeXgHSpzXMCvD1szhvQKrEaUwnOsBFhjjgdwSPoKdV9B6pFI1+0khxGlov 9y3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AeTnO52YndsZmTRW+HzuMQ3VwkuRUh6u9tmTmFRh+sE=; b=oHBJKzgOJyKi6JqopwrtKgp7pjW28Us4lNK3zlpU7111pxwiyKeJtPN9w9MKJFCX74 yPjIp1NcI+TkUjLlmrBR9OomF01w/wEnkuV70MImuNPwKTMTUgiQMbhcs2q9cGuqY3o7 GosjZkAvjbeKKFH0qTNDAg/H2PbqI3t3njTHDLH2cR3abwPNxgE8LZniqVROLJqcOcWt SOBSohRboe5ElJVXZe6WVJPI/1aNfXLqDNPmbxovp+BDxIioD22YusFQCdvFpyshUUPC zuc5ygxmM4fxr9p+T+wYcQRckAWkQhfOwFpVbunrwkdMVls3IPbgnIGXUQzqFu4inrJF oEeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hJ9jBQZ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id lr16-20020a17090b4b9000b001d1ad44a667si20769348pjb.6.2022.06.07.23.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:15:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hJ9jBQZ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DE3B010F1DB; Tue, 7 Jun 2022 22:36:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391236AbiFHBwe (ORCPT + 99 others); Tue, 7 Jun 2022 21:52:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382581AbiFGWDV (ORCPT ); Tue, 7 Jun 2022 18:03:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9149925226C; Tue, 7 Jun 2022 12:15:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2BA0461846; Tue, 7 Jun 2022 19:15:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B1E3C385A2; Tue, 7 Jun 2022 19:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629323; bh=i9D6UZi1id+EwXjbxVjIy6MvFF68gEQaTYHag2aL4jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hJ9jBQZ1PZvabaxnyYKtvGqkxzW6TscCtCz5jA8fY57eAQoBVVb1Ub0W7VompRY+Q igy1dm7fN2QPbhOquWkyC/TEWl8vbYf+iDALe+fQuPeGV5R1oSx4HSB8AFIdfX0vJW RUPamf2jJRE/pMJ4OW25A+19NU4rjZWszpmuUWUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Schroeder , Chuck Lever , Sasha Levin Subject: [PATCH 5.18 650/879] nfsd: destroy percpu stats counters after reply cache shutdown Date: Tue, 7 Jun 2022 19:02:48 +0200 Message-Id: <20220607165021.715699200@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julian Schroeder [ Upstream commit fd5e363eac77ef81542db77ddad0559fa0f9204e ] Upon nfsd shutdown any pending DRC cache is freed. DRC cache use is tracked via a percpu counter. In the current code the percpu counter is destroyed before. If any pending cache is still present, percpu_counter_add is called with a percpu counter==NULL. This causes a kernel crash. The solution is to destroy the percpu counter after the cache is freed. Fixes: e567b98ce9a4b (“nfsd: protect concurrent access to nfsd stats counters”) Signed-off-by: Julian Schroeder Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/nfscache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 0b3f12aa37ff..7da88bdc0d6c 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c @@ -206,7 +206,6 @@ void nfsd_reply_cache_shutdown(struct nfsd_net *nn) struct svc_cacherep *rp; unsigned int i; - nfsd_reply_cache_stats_destroy(nn); unregister_shrinker(&nn->nfsd_reply_cache_shrinker); for (i = 0; i < nn->drc_hashsize; i++) { @@ -217,6 +216,7 @@ void nfsd_reply_cache_shutdown(struct nfsd_net *nn) rp, nn); } } + nfsd_reply_cache_stats_destroy(nn); kvfree(nn->drc_hashtbl); nn->drc_hashtbl = NULL; -- 2.35.1