Skip to content

Commit 18d72c2

Browse files
committed
cifs: support reconnect with alternate password for SMB1
JIRA: https://issues.redhat.com/browse/RHEL-76046 commit b8ed9da Author: Meetakshi Setiya <msetiya@microsoft.com> Date: Fri Jan 10 07:10:27 2025 -0500 cifs: support reconnect with alternate password for SMB1 SMB1 shares the mount and remount code paths with SMB2/3 and already supports password rotation in some scenarios. This patch extends the password rotation support to SMB1 reconnects as well. Cc: stable@vger.kernel.org Signed-off-by: Meetakshi Setiya <msetiya@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Paulo Alcantara <paalcant@redhat.com>
1 parent 7753ce5 commit 18d72c2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

fs/smb/client/cifssmb.c

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

150150
rc = cifs_negotiate_protocol(0, ses, server);
151-
if (!rc)
151+
if (!rc) {
152152
rc = cifs_setup_session(0, ses, server, ses->local_nls);
153+
if ((rc == -EACCES) || (rc == -EHOSTDOWN) || (rc == -EKEYREVOKED)) {
154+
/*
155+
* Try alternate password for next reconnect if an alternate
156+
* password is available.
157+
*/
158+
if (ses->password2)
159+
swap(ses->password2, ses->password);
160+
}
161+
}
153162

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

0 commit comments

Comments
 (0)