Skip to content

Commit 631f9de

Browse files
sprasad-microsoftgregkh
authored andcommitted
cifs: all initializations for tcon should happen in tcon_info_alloc
commit 74ebd02 upstream. Today, a few work structs inside tcon are initialized inside cifs_get_tcon and not in tcon_info_alloc. As a result, if a tcon is obtained from tcon_info_alloc, but not called as a part of cifs_get_tcon, we may trip over. Cc: <stable@vger.kernel.org> Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7b02e09 commit 631f9de

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

fs/smb/client/cifsproto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ extern int SendReceiveBlockingLock(const unsigned int xid,
136136
struct smb_hdr *out_buf,
137137
int *bytes_returned);
138138

139+
void smb2_query_server_interfaces(struct work_struct *work);
139140
void
140141
cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
141142
bool all_channels);

fs/smb/client/connect.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
113113
return rc;
114114
}
115115

116-
static void smb2_query_server_interfaces(struct work_struct *work)
116+
void smb2_query_server_interfaces(struct work_struct *work)
117117
{
118118
int rc;
119119
int xid;
@@ -2819,20 +2819,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
28192819
tcon->max_cached_dirs = ctx->max_cached_dirs;
28202820
tcon->nodelete = ctx->nodelete;
28212821
tcon->local_lease = ctx->local_lease;
2822-
INIT_LIST_HEAD(&tcon->pending_opens);
28232822
tcon->status = TID_GOOD;
28242823

2825-
INIT_DELAYED_WORK(&tcon->query_interfaces,
2826-
smb2_query_server_interfaces);
28272824
if (ses->server->dialect >= SMB30_PROT_ID &&
28282825
(ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
28292826
/* schedule query interfaces poll */
28302827
queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
28312828
(SMB_INTERFACE_POLL_INTERVAL * HZ));
28322829
}
2833-
#ifdef CONFIG_CIFS_DFS_UPCALL
2834-
INIT_DELAYED_WORK(&tcon->dfs_cache_work, dfs_cache_refresh);
2835-
#endif
28362830
spin_lock(&cifs_tcp_ses_lock);
28372831
list_add(&tcon->tcon_list, &ses->tcon_list);
28382832
spin_unlock(&cifs_tcp_ses_lock);

fs/smb/client/misc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ tcon_info_alloc(bool dir_leases_enabled, enum smb3_tcon_ref_trace trace)
148148
#ifdef CONFIG_CIFS_DFS_UPCALL
149149
INIT_LIST_HEAD(&ret_buf->dfs_ses_list);
150150
#endif
151+
INIT_LIST_HEAD(&ret_buf->pending_opens);
152+
INIT_DELAYED_WORK(&ret_buf->query_interfaces,
153+
smb2_query_server_interfaces);
154+
#ifdef CONFIG_CIFS_DFS_UPCALL
155+
INIT_DELAYED_WORK(&ret_buf->dfs_cache_work, dfs_cache_refresh);
156+
#endif
151157

152158
return ret_buf;
153159
}

0 commit comments

Comments
 (0)