Skip to content

Commit ce465bf

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: fix crash in cifs_dfs_do_automount
RHBZ: 1649907 Fix a crash that happens while attempting to mount a DFS referral from the same server on the root of a filesystem. Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent df070af commit ce465bf

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

fs/cifs/connect.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4484,11 +4484,13 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
44844484
unsigned int xid,
44854485
struct cifs_tcon *tcon,
44864486
struct cifs_sb_info *cifs_sb,
4487-
char *full_path)
4487+
char *full_path,
4488+
int added_treename)
44884489
{
44894490
int rc;
44904491
char *s;
44914492
char sep, tmp;
4493+
int skip = added_treename ? 1 : 0;
44924494

44934495
sep = CIFS_DIR_SEP(cifs_sb);
44944496
s = full_path;
@@ -4503,7 +4505,14 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server,
45034505
/* next separator */
45044506
while (*s && *s != sep)
45054507
s++;
4506-
4508+
/*
4509+
* if the treename is added, we then have to skip the first
4510+
* part within the separators
4511+
*/
4512+
if (skip) {
4513+
skip = 0;
4514+
continue;
4515+
}
45074516
/*
45084517
* temporarily null-terminate the path at the end of
45094518
* the current component
@@ -4551,8 +4560,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
45514560

45524561
if (rc != -EREMOTE) {
45534562
rc = cifs_are_all_path_components_accessible(server, xid, tcon,
4554-
cifs_sb,
4555-
full_path);
4563+
cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS);
45564564
if (rc != 0) {
45574565
cifs_dbg(VFS, "cannot query dirs between root and final path, "
45584566
"enabling CIFS_MOUNT_USE_PREFIX_PATH\n");

0 commit comments

Comments
 (0)