diff options
author | Ronnie Sahlberg <lsahlber@redhat.com> | 2019-07-11 13:46:58 +1000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-06 19:08:09 +0200 |
commit | a288e51c6864f5e8a630d2d14ca29c4fb31b07bb (patch) | |
tree | b2f903aa1341075161ec917965c4e03aec5724ae /fs/cifs | |
parent | 3a4d7f5e2bdf1050a365a1e1814af3a46d5015a8 (diff) | |
download | linux-stable-a288e51c6864f5e8a630d2d14ca29c4fb31b07bb.tar.gz linux-stable-a288e51c6864f5e8a630d2d14ca29c4fb31b07bb.tar.bz2 linux-stable-a288e51c6864f5e8a630d2d14ca29c4fb31b07bb.zip |
cifs: fix crash in cifs_dfs_do_automount
[ Upstream commit ce465bf94b70f03136171a62b607864f00093b19 ]
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 <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/connect.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 6ad43ac129d2..18c7c6b2fe08 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -4463,11 +4463,13 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, unsigned int xid, struct cifs_tcon *tcon, struct cifs_sb_info *cifs_sb, - char *full_path) + char *full_path, + int added_treename) { int rc; char *s; char sep, tmp; + int skip = added_treename ? 1 : 0; sep = CIFS_DIR_SEP(cifs_sb); s = full_path; @@ -4482,7 +4484,14 @@ cifs_are_all_path_components_accessible(struct TCP_Server_Info *server, /* next separator */ while (*s && *s != sep) s++; - + /* + * if the treename is added, we then have to skip the first + * part within the separators + */ + if (skip) { + skip = 0; + continue; + } /* * temporarily null-terminate the path at the end of * the current component @@ -4530,8 +4539,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol, if (rc != -EREMOTE) { rc = cifs_are_all_path_components_accessible(server, xid, tcon, - cifs_sb, - full_path); + cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS); if (rc != 0) { cifs_dbg(VFS, "cannot query dirs between root and final path, " "enabling CIFS_MOUNT_USE_PREFIX_PATH\n"); |