From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EDAE4350D44; Tue, 26 Aug 2025 14:13:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756217591; cv=none; b=X5VxBfyU2iU+E9C7WVaqojQHs73Pi4tWHtlkCIW1BUzggFH/pOX15Xg6sp1YbSatcQ7yzZ8rHAQpPMosqUaDfW5jupbgiY6cU1CCcL4NJaP3sS7Ac3jq/MYL83E615Bd2jv33eIDIgxvOOq8oWG07bxCuc0TEsTpiqNqsGyUQ6w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756217591; c=relaxed/simple; bh=XClKdSu+P/C61QVM2mtWBpSADAKsx+qpepj3LxqIviE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P0E+wxT7pDrV1oimP7oP+uHtpjQ9/JJLlVuLquaLLLBnxqwq5oT+fx2Lca0CT6g5WmRyVN7ADjYF4YkgqkGw88FrsM11JkkVTjKXnAkuKDVIIK4pxTvh/cWvhVg94PC0gmgSC/JlcGJbAu76hrmZ0tcnkJp/XVxJgXvD1ZnmG5A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jmTl/4qQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jmTl/4qQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C858C4CEF1; Tue, 26 Aug 2025 14:13:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756217590; bh=XClKdSu+P/C61QVM2mtWBpSADAKsx+qpepj3LxqIviE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jmTl/4qQUysIq978q1kTvzOhRT7GcF4uhMEhipagt+hOrmQj8/jb7z/FHxtl2eNi+ Y5z+kEg8jZYpJClBwAXsBbvJzCp0Z0MEgJiDBg9yf4qNc8dPLDTkrLul8VlOOC/SRV 0XIcyVK6q17cnVWI2OqwtVlQjb62sFFn55EJ0ATc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Petro Pavlov , Dai Ngo , Jeff Layton , Chuck Lever Subject: [PATCH 5.10 199/523] NFSD: detect mismatch of file handle and delegation stateid in OPEN op Date: Tue, 26 Aug 2025 13:06:49 +0200 Message-ID: <20250826110929.355828795@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110924.562212281@linuxfoundation.org> References: <20250826110924.562212281@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dai Ngo commit 9c65001c57164033ad08b654c8b5ae35512ddf4a upstream. When the client sends an OPEN with claim type CLAIM_DELEG_CUR_FH or CLAIM_DELEGATION_CUR, the delegation stateid and the file handle must belong to the same file, otherwise return NFS4ERR_INVAL. Note that RFC8881, section 8.2.4, mandates the server to return NFS4ERR_BAD_STATEID if the selected table entry does not match the current filehandle. However returning NFS4ERR_BAD_STATEID in the OPEN causes the client to retry the operation and therefor get the client into a loop. To avoid this situation we return NFS4ERR_INVAL instead. Reported-by: Petro Pavlov Fixes: c44c5eeb2c02 ("[PATCH] nfsd4: add open state code for CLAIM_DELEGATE_CUR") Cc: stable@vger.kernel.org Signed-off-by: Dai Ngo Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs4state.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -5732,6 +5732,20 @@ nfsd4_process_open2(struct svc_rqst *rqs status = nfs4_check_deleg(cl, open, &dp); if (status) goto out; + if (dp && nfsd4_is_deleg_cur(open) && + (dp->dl_stid.sc_file != fp)) { + /* + * RFC8881 section 8.2.4 mandates the server to return + * NFS4ERR_BAD_STATEID if the selected table entry does + * not match the current filehandle. However returning + * NFS4ERR_BAD_STATEID in the OPEN can cause the client + * to repeatedly retry the operation with the same + * stateid, since the stateid itself is valid. To avoid + * this situation NFSD returns NFS4ERR_INVAL instead. + */ + status = nfserr_inval; + goto out; + } stp = nfsd4_find_and_lock_existing_open(fp, open); } else { open->op_file = NULL;