Skip to content

Commit 605b249

Browse files
decarvSteve French
authored andcommitted
smb: client: Fix match_session bug preventing session reuse
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>
1 parent d5a30fd commit 605b249

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
@@ -1825,9 +1825,8 @@ static int match_session(struct cifs_ses *ses,
18251825
struct smb3_fs_context *ctx,
18261826
bool match_super)
18271827
{
1828-
if (ctx->sectype != Unspecified &&
1829-
ctx->sectype != ses->sectype)
1830-
return 0;
1828+
struct TCP_Server_Info *server = ses->server;
1829+
enum securityEnum ctx_sec, ses_sec;
18311830

18321831
if (!match_super && ctx->dfs_root_ses != ses->dfs_root_ses)
18331832
return 0;
@@ -1839,11 +1838,20 @@ static int match_session(struct cifs_ses *ses,
18391838
if (ses->chan_max < ctx->max_channels)
18401839
return 0;
18411840

1842-
switch (ses->sectype) {
1841+
ctx_sec = server->ops->select_sectype(server, ctx->sectype);
1842+
ses_sec = server->ops->select_sectype(server, ses->sectype);
1843+
1844+
if (ctx_sec != ses_sec)
1845+
return 0;
1846+
1847+
switch (ctx_sec) {
1848+
case IAKerb:
18431849
case Kerberos:
18441850
if (!uid_eq(ctx->cred_uid, ses->cred_uid))
18451851
return 0;
18461852
break;
1853+
case NTLMv2:
1854+
case RawNTLMSSP:
18471855
default:
18481856
/* NULL username means anonymous session */
18491857
if (ses->user_name == NULL) {

0 commit comments

Comments
 (0)