]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: fix creating symlinks under POSIX mounts
authorPaulo Alcantara <pc@manguebit.org>
Thu, 31 Jul 2025 23:46:43 +0000 (20:46 -0300)
committerSteve French <stfrench@microsoft.com>
Tue, 5 Aug 2025 00:29:14 +0000 (19:29 -0500)
SMB3.1.1 POSIX mounts support native symlinks that are created with
IO_REPARSE_TAG_SYMLINK reparse points, so skip the checking of
FILE_SUPPORTS_REPARSE_POINTS as some servers might not have it set.

Cc: linux-cifs@vger.kernel.org
Cc: Ralph Boehme <slow@samba.org>
Cc: David Howells <dhowells@redhat.com>
Cc: <stable@vger.kernel.org>
Reported-by: Matthew Richardson <m.richardson@ed.ac.uk>
Closes: https://marc.info/?i=1124e7cd-6a46-40a6-9f44-b7664a66654b@ed.ac.uk
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifsglob.h
fs/smb/client/cifssmb.c
fs/smb/client/link.c
fs/smb/client/smb1ops.c
fs/smb/client/smb2inode.c
fs/smb/client/smb2ops.c

index 19dd901fe8abf9fc5aea2c1cab8ac9c33f19e51c..a97e2cca2f5324bd6dbe507af5629cbed9b77d3f 100644 (file)
@@ -2377,4 +2377,9 @@ static inline bool cifs_netbios_name(const char *name, size_t namelen)
        return ret;
 }
 
+#define CIFS_REPARSE_SUPPORT(tcon) \
+       ((tcon)->posix_extensions || \
+        (le32_to_cpu((tcon)->fsAttrInfo.Attributes) & \
+         FILE_SUPPORTS_REPARSE_POINTS))
+
 #endif /* _CIFS_GLOB_H */
index 6c890db0659385d3d408b647db2268bfc4ab19db..d20766f664c49354eea35a015121e06eaeb40c37 100644 (file)
@@ -2751,7 +2751,7 @@ int cifs_query_reparse_point(const unsigned int xid,
        if (cap_unix(tcon->ses))
                return -EOPNOTSUPP;
 
-       if (!(le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS))
+       if (!CIFS_REPARSE_SUPPORT(tcon))
                return -EOPNOTSUPP;
 
        oparms = (struct cifs_open_parms) {
@@ -2879,7 +2879,7 @@ struct inode *cifs_create_reparse_inode(struct cifs_open_info_data *data,
         * attempt to create reparse point. This will prevent creating unusable
         * empty object on the server.
         */
-       if (!(le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS))
+       if (!CIFS_REPARSE_SUPPORT(tcon))
                return ERR_PTR(-EOPNOTSUPP);
 
 #ifndef CONFIG_CIFS_XATTR
index afe76367d2c8f82de41830793e3aa8876e6d9f90..fe80e711cd756ad615d194df62291227ff23c1f6 100644 (file)
@@ -635,7 +635,7 @@ cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
        case CIFS_SYMLINK_TYPE_NATIVE:
        case CIFS_SYMLINK_TYPE_NFS:
        case CIFS_SYMLINK_TYPE_WSL:
-               if (le32_to_cpu(pTcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS) {
+               if (CIFS_REPARSE_SUPPORT(pTcon)) {
                        rc = create_reparse_symlink(xid, inode, direntry, pTcon,
                                                    full_path, symname);
                        goto symlink_exit;
index e364b6515af3f67fcca7036ef4954fbcfa1591e5..f722c7f47b07d61a9e5b419ff3bb4308c8b6cb3f 100644 (file)
@@ -1272,7 +1272,7 @@ cifs_make_node(unsigned int xid, struct inode *inode,
                 */
                return cifs_sfu_make_node(xid, inode, dentry, tcon,
                                          full_path, mode, dev);
-       } else if (le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS) {
+       } else if (CIFS_REPARSE_SUPPORT(tcon)) {
                /*
                 * mknod via reparse points requires server support for
                 * storing reparse points, which is available since
index 69d251726c02e030bfff2d5d7d2adf31861b5c9c..2a0316c514e4731d7522b1a715afe9f14c260494 100644 (file)
@@ -1346,9 +1346,8 @@ struct inode *smb2_create_reparse_inode(struct cifs_open_info_data *data,
         * attempt to create reparse point. This will prevent creating unusable
         * empty object on the server.
         */
-       if (!(le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS))
-               if (!tcon->posix_extensions)
-                       return ERR_PTR(-EOPNOTSUPP);
+       if (!CIFS_REPARSE_SUPPORT(tcon))
+               return ERR_PTR(-EOPNOTSUPP);
 
        oparms = CIFS_OPARMS(cifs_sb, tcon, full_path,
                             SYNCHRONIZE | DELETE |
index 1b4a31894f431d807236b77d0f87e478c73becf3..bd6c1fb2a9923520781cba719f5d76e69eb29a7a 100644 (file)
@@ -5260,10 +5260,9 @@ static int smb2_make_node(unsigned int xid, struct inode *inode,
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
                rc = cifs_sfu_make_node(xid, inode, dentry, tcon,
                                        full_path, mode, dev);
-       } else if ((le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS)
-               || (tcon->posix_extensions)) {
+       } else if (CIFS_REPARSE_SUPPORT(tcon)) {
                rc = mknod_reparse(xid, inode, dentry, tcon,
-                                       full_path, mode, dev);
+                                  full_path, mode, dev);
        }
        return rc;
 }