Skip to content

Commit ca24634

Browse files
decarvgregkh
authored andcommitted
smb: client: Fix match_session bug preventing session reuse
[ Upstream commit 605b249 ] Fix a bug in match_session() that can causes the session to not be reused in some cases. Reproduction steps: mount.cifs //server/share /mnt/a -o credentials=creds mount.cifs //server/share /mnt/b -o credentials=creds,sec=ntlmssp cat /proc/fs/cifs/DebugData | grep SessionId | wc -l mount.cifs //server/share /mnt/b -o credentials=creds,sec=ntlmssp mount.cifs //server/share /mnt/a -o credentials=creds cat /proc/fs/cifs/DebugData | grep SessionId | wc -l Cc: stable@vger.kernel.org Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de> Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5a49a52 commit ca24634

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

fs/smb/client/connect.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,9 +1873,8 @@ static int match_session(struct cifs_ses *ses,
18731873
struct smb3_fs_context *ctx,
18741874
bool match_super)
18751875
{
1876-
if (ctx->sectype != Unspecified &&
1877-
ctx->sectype != ses->sectype)
1878-
return 0;
1876+
struct TCP_Server_Info *server = ses->server;
1877+
enum securityEnum ctx_sec, ses_sec;
18791878

18801879
if (!match_super && ctx->dfs_root_ses != ses->dfs_root_ses)
18811880
return 0;
@@ -1887,11 +1886,20 @@ static int match_session(struct cifs_ses *ses,
18871886
if (ses->chan_max < ctx->max_channels)
18881887
return 0;
18891888

1890-
switch (ses->sectype) {
1889+
ctx_sec = server->ops->select_sectype(server, ctx->sectype);
1890+
ses_sec = server->ops->select_sectype(server, ses->sectype);
1891+
1892+
if (ctx_sec != ses_sec)
1893+
return 0;
1894+
1895+
switch (ctx_sec) {
1896+
case IAKerb:
18911897
case Kerberos:
18921898
if (!uid_eq(ctx->cred_uid, ses->cred_uid))
18931899
return 0;
18941900
break;
1901+
case NTLMv2:
1902+
case RawNTLMSSP:
18951903
default:
18961904
/* NULL username means anonymous session */
18971905
if (ses->user_name == NULL) {

0 commit comments

Comments
 (0)