Skip to content

Commit 13c0a74

Browse files
sprasad-microsoftsmfrench
authored andcommitted
cifs: make sure server interfaces are requested only for SMB3+
Some code paths for querying server interfaces make a false assumption that it will only get called for SMB3+. Since this function now can get called from a generic code paths, the correct thing to do is to have specific handler for this functionality per SMB dialect, and call this handler. This change adds such a handler and implements this handler only for SMB 3.0 and 3.1.1. Cc: stable@vger.kernel.org Cc: Jan Čermák <sairon@sairon.cz> Reported-by: Paulo Alcantara <pc@manguebit.com> Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent dc52877 commit 13c0a74

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

fs/smb/client/cifsglob.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ struct smb_version_operations {
355355
/* informational QFS call */
356356
void (*qfs_tcon)(const unsigned int, struct cifs_tcon *,
357357
struct cifs_sb_info *);
358+
/* query for server interfaces */
359+
int (*query_server_interfaces)(const unsigned int, struct cifs_tcon *,
360+
bool);
358361
/* check if a path is accessible or not */
359362
int (*is_path_accessible)(const unsigned int, struct cifs_tcon *,
360363
struct cifs_sb_info *, const char *);

fs/smb/client/connect.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,16 @@ static void smb2_query_server_interfaces(struct work_struct *work)
123123
struct cifs_tcon *tcon = container_of(work,
124124
struct cifs_tcon,
125125
query_interfaces.work);
126+
struct TCP_Server_Info *server = tcon->ses->server;
126127

127128
/*
128129
* query server network interfaces, in case they change
129130
*/
131+
if (!server->ops->query_server_interfaces)
132+
return;
133+
130134
xid = get_xid();
131-
rc = SMB3_request_interfaces(xid, tcon, false);
135+
rc = server->ops->query_server_interfaces(xid, tcon, false);
132136
free_xid(xid);
133137

134138
if (rc) {

fs/smb/client/smb2ops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5290,6 +5290,7 @@ struct smb_version_operations smb30_operations = {
52905290
.tree_connect = SMB2_tcon,
52915291
.tree_disconnect = SMB2_tdis,
52925292
.qfs_tcon = smb3_qfs_tcon,
5293+
.query_server_interfaces = SMB3_request_interfaces,
52935294
.is_path_accessible = smb2_is_path_accessible,
52945295
.can_echo = smb2_can_echo,
52955296
.echo = SMB2_echo,
@@ -5405,6 +5406,7 @@ struct smb_version_operations smb311_operations = {
54055406
.tree_connect = SMB2_tcon,
54065407
.tree_disconnect = SMB2_tdis,
54075408
.qfs_tcon = smb3_qfs_tcon,
5409+
.query_server_interfaces = SMB3_request_interfaces,
54085410
.is_path_accessible = smb2_is_path_accessible,
54095411
.can_echo = smb2_can_echo,
54105412
.echo = SMB2_echo,

fs/smb/client/smb2pdu.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,15 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
409409
spin_unlock(&ses->ses_lock);
410410

411411
if (!rc &&
412-
(server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
412+
(server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL) &&
413+
server->ops->query_server_interfaces) {
413414
mutex_unlock(&ses->session_mutex);
414415

415416
/*
416417
* query server network interfaces, in case they change
417418
*/
418419
xid = get_xid();
419-
rc = SMB3_request_interfaces(xid, tcon, false);
420+
rc = server->ops->query_server_interfaces(xid, tcon, false);
420421
free_xid(xid);
421422

422423
if (rc == -EOPNOTSUPP && ses->chan_count > 1) {

0 commit comments

Comments
 (0)