]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
0234a820b1db7af412bcb8639e78129ff9015b23
[thirdparty/kernel/stable-queue.git] /
1 From 20b1aa912316ffb7fbb5f407f17c330f2a22ddff Mon Sep 17 00:00:00 2001
2 From: Meetakshi Setiya <msetiya@microsoft.com>
3 Date: Wed, 8 Jan 2025 05:10:34 -0500
4 Subject: smb: client: sync the root session and superblock context passwords before automounting
5
6 From: Meetakshi Setiya <msetiya@microsoft.com>
7
8 commit 20b1aa912316ffb7fbb5f407f17c330f2a22ddff upstream.
9
10 In some cases, when password2 becomes the working password, the
11 client swaps the two password fields in the root session struct, but
12 not in the smb3_fs_context struct in cifs_sb. DFS automounts inherit
13 fs context from their parent mounts. Therefore, they might end up
14 getting the passwords in the stale order.
15 The automount should succeed, because the mount function will end up
16 retrying with the actual password anyway. But to reduce these
17 unnecessary session setup retries for automounts, we can sync the
18 parent context's passwords with the root session's passwords before
19 duplicating it to the child's fs context.
20
21 Cc: stable@vger.kernel.org
22 Signed-off-by: Meetakshi Setiya <msetiya@microsoft.com>
23 Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
24 Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
25 Signed-off-by: Steve French <stfrench@microsoft.com>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27 ---
28 fs/smb/client/namespace.c | 19 ++++++++++++++++++-
29 1 file changed, 18 insertions(+), 1 deletion(-)
30
31 --- a/fs/smb/client/namespace.c
32 +++ b/fs/smb/client/namespace.c
33 @@ -196,11 +196,28 @@ static struct vfsmount *cifs_do_automoun
34 struct smb3_fs_context tmp;
35 char *full_path;
36 struct vfsmount *mnt;
37 + struct cifs_sb_info *mntpt_sb;
38 + struct cifs_ses *ses;
39
40 if (IS_ROOT(mntpt))
41 return ERR_PTR(-ESTALE);
42
43 - cur_ctx = CIFS_SB(mntpt->d_sb)->ctx;
44 + mntpt_sb = CIFS_SB(mntpt->d_sb);
45 + ses = cifs_sb_master_tcon(mntpt_sb)->ses;
46 + cur_ctx = mntpt_sb->ctx;
47 +
48 + /*
49 + * At this point, the root session should be in the mntpt sb. We should
50 + * bring the sb context passwords in sync with the root session's
51 + * passwords. This would help prevent unnecessary retries and password
52 + * swaps for automounts.
53 + */
54 + mutex_lock(&ses->session_mutex);
55 + rc = smb3_sync_session_ctx_passwords(mntpt_sb, ses);
56 + mutex_unlock(&ses->session_mutex);
57 +
58 + if (rc)
59 + return ERR_PTR(rc);
60
61 fc = fs_context_for_submount(path->mnt->mnt_sb->s_type, mntpt);
62 if (IS_ERR(fc))