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 9916A19E82A; Mon, 18 Aug 2025 13:46:36 +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=1755524796; cv=none; b=JEXQT9q1klLioLiqcfQ8xTtOZOkD1900NyO03uUqDbEosrSKYCm7eS/bIWlcVr/jCar8sX84iy1y/HJVZuZS7kK5UcX/sZ7JDyaUX3Bfp4/iYYHRQ0/ygaj12JerNo14YNIZf6wSxgvXICchrFVsWtDenVmCWcjTQlCvpsWwChQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755524796; c=relaxed/simple; bh=0InLkshKxs8aud/AJ2k8AvCUMol8uD6rRWkeFo95YPs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q6UVKPAww+Ph9NWirMHOqeI9DGUnuGfucZSMPU6ScJ8Twl3ClfJVVAfdgjOyeLNvkMgB7gvP9cpo8qZzOzavYXAQ0OHfNAro+3pLJBYv5VyLE1MHbFkbzYjrI14j90Ppn+E7wx04wA1YjSG/hp1UFazLkQtsZ4wQkgr1qEdmE5M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fmUJyDiC; 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="fmUJyDiC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E344AC4CEEB; Mon, 18 Aug 2025 13:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755524796; bh=0InLkshKxs8aud/AJ2k8AvCUMol8uD6rRWkeFo95YPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fmUJyDiCnzv8oRFtYFsn6c/tRsHpwiSQCj2go/G73vfsPYd4qz+2ACAd/ov3cMAsY X2BoT6tPDiNMOXu131uG3ehDtcAyN9gVjdRO3lw8WxYLovkmPLCsJsJTVEvy850MBA kNcbrJC93oYoZa+ScgZA/ARtdKlP3rJNaj6SNnu8= 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 6.16 033/570] NFSD: detect mismatch of file handle and delegation stateid in OPEN op Date: Mon, 18 Aug 2025 14:40:20 +0200 Message-ID: <20250818124507.090103101@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250818124505.781598737@linuxfoundation.org> References: <20250818124505.781598737@linuxfoundation.org> User-Agent: quilt/0.68 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.16-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 @@ -6332,6 +6332,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;