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 DF1645908AE; Wed, 9 Sep 2026 14:40:15 +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=1788964817; cv=none; b=U5i+NqDsqXJayJaNqAvB59Ntbb5nS+Vy/GDRfR4xmW2PvpHkAsMTRhGGOrcktQtXTsuaPBAywWnhN4/TIyyLOsGWxMD0uD4sWpbrvFBi4q6/n7G97z4FDpxtl6xlq8M7GSTSjRQpCHDsvlLwGf5n9oET/5wbRr3gGfkpmdVSzVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788964817; c=relaxed/simple; bh=M6eRZQvO0+9b8J0gPzu9BJr/7MDVlt3ON+FhnMoUgXc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DuFsxMmCHGuNZzHFNQ3/31Y5UOBkuBt87laoGjrbRLlox5Puldqt1vRKGWR7sMlcr9Gv7lKPGOZ90Vvkrib9HuydPESF7tqyCneKe17dSbVfxnBtrdjDmjy6YSK3lGzA8YzXEGjbQkalRve7MwBxxMTVec+91grJZijJ8ED+s6k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YO2kAWNe; 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="YO2kAWNe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E514C1F00A3A; Wed, 9 Sep 2026 14:40:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788964815; bh=8LqlmpImJE38yegtWIyoLznUtx5pMkTmMLREplsWomw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YO2kAWNeY8D+1rWLtiuJQl8mqd5FoNpvUqqzh6oD/1ao66Bdv4JjAQ8DUTCRQGGDa BWb8ImJFXVBOw02m9NwBsWHET4xGOGeKmTKAI4tiemhDQlrdf+P/eR9ey0E11xHsQl /oIDVfz9bsC39bS+UpC+C8zji7rmL1IWncPkul/I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 6.18 552/583] NFSD: Prevent client use-after-free during close_lru reaping Date: Wed, 9 Sep 2026 15:43:57 +0200 Message-ID: <20260909134256.837279064@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909134237.773280130@linuxfoundation.org> References: <20260909134237.773280130@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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chuck Lever [ Upstream commit 2330b788d732f43668b965b3105b37ceb276dfea ] An nfs4_openowner left on nn->close_lru after its final CLOSE keeps its last closed stateid in oo_last_closed_stid, holding only a raw pointer to its nfs4_client. The laundromat reaps timed-out entries, drops nn->client_lock, and calls nfs4_put_stid(), which dereferences the client through cl_lock. Nothing pins the client across that window, so a concurrent force_expire_client() can free it and nfs4_put_stid() reads freed memory. __destroy_client() hits the same race, walking clp->cl_openowners without cl_lock. Pin the client with cl_rpc_users before dropping client_lock, and skip clients already expiring. __destroy_client() then cleans up its own close_lru entries through release_last_closed_stateid(), so teardown no longer races the laundromat. Fixes: 217526e7ecc9 ("nfsd: protect the close_lru list and oo_last_closed_stid with client_lock") Cc: stable@vger.kernel.org Reviewed-by: Jeff Layton Link: https://patch.msgid.link/20260709-cel-v4-8-1d519d9be0cb@kernel.org Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs4state.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -7165,11 +7165,16 @@ nfs4_laundromat(struct nfsd_net *nn) if (!state_expired(<, oo->oo_time)) break; list_del_init(&oo->oo_close_lru); + clp = oo->oo_owner.so_client; + if (is_client_expired(clp)) + continue; stp = oo->oo_last_closed_stid; oo->oo_last_closed_stid = NULL; + atomic_inc(&clp->cl_rpc_users); spin_unlock(&nn->client_lock); nfs4_put_stid(&stp->st_stid); spin_lock(&nn->client_lock); + put_client_no_renew_locked(clp); } spin_unlock(&nn->client_lock);