From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84586412C04; Fri, 4 Sep 2026 05:11:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788498667; cv=none; b=ixt2R8gI9vViJTnLqwUHWot6uR0PWBE33b/F9qVyWBU73a0kRiPZpShj4SzpFGHzGR8ScNTJd6K1q0bKk2osUrRbk4gbDToT/H05U+t5XLxDPEJWWy7FXAMNpv6fLZluw1eJNntEcW7cZytKr7UEjwppJ5GBoZTEa0kSd/nl5DM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788498667; c=relaxed/simple; bh=Gdgi30FZB6NfqgMyiI2uT/R/Nx7dOVsmCx94onra6Uw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q0cr+Jkqpd9FMfk2i8Fy0hmg0FUm/cOeMF26PAnHJOIu2sk9GkAMxf+rbZX7vi1otAI63PXTvLuQZ9xHhVmyNr96qwbfnD/2lQHcNq6cyFbV8hJHIAl0bwv9LpdpLcd6VTpHLx1wYdmISB3ZDDX938pnMQ1ux7mdwtrHdG6EnaE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UEG46rnH; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UEG46rnH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEA511F00A3D; Fri, 4 Sep 2026 05:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788498666; bh=AANPE3N7ttGWKX0V6DzmpIV+zbni51fihMeKaAyWhzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UEG46rnHxT5qYFzk7Zjaw1ryC0srI+3EUG+6GTCFrwJdOFDcwn7H1MmBTbvQV72yy QApboYjKACC1KIuYXRArn58NvbRRIekvpJDgKhE0mSMLC5I84GWtwtJF06fMYr94vu TTL8JHGOj8ttq9qc/mvcuyaUk3KKoDQA+YEf5YZI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Mason , Chuck Lever Subject: [PATCH 7.2 144/713] nfsd: guard nfsd_serv deref in nfsd_file_net_dispose Date: Fri, 4 Sep 2026 06:51:52 +0200 Message-ID: <20260904045807.056105415@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260904045803.810145556@linuxfoundation.org> References: <20260904045803.810145556@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Mason commit 9f1ddfc8cb9076592401a611eb3a44d36186d014 upstream. nfsd_file_net_dispose() is the consumer side of l->freeme: the nfsd service thread loop calls it to drain entries that the filecache garbage collector and shrinker append via nfsd_file_dispose_list_delayed(). During per-net teardown, nn->nfsd_serv is cleared before the filecache laundrette is shut down, so the service thread can still run a dispose pass that finds more than eight entries on l->freeme and dereferences a NULL svc_serv: nfsd service thread loop nfsd_file_net_dispose(nn) if (!list_empty(&l->freeme)) { ... svc_wake_up(nn->nfsd_serv); /* nn->nfsd_serv == NULL */ } The sibling helper nfsd_file_dispose_list_delayed() already documents this ordering and caches nn->nfsd_serv into a local before testing it for NULL. nfsd_file_net_dispose() was introduced with the same raw svc_wake_up(nn->nfsd_serv) call and never picked up the guard. Fix by loading nn->nfsd_serv into a local svc_serv pointer and only calling svc_wake_up() when it is non-NULL, matching the pattern in nfsd_file_dispose_list_delayed(). Fixes: ffb402596147 ("nfsd: Don't leave work of closing files to a work queue") Cc: stable@vger.kernel.org Assisted-by: kres:claude-opus-4-7 Signed-off-by: Chris Mason Link: https://patch.msgid.link/20260602-nfsd-testing-v2-4-e4ea62e3cd5c@kernel.org Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/filecache.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -471,11 +471,20 @@ void nfsd_file_net_dispose(struct nfsd_n for (i = 0; i < 8 && !list_empty(&l->freeme); i++) list_move(l->freeme.next, &dispose); spin_unlock(&l->lock); - if (!list_empty(&l->freeme)) - /* Wake up another thread to share the work + if (!list_empty(&l->freeme)) { + /* + * Wake up another thread to share the work * *before* doing any actual disposing. + * + * The filecache laundrette is shut down after + * the nn->nfsd_serv pointer is cleared, but + * before the svc_serv is freed. */ - svc_wake_up(nn->nfsd_serv); + struct svc_serv *serv = nn->nfsd_serv; + + if (serv) + svc_wake_up(serv); + } nfsd_file_dispose_list(&dispose); } }