smb: client: report correct st_size for SMB and NFS symlinks
authorPaulo Alcantara <pc@manguebit.com>
Tue, 28 Nov 2023 19:37:19 +0000 (16:37 -0300)
committerSteve French <stfrench@microsoft.com>
Wed, 29 Nov 2023 02:41:41 +0000 (20:41 -0600)
We can't rely on FILE_STANDARD_INFORMATION::EndOfFile for reparse
points as they will be always zero.  Set it to symlink target's length
as specified by POSIX.

This will make stat() family of syscalls return the correct st_size
for such files.

Cc: stable@vger.kernel.org
Signed-off-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/inode.c

index 42ef8ca446d0dc8970d9e7e7e6487e99d6741e33..09c5c0f5c96e2e17dc584622b722c6e2c4c27d10 100644 (file)
@@ -865,6 +865,8 @@ static void cifs_open_info_to_fattr(struct cifs_fattr *fattr,
 
 out_reparse:
        if (S_ISLNK(fattr->cf_mode)) {
+               if (likely(data->symlink_target))
+                       fattr->cf_eof = strnlen(data->symlink_target, PATH_MAX);
                fattr->cf_symlink_target = data->symlink_target;
                data->symlink_target = NULL;
        }