Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2178163iof; Tue, 7 Jun 2022 22:18:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQqtj8PB6PjU6JuV2E/Sob+4LvriFC6D5YEN5rep2GcNMRQ4WGQctQtTzjTra1t0SBxYgf X-Received: by 2002:a05:6a00:1745:b0:51b:de90:aefb with SMTP id j5-20020a056a00174500b0051bde90aefbmr26995100pfc.11.1654665522413; Tue, 07 Jun 2022 22:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665522; cv=none; d=google.com; s=arc-20160816; b=DRDUQ9OkKfR8NGgWe9VYMgsUdMD9RDSrz1CaAGBsG21cv5dh58utHRRqlcJGgqQXqO OAveEeKHzW/JkyS8+oRWv5CITx4LMZkaWGzsDMYqfG8mgzNMiwigQ78gTPBfEcfXw8B2 XW/xlJ6eYjIXkmOw1g4HkgKXAhBvPdIDbo56GpgRTmclbo+EwGyKNAtwWQYSM49PMDup Ufqyh4ErQ6RmDlee5WaYvc7PIWnh9BSe9rluLQkLcKlJF5oU9ofpeivUfvhM+nffxq/B jREbiRGIzS+bBLJiw1S2PDzQwg416nFwqn57JM6DbgeQJATOIImrUKAA2+N7JsON2R63 dUmw== 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=K48C6nGV51nXliglvVfDq50vAcZylT98sW5pAXkblwY=; b=T+cKtQPZbEddjlOCSOKHYh/LtR3GudtEMXCfaiVCGAeUNzgNmmwVCSiTB1EnU0CxXm COZ0YsLSGVkvUp3g9Jonw8Wv2PPedoSNQH5VVu3AlgtSUIJ3bqP5LljW2FloNmov3/kq c1avrRfq3+p5TVr1P1/Ip0P25CEUplLXmAeDZLJWy4vqbZOSUJxjQ2vM6qDiGh+RYWpd sZl4TBtZ4cUdN9KPKMTkEqFIZUQSMU/ibwnOpotLBHrNTlWn6feFFc64+H5yZW7LUm7S jTWEEIco1rmLHhe3GqkdF0X0f0aIqbwrDZfFU1mo4hwAak3KQtUphgSBCpCtyUGb24JE B0WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Sd5EhpKs; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id q10-20020a170902eb8a00b00153b640ed90si27177100plg.38.2022.06.07.22.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:18:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Sd5EhpKs; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4534A46F1C1; Tue, 7 Jun 2022 21:47:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356628AbiFGTj0 (ORCPT + 99 others); Tue, 7 Jun 2022 15:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354314AbiFGSqx (ORCPT ); Tue, 7 Jun 2022 14:46:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 706DF1269A3; Tue, 7 Jun 2022 11:00:42 -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 ams.source.kernel.org (Postfix) with ESMTPS id 2EAF2B82239; Tue, 7 Jun 2022 18:00:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D261C385A5; Tue, 7 Jun 2022 18:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654624839; bh=T/8dKxgO1bV24yxbT1u1jIbcPlEOMWi68k46axBHxpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sd5EhpKssMQvFyG2w6s5bGgOsheczlFIXOjvNix71o/AXqgCBx+gVkUWhiruvaGVY +98SDLx1CHDhxPTqt4zXLl/A3LEZdkFuvBGwLD15HE32jaFmS/x9nbC6UKEKFB3cP/ nYUNe0IaXa7tUd5vwk10uwRp4xUUZZpHk5cXEH3g= 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.15 471/667] nfsd: destroy percpu stats counters after reply cache shutdown Date: Tue, 7 Jun 2022 19:02:16 +0200 Message-Id: <20220607164948.832223601@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164934.766888869@linuxfoundation.org> References: <20220607164934.766888869@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 96cdf77925f3..830bb8493c7f 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c @@ -212,7 +212,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++) { @@ -223,6 +222,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