]> www.infradead.org Git - users/jedix/linux-maple.git/commit
cifs: during remount, make sure passwords are in sync
authorShyam Prasad N <sprasad@microsoft.com>
Wed, 30 Oct 2024 06:45:50 +0000 (06:45 +0000)
committerSteve French <stfrench@microsoft.com>
Thu, 28 Nov 2024 15:51:07 +0000 (09:51 -0600)
commit0f0e357902957fba28ed31bde0d6921c6bd1485d
tree006def613def03cf43bab299b9ffcbc2cacaa505
parentb9aef1b13a0a92aa7058ba235afb24b5b89153ca
cifs: during remount, make sure passwords are in sync

This fixes scenarios where remount can overwrite the only currently
working password, breaking reconnect.

We recently introduced a password2 field in both ses and ctx structs.
This was done so as to allow the client to rotate passwords for a mount
without any downtime. However, when the client transparently handles
password rotation, it can swap the values of the two password fields
in the ses struct, but not in smb3_fs_context struct that hangs off
cifs_sb. This can lead to a situation where a remount unintentionally
overwrites a working password in the ses struct.

In order to fix this, we first get the passwords in ctx struct
in-sync with ses struct, before replacing them with what the passwords
that could be passed as a part of remount.

Also, in order to avoid race condition between smb2_reconnect and
smb3_reconfigure, we make sure to lock session_mutex before changing
password and password2 fields of the ses structure.

Fixes: 35f834265e0d ("smb3: fix broken reconnect when password changing on the server by allowing password rotation")
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Meetakshi Setiya <msetiya@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/fs_context.c
fs/smb/client/fs_context.h