]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cifs: populate empty hostnames for extra channels
authorShyam Prasad N <sprasad@microsoft.com>
Mon, 6 Jun 2022 09:52:46 +0000 (09:52 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 16:45:16 +0000 (18:45 +0200)
commit 4c14d7043fede258957d7b01da0cad2d9fe3a205 upstream.

Currently, the secondary channels of a multichannel session
also get hostname populated based on the info in primary channel.
However, this will end up with a wrong resolution of hostname to
IP address during reconnect.

This change fixes this by not populating hostname info for all
secondary channels.

Fixes: 5112d80c162f ("cifs: populate server_hostname for extra channels")
Cc: stable@vger.kernel.org
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/connect.c
fs/cifs/sess.c

index 4a0b44052c350f1f72d089be81ce5abe3ce0d4eb..98e4a1aa898e2ecaac0be00a3210c3aebc419582 100644 (file)
@@ -97,6 +97,10 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
        if (!server->hostname)
                return -EINVAL;
 
+       /* if server hostname isn't populated, there's nothing to do here */
+       if (server->hostname[0] == '\0')
+               return 0;
+
        len = strlen(server->hostname) + 3;
 
        unc = kmalloc(len, GFP_KERNEL);
index 20f3abc4026783b4e80d15a5ffde0c34bdbe5379..83b9047c945aa8d221b43aab8ed8232e89b96888 100644 (file)
@@ -274,7 +274,10 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
        /* Auth */
        ctx.domainauto = ses->domainAuto;
        ctx.domainname = ses->domainName;
-       ctx.server_hostname = ses->server->hostname;
+
+       /* no hostname for extra channels */
+       ctx.server_hostname = "";
+
        ctx.username = ses->user_name;
        ctx.password = ses->password;
        ctx.sectype = ses->sectype;