Skip to content

Commit 6c06be9

Browse files
paliSteve French
authored andcommitted
cifs: Check if server supports reparse points before using them
Do not attempt to query or create reparse point when server fs does not support it. This will prevent creating unusable empty object on the server. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 5eeebd9 commit 6c06be9

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

fs/smb/client/cifssmb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,6 +2709,9 @@ int cifs_query_reparse_point(const unsigned int xid,
27092709
if (cap_unix(tcon->ses))
27102710
return -EOPNOTSUPP;
27112711

2712+
if (!(le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS))
2713+
return -EOPNOTSUPP;
2714+
27122715
oparms = (struct cifs_open_parms) {
27132716
.tcon = tcon,
27142717
.cifs_sb = cifs_sb,

fs/smb/client/link.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
643643
case CIFS_SYMLINK_TYPE_NATIVE:
644644
case CIFS_SYMLINK_TYPE_NFS:
645645
case CIFS_SYMLINK_TYPE_WSL:
646-
if (server->ops->create_reparse_symlink) {
646+
if (server->ops->create_reparse_symlink &&
647+
(le32_to_cpu(pTcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS)) {
647648
rc = server->ops->create_reparse_symlink(xid, inode,
648649
direntry,
649650
pTcon,

fs/smb/client/smb2inode.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,14 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data,
12731273
int rc;
12741274
int i;
12751275

1276+
/*
1277+
* If server filesystem does not support reparse points then do not
1278+
* attempt to create reparse point. This will prevent creating unusable
1279+
* empty object on the server.
1280+
*/
1281+
if (!(le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS))
1282+
return ERR_PTR(-EOPNOTSUPP);
1283+
12761284
oparms = CIFS_OPARMS(cifs_sb, tcon, full_path,
12771285
SYNCHRONIZE | DELETE |
12781286
FILE_READ_ATTRIBUTES |

fs/smb/client/smb2ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5229,7 +5229,7 @@ static int smb2_make_node(unsigned int xid, struct inode *inode,
52295229
const char *full_path, umode_t mode, dev_t dev)
52305230
{
52315231
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
5232-
int rc;
5232+
int rc = -EOPNOTSUPP;
52335233

52345234
/*
52355235
* Check if mounted with mount parm 'sfu' mount parm.
@@ -5240,7 +5240,7 @@ static int smb2_make_node(unsigned int xid, struct inode *inode,
52405240
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
52415241
rc = cifs_sfu_make_node(xid, inode, dentry, tcon,
52425242
full_path, mode, dev);
5243-
} else {
5243+
} else if (le32_to_cpu(tcon->fsAttrInfo.Attributes) & FILE_SUPPORTS_REPARSE_POINTS) {
52445244
rc = smb2_mknod_reparse(xid, inode, dentry, tcon,
52455245
full_path, mode, dev);
52465246
}

0 commit comments

Comments
 (0)