Skip to content

Commit 9ca2729

Browse files
committed
Merge tag '6.13-rc7-SMB3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: - fix double free when reconnect racing with closing session - fix SMB1 reconnect with password rotation * tag '6.13-rc7-SMB3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: smb: client: fix double free of TCP_Server_Info::hostname cifs: support reconnect with alternate password for SMB1
2 parents 9bffa1a + fa2f990 commit 9ca2729

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

fs/smb/client/cifssmb.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,17 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
152152
spin_unlock(&ses->ses_lock);
153153

154154
rc = cifs_negotiate_protocol(0, ses, server);
155-
if (!rc)
155+
if (!rc) {
156156
rc = cifs_setup_session(0, ses, server, ses->local_nls);
157+
if ((rc == -EACCES) || (rc == -EHOSTDOWN) || (rc == -EKEYREVOKED)) {
158+
/*
159+
* Try alternate password for next reconnect if an alternate
160+
* password is available.
161+
*/
162+
if (ses->password2)
163+
swap(ses->password2, ses->password);
164+
}
165+
}
157166

158167
/* do we need to reconnect tcon? */
159168
if (rc || !tcon->need_reconnect) {

fs/smb/client/connect.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ clean_demultiplex_info(struct TCP_Server_Info *server)
10441044
/* Release netns reference for this server. */
10451045
put_net(cifs_net_ns(server));
10461046
kfree(server->leaf_fullpath);
1047+
kfree(server->hostname);
10471048
kfree(server);
10481049

10491050
length = atomic_dec_return(&tcpSesAllocCount);
@@ -1670,8 +1671,6 @@ cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect)
16701671
kfree_sensitive(server->session_key.response);
16711672
server->session_key.response = NULL;
16721673
server->session_key.len = 0;
1673-
kfree(server->hostname);
1674-
server->hostname = NULL;
16751674

16761675
task = xchg(&server->tsk, NULL);
16771676
if (task)

0 commit comments

Comments
 (0)