]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cifs: support reconnect with alternate password for SMB1
authorMeetakshi Setiya <msetiya@microsoft.com>
Fri, 10 Jan 2025 12:10:27 +0000 (07:10 -0500)
committerSteve French <stfrench@microsoft.com>
Mon, 13 Jan 2025 05:20:53 +0000 (23:20 -0600)
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>
fs/smb/client/cifssmb.c

index 6cb1e81993f89bf695f034bb8d7d4928bd6f4fc3..ab0b949924d77d4c39921a3ade624fc63f605495 100644 (file)
@@ -152,8 +152,17 @@ again:
        spin_unlock(&ses->ses_lock);
 
        rc = cifs_negotiate_protocol(0, ses, server);
-       if (!rc)
+       if (!rc) {
                rc = cifs_setup_session(0, ses, server, ses->local_nls);
+               if ((rc == -EACCES) || (rc == -EHOSTDOWN) || (rc == -EKEYREVOKED)) {
+                       /*
+                        * Try alternate password for next reconnect if an alternate
+                        * password is available.
+                        */
+                       if (ses->password2)
+                               swap(ses->password2, ses->password);
+               }
+       }
 
        /* do we need to reconnect tcon? */
        if (rc || !tcon->need_reconnect) {