mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
smb: client: fix iface port assignment in parse_server_interfaces
parse_server_interfaces() initializes interface socket addresses with
CIFS_PORT. When the mount uses a non-default port this overwrites the
configured destination port.
Later, cifs_chan_update_iface() copies this sockaddr into server->dstaddr,
causing reconnect attempts to use the wrong port after server interface
updates.
Use the existing port from server->dstaddr instead.
Cc: stable@vger.kernel.org
Fixes: fe856be475 ("CIFS: parse and store info on iface queries")
Tested-by: Dr. Thomas Orgis <thomas.orgis@uni-hamburg.de>
Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
committed by
Steve French
parent
88d37abb36
commit
d4c7210d2f
@@ -628,6 +628,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
|
||||
struct smb_sockaddr_in6 *p6;
|
||||
struct cifs_server_iface *info = NULL, *iface = NULL, *niface = NULL;
|
||||
struct cifs_server_iface tmp_iface;
|
||||
__be16 port;
|
||||
ssize_t bytes_left;
|
||||
size_t next = 0;
|
||||
int nb_iface = 0;
|
||||
@@ -662,6 +663,15 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
|
||||
goto out;
|
||||
}
|
||||
|
||||
spin_lock(&ses->server->srv_lock);
|
||||
if (ses->server->dstaddr.ss_family == AF_INET)
|
||||
port = ((struct sockaddr_in *)&ses->server->dstaddr)->sin_port;
|
||||
else if (ses->server->dstaddr.ss_family == AF_INET6)
|
||||
port = ((struct sockaddr_in6 *)&ses->server->dstaddr)->sin6_port;
|
||||
else
|
||||
port = cpu_to_be16(CIFS_PORT);
|
||||
spin_unlock(&ses->server->srv_lock);
|
||||
|
||||
while (bytes_left >= (ssize_t)sizeof(*p)) {
|
||||
memset(&tmp_iface, 0, sizeof(tmp_iface));
|
||||
/* default to 1Gbps when link speed is unset */
|
||||
@@ -682,7 +692,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
|
||||
memcpy(&addr4->sin_addr, &p4->IPv4Address, 4);
|
||||
|
||||
/* [MS-SMB2] 2.2.32.5.1.1 Clients MUST ignore these */
|
||||
addr4->sin_port = cpu_to_be16(CIFS_PORT);
|
||||
addr4->sin_port = port;
|
||||
|
||||
cifs_dbg(FYI, "%s: ipv4 %pI4\n", __func__,
|
||||
&addr4->sin_addr);
|
||||
@@ -696,7 +706,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
|
||||
/* [MS-SMB2] 2.2.32.5.1.2 Clients MUST ignore these */
|
||||
addr6->sin6_flowinfo = 0;
|
||||
addr6->sin6_scope_id = 0;
|
||||
addr6->sin6_port = cpu_to_be16(CIFS_PORT);
|
||||
addr6->sin6_port = port;
|
||||
|
||||
cifs_dbg(FYI, "%s: ipv6 %pI6\n", __func__,
|
||||
&addr6->sin6_addr);
|
||||
|
||||
Reference in New Issue
Block a user