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 DF0DF43BDB8; Mon, 17 Aug 2026 14:53:58 +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=1786978440; cv=none; b=DlfhZ9nmMrUViTO65gsSzuQyvxe8om5aJF+6JK4idlVfmav534Zpg1FDZmv3lO7LhV/n/uX+m9Ta6QR99oh6CcWNCEFMtDEsZwdKyu6ip9QMBvTsBiqdGL+O4zdFZqhYX/TmD10oOAyHQgQeNvIA3/ah3FNwEuOcJ8QEEbx+HDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786978440; c=relaxed/simple; bh=jsaO3NRmfcuf5JSs0TNQIazwbzcfAYcEKamhYPnxzI8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RbuFCdwFr/yJz3aZfw8ylsZujLH/swZ+2Rp0vEA32J4m3Yjl0mx8mxBsu6tBeDE9XHfM5+pe0V5LmHPC4SzLvHk6hfv853GZBgEwFqnm/6cXHHRErisPX9m6SxTsN1QCZtotuxt/AF6Nhckx3wW6xSRvLKxRds7N9v/r33jvdCY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DV0h3Z6i; 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="DV0h3Z6i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94B4A1F00A3A; Mon, 17 Aug 2026 14:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786978436; bh=QUMkoLwoyBaOuM4c08ZN0Xfdf5j02ITEOJZqAqHobWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DV0h3Z6iRXSfiAcpJLPkHwb144Z6MVeFvpqN2daTssLu9p+n/uxmm6xuZuEeQXOk7 BTilCL+NvmNWKSnoV7M3tsnttHpkdQQYM41Cs9cvNPXnipi/HnRvnVuRdRL1M0NMJs /klB5jqoSDI04znUN6sQjD6LpnC2wYCyfORtzDWg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Aloni , Anna Schumaker , Sasha Levin Subject: [PATCH 6.6 004/156] NFS: Pin the struct nfs_server during a FREE_STATEID call Date: Mon, 17 Aug 2026 15:32:18 +0200 Message-ID: <20260817132534.833717146@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132534.666299318@linuxfoundation.org> References: <20260817132534.666299318@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anna Schumaker [ Upstream commit cf616096a0f3a2b60f7d68b6b39674a6867ded9c ] Dan Aloni reports that he was able to hit a use-after-free bug if a FREE_STATEID operation gets delayed for whatever reason. Fix this by bumping the refcount of the 'struct nfs_server' object for the duration of the FREE_STATEID so it doesn't get cleaned up from underneath us while operations are still in flight. Reported-by: Dan Aloni Fixes: 7c1d5fae4a87 ("NFSv4: Convert nfs41_free_stateid to use an asynchronous RPC call") Tested-by: Dan Aloni Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/nfs4proc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 42fa7c915e29b..ce3ab0a9c0ef7 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -10383,6 +10383,7 @@ static void nfs41_free_stateid_release(void *calldata) struct nfs_free_stateid_data *data = calldata; struct nfs_client *clp = data->server->nfs_client; + nfs_sb_deactive(data->server->super); nfs_put_client(clp); kfree(calldata); } @@ -10424,6 +10425,10 @@ static int nfs41_free_stateid(struct nfs_server *server, if (!refcount_inc_not_zero(&clp->cl_count)) return -EIO; + if (!nfs_sb_active(server->super)) { + nfs_put_client(clp); + return -EIO; + } nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_STATEID, &task_setup.rpc_client, &msg); -- 2.53.0