summaryrefslogtreecommitdiff
path: root/fs/cifs/fs_context.c
diff options
context:
space:
mode:
authorShyam Prasad N <sprasad@microsoft.com>2021-10-14 11:52:39 +0000
committerSteve French <stfrench@microsoft.com>2021-11-02 13:12:55 -0500
commit7be3248f313930ff3d3436d4e9ddbe9fccc1f541 (patch)
tree59509a1b82e5b7f0d2568b6f524399d06d0cbb8f /fs/cifs/fs_context.c
parent3906fe9bb7f1a2c8667ae54e967dc8690824f4ea (diff)
cifs: To match file servers, make sure the server hostname matches
We generally rely on a bunch of factors to differentiate between servers. For example, IP address, port etc. For certain server types (like Azure), it is important to make sure that the server hostname matches too, even if the both hostnames currently resolve to the same IP address. Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> Cc: stable@vger.kernel.org Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/fs_context.c')
-rw-r--r--fs/cifs/fs_context.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 3109def8e199..4130908af8d7 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -318,6 +318,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
DUP_CTX_STR(mount_options);
DUP_CTX_STR(username);
DUP_CTX_STR(password);
+ DUP_CTX_STR(server_hostname);
DUP_CTX_STR(UNC);
DUP_CTX_STR(source);
DUP_CTX_STR(domainname);
@@ -456,6 +457,11 @@ smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)
if (!pos)
return -EINVAL;
+ /* record the server hostname */
+ ctx->server_hostname = kstrndup(devname + 2, pos - devname - 2, GFP_KERNEL);
+ if (!ctx->server_hostname)
+ return -ENOMEM;
+
/* skip past delimiter */
++pos;
@@ -1496,6 +1502,8 @@ smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx)
ctx->username = NULL;
kfree_sensitive(ctx->password);
ctx->password = NULL;
+ kfree(ctx->server_hostname);
+ ctx->server_hostname = NULL;
kfree(ctx->UNC);
ctx->UNC = NULL;
kfree(ctx->source);