summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPaulo Alcantara <pc@cjr.nz>2022-12-17 03:25:38 +0100
committerSteve French <stfrench@microsoft.com>2022-12-19 15:03:12 +0100
commit466611e4af8252dce253cfaebdc7b0019acdbe7e (patch)
tree33bf5abfacfc4137cb670ff568329982c7bc040f /fs
parentcifs: fix confusing debug message (diff)
downloadlinux-466611e4af8252dce253cfaebdc7b0019acdbe7e.tar.xz
linux-466611e4af8252dce253cfaebdc7b0019acdbe7e.zip
cifs: fix source pathname comparison of dfs supers
We store the TCP_Server_Info::origin_fullpath path canonicalised (e.g. with '\\' path separators), so ignore separators when comparing it with smb3_fs_context::source. Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/connect.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 069e894d5917..a66c7422b8bc 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1412,6 +1412,20 @@ match_security(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
return true;
}
+static bool dfs_src_pathname_equal(const char *s1, const char *s2)
+{
+ if (strlen(s1) != strlen(s2))
+ return false;
+ for (; *s1; s1++, s2++) {
+ if (*s1 == '/' || *s1 == '\\') {
+ if (*s2 != '/' && *s2 != '\\')
+ return false;
+ } else if (tolower(*s1) != tolower(*s2))
+ return false;
+ }
+ return true;
+}
+
/* this function must be called with srv_lock held */
static int match_server(struct TCP_Server_Info *server, struct smb3_fs_context *ctx,
bool dfs_super_cmp)
@@ -1449,7 +1463,7 @@ static int match_server(struct TCP_Server_Info *server, struct smb3_fs_context *
*/
if (dfs_super_cmp) {
if (!ctx->source || !server->origin_fullpath ||
- strcasecmp(server->origin_fullpath, ctx->source))
+ !dfs_src_pathname_equal(server->origin_fullpath, ctx->source))
return 0;
} else {
/* Skip addr, hostname and port matching for DFS connections */