cifs: populate empty hostnames for extra channels

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: 5112d80c16 ("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>
This commit is contained in:
Shyam Prasad N 2022-06-06 09:52:46 +00:00 committed by Steve French
parent 8ea21823aa
commit 4c14d7043f
2 changed files with 8 additions and 1 deletions

View file

@ -97,6 +97,10 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
if (!server->hostname) if (!server->hostname)
return -EINVAL; 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; len = strlen(server->hostname) + 3;
unc = kmalloc(len, GFP_KERNEL); unc = kmalloc(len, GFP_KERNEL);

View file

@ -301,7 +301,10 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
/* Auth */ /* Auth */
ctx.domainauto = ses->domainAuto; ctx.domainauto = ses->domainAuto;
ctx.domainname = ses->domainName; ctx.domainname = ses->domainName;
ctx.server_hostname = ses->server->hostname;
/* no hostname for extra channels */
ctx.server_hostname = "";
ctx.username = ses->user_name; ctx.username = ses->user_name;
ctx.password = ses->password; ctx.password = ses->password;
ctx.sectype = ses->sectype; ctx.sectype = ses->sectype;