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 6D7A01AA1F4; Fri, 4 Sep 2026 05:14:20 +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=1788498861; cv=none; b=pX0QE40ZGJt2wkBB54cO3pg/mhqY5wM/0rqltLWDegouC/Usp2taBKlWYn54e5XtbYtdKYJ/aXcvzZVO4q9yAARRAH7P1j/fjFseJCYxgV73+IKG21Je/+TfcCEA6BIFeQt4K8OoTkCByu5QOCicMuXSFaAk6EOBA8ubCR4ZFcE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788498861; c=relaxed/simple; bh=5U7oO9f86R42SmVnwiU5Zu/LmRFSWq4Yj/lDwFE9T/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qpbu2AfZQQTI4gvi8G9sPo8AcdSbkRCHObf60yT+qn6u44ZpG47KskiKF+Od3OvXyTMG3n6j5PeTJL0x6kYtIRojK5OHgGYTTknCT17D1FLFOME223dC3vKZwY6mqeM+qtSsN+1OlOXjYqrmgAUX8di3W2cirBlbFTyfYALWfgA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fjnStgV/; 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="fjnStgV/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC8521F00A3D; Fri, 4 Sep 2026 05:14:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788498860; bh=Q6YPtn22qjWLyQC2iiJUckP4RozehNo4kVzYVIqJDvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fjnStgV/t7zjP5Pi2LG4Qe6DXBT+HfK47webCUi6dRrCoZKxfBMVFHCBw7ajDkIH6 0fSVM3gDrszuMy7a79A5jqv9JnFfvt9k9Gl1JwW14C2EfFejmF97P+OalLkh28cBlK 6Mq2iVHzeYZJwrhqqlf0f0vBi/c7GA4Q0LjCJBNw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, NeilBrown , Jeff Layton , Chuck Lever Subject: [PATCH 7.2 211/713] NFSD: Prevent client use-after-free during NFSv4.0 revoked-state cleanup Date: Fri, 4 Sep 2026 06:52:59 +0200 Message-ID: <20260904045808.547435663@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: Chuck Lever commit 7b4f8a1586c42d3afc3c0ac779af2db7ab1a5c55 upstream. nfs40_clean_admin_revoked() takes a stateid reference under clp->cl_lock, drops nn->client_lock, and calls nfsd4_drop_revoked_stid(), which dereferences the stateid's client through s->sc_client->cl_lock. The stateid reference does not pin the client, so a teardown racing the dropped lock can free the client while nfsd4_drop_revoked_stid() is still using it. This cleanup runs from the laundromat, so a periodic sweep can race force_expire_client() driven by a write to the clients//ctl file. Skip a client that is already expiring and otherwise pin it with cl_rpc_users under client_lock before dropping the lock, matching nfsd4_revoke_states(). Fixes: d688d8585e6b ("nfsd: allow admin-revoked NFSv4.0 state to be freed.") Cc: stable@vger.kernel.org Reviewed-by: NeilBrown Reviewed-by: Jeff Layton Link: https://patch.msgid.link/20260709-cel-v4-5-1d519d9be0cb@kernel.org Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs4state.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -7174,16 +7174,22 @@ retry: if (atomic_read(&clp->cl_admin_revoked) == 0) continue; + if (is_client_expired(clp)) + continue; spin_lock(&clp->cl_lock); idr_for_each_entry_ul(&clp->cl_stateids, stid, tmp, id) if (stid->sc_status & SC_STATUS_ADMIN_REVOKED) { refcount_inc(&stid->sc_count); + atomic_inc(&clp->cl_rpc_users); spin_unlock(&nn->client_lock); /* this function drops ->cl_lock */ nfsd4_drop_revoked_stid(stid); nfs4_put_stid(stid); spin_lock(&nn->client_lock); + if (atomic_dec_and_test(&clp->cl_rpc_users) && + is_client_expired(clp)) + wake_up_all(&expiry_wq); goto retry; } spin_unlock(&clp->cl_lock);