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 4A32B2ED157; Thu, 3 Jul 2025 14:56:40 +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=1751554600; cv=none; b=IlQOp4OlBaj91pZzTRT1e8v/2zfLK1SfM7CMOa1pxDJ4JgudQLluvZ0IYATvsXZY1tuxaE/5BS1iNWoORM1kM1ccQIUhrhM6o+niGG16eMoauyo3kE1tjeZjGe5YvFUB12Zp+jWbDrXQjKGihhtyhlrPMKMORNScCpiFGVth33k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751554600; c=relaxed/simple; bh=dUHY3WhqGU1km+TAlxTSlDLhV1mK4HWGStUiaWhqxNM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ICOOYcqgRSdTJ9LGL1AQk4Q7troFi0vor9nvgm5V9QpM5QV8xiG3lGEZk8y7n5FsXAMR7/EH2NplDqVslVNJetr9SWtkcSDWbjwDqF+2eT9r6gHcy/uGLW6ZPV6Fjlesywbi7+YUg4RhDEn+3R9zAIUgBeEEpT9Nkk6Co6qKmeg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=izASFNuO; 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="izASFNuO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C651CC4CEE3; Thu, 3 Jul 2025 14:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1751554600; bh=dUHY3WhqGU1km+TAlxTSlDLhV1mK4HWGStUiaWhqxNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=izASFNuO+qSbiCJLPu2svp19zhLlN8geZAUCaFmehlUDqTDhJIqOF/Q/Shfsgzryb 6q2u3Z8qJvDah7p9COILqnSZ621N/DHxLhVIpaOEhHWvIPOyDl2wLI5xMewE/Vmyw5 QLiBVMKAilPITwp4DdDgx4hh64dfoUzyA9w2hTQc= 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.15 020/263] NFSv4: xattr handlers should check for absent nfs filehandles Date: Thu, 3 Jul 2025 16:39:00 +0200 Message-ID: <20250703144005.104656160@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250703144004.276210867@linuxfoundation.org> References: <20250703144004.276210867@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.15-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 6c3896a9b9d0f..2f5a6aa3fd48e 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6220,6 +6220,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); @@ -6294,6 +6296,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