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 0B6322F0C44; Thu, 3 Jul 2025 15:19:22 +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=1751555962; cv=none; b=KNApALJlhoVOtWzNTMmwAfU1CRj7KKZwJ2QdZV04ijaukqb26dMIOBAoxnm3iS5haz8yxufqvzz8xVmDTz3dMEdNeypIsYkaW1klmBv7S/kowGCo5SOWbbOEvLwnJZhkC//kZhgViPFSm3GFXIJ7zD0g83IUskUyKBFnB6yit3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751555962; c=relaxed/simple; bh=OyxbcDNAV9g3JYerzyV9ekq32oh7eGoFU9HIK/5SZHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EaSfD1KFsZ0D4MefKajxpbr6FRP2woh/d5ROnSnPi5q7gOiTlzE1YwKbOvHvE55n8Jwud6wseE0wLlg++Qg9tyV1BJzvo94Ou8EHwOOXDJRMe6zXStuvHbBTjz2unNViRv8iH0iHWou+tH2b+4BZZCb7fuDlxT4NtIOuoU5DOHA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pH8ZcbOM; 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="pH8ZcbOM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FC51C4CEE3; Thu, 3 Jul 2025 15:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1751555961; bh=OyxbcDNAV9g3JYerzyV9ekq32oh7eGoFU9HIK/5SZHc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pH8ZcbOMjkvr85ZDo9Mt29A3FU9V3HwTZ/8XwvW0Tt1XjqkGGZvYuWfhFytJTRHzT 2+RqR7bP4l99sgrWU6CawrBkc5FO2s+EN7nCqiCGjHzHHcatDMcQ+hIuvMhgFeqAI+ AKFhd7GkQ9q47tcH031wRzzYIbw813VC8kOms03U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Scott Mayhew , Anna Schumaker , Sasha Levin Subject: [PATCH 6.1 008/132] NFSv4: xattr handlers should check for absent nfs filehandles Date: Thu, 3 Jul 2025 16:41:37 +0200 Message-ID: <20250703143939.720845606@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250703143939.370927276@linuxfoundation.org> References: <20250703143939.370927276@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Scott Mayhew [ Upstream commit 6e9a2f8dbe93c8004c2af2c0158888628b7ca034 ] The nfs inodes for referral anchors that have not yet been followed have their filehandles zeroed out. Attempting to call getxattr() on one of these will cause the nfs client to send a GETATTR to the nfs server with the preceding PUTFH sans filehandle. The server will reply NFS4ERR_NOFILEHANDLE, leading to -EIO being returned to the application. For example: $ strace -e trace=getxattr getfattr -n system.nfs4_acl /mnt/t/ref getxattr("/mnt/t/ref", "system.nfs4_acl", NULL, 0) = -1 EIO (Input/output error) /mnt/t/ref: system.nfs4_acl: Input/output error +++ exited with 1 +++ Have the xattr handlers return -ENODATA instead. Signed-off-by: Scott Mayhew 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 2d94d1d7b0c62..29f8a2df2c11a 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6065,6 +6065,8 @@ static ssize_t nfs4_proc_get_acl(struct inode *inode, void *buf, size_t buflen, struct nfs_server *server = NFS_SERVER(inode); int ret; + if (unlikely(NFS_FH(inode)->size == 0)) + return -ENODATA; if (!nfs4_server_supports_acls(server, type)) return -EOPNOTSUPP; ret = nfs_revalidate_inode(inode, NFS_INO_INVALID_CHANGE); @@ -6139,6 +6141,9 @@ static int nfs4_proc_set_acl(struct inode *inode, const void *buf, { struct nfs4_exception exception = { }; int err; + + if (unlikely(NFS_FH(inode)->size == 0)) + return -ENODATA; do { err = __nfs4_proc_set_acl(inode, buf, buflen, type); trace_nfs4_set_acl(inode, err); -- 2.39.5