Skip to content

Commit 8bde59b

Browse files
Paulo AlcantaraSteve French
authored andcommitted
smb: client: handle path separator of created SMB symlinks
Convert path separator to CIFS_DIR_SEP(cifs_sb) from symlink target before sending it over the wire otherwise the created SMB symlink may become innaccesible from server side. Fixes: 514d793 ("smb: client: allow creating symlinks via reparse points") Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 4508ec1 commit 8bde59b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/smb/client/smb2ops.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5217,7 +5217,7 @@ static int smb2_create_reparse_symlink(const unsigned int xid,
52175217
struct inode *new;
52185218
struct kvec iov;
52195219
__le16 *path;
5220-
char *sym;
5220+
char *sym, sep = CIFS_DIR_SEP(cifs_sb);
52215221
u16 len, plen;
52225222
int rc = 0;
52235223

@@ -5231,7 +5231,8 @@ static int smb2_create_reparse_symlink(const unsigned int xid,
52315231
.symlink_target = sym,
52325232
};
52335233

5234-
path = cifs_convert_path_to_utf16(symname, cifs_sb);
5234+
convert_delimiter(sym, sep);
5235+
path = cifs_convert_path_to_utf16(sym, cifs_sb);
52355236
if (!path) {
52365237
rc = -ENOMEM;
52375238
goto out;
@@ -5254,7 +5255,10 @@ static int smb2_create_reparse_symlink(const unsigned int xid,
52545255
buf->PrintNameLength = cpu_to_le16(plen);
52555256
memcpy(buf->PathBuffer, path, plen);
52565257
buf->Flags = cpu_to_le32(*symname != '/' ? SYMLINK_FLAG_RELATIVE : 0);
5258+
if (*sym != sep)
5259+
buf->Flags = cpu_to_le32(SYMLINK_FLAG_RELATIVE);
52575260

5261+
convert_delimiter(sym, '/');
52585262
iov.iov_base = buf;
52595263
iov.iov_len = len;
52605264
new = smb2_get_reparse_inode(&data, inode->i_sb, xid,

0 commit comments

Comments
 (0)