]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
NFSv4: xattr handlers should check for absent nfs filehandles
authorScott Mayhew <smayhew@redhat.com>
Wed, 16 Apr 2025 15:23:38 +0000 (11:23 -0400)
committerAnna Schumaker <anna.schumaker@oracle.com>
Mon, 19 May 2025 14:14:29 +0000 (10:14 -0400)
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 <smayhew@redhat.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/nfs4proc.c

index b1d2122bd5a749dbccad975a732b4f54624ee116..f837ed7ad90c01f35f14389c740f094ec5ec92bf 100644 (file)
@@ -6211,6 +6211,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);
@@ -6285,6 +6287,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);