summaryrefslogtreecommitdiffstats
path: root/fs/smb/client/cifssmb.c
diff options
context:
space:
mode:
authorMeetakshi Setiya <msetiya@microsoft.com>2025-01-10 13:10:27 +0100
committerSteve French <stfrench@microsoft.com>2025-01-13 06:20:53 +0100
commitb8ed9da102beb2d0926a1d7a7e652392190151c0 (patch)
tree8d24836ba4d9fbf12c41b4a980efad1b60e84d95 /fs/smb/client/cifssmb.c
parentLinux 6.13-rc7 (diff)
downloadlinux-b8ed9da102beb2d0926a1d7a7e652392190151c0.tar.xz
linux-b8ed9da102beb2d0926a1d7a7e652392190151c0.zip
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>
Diffstat (limited to '')
-rw-r--r--fs/smb/client/cifssmb.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c
index 6cb1e81993f8..ab0b949924d7 100644
--- a/fs/smb/client/cifssmb.c
+++ b/fs/smb/client/cifssmb.c
@@ -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) {