mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
smb: client: Fix match_session bug preventing session reuse
[ Upstream commit 605b249ea96770ac4fac4b8510a99e0f8442be5e ] 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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
98bbcf4cca
commit
dda134d117
@@ -1881,9 +1881,8 @@ out_err:
|
|||||||
/* this function must be called with ses_lock and chan_lock held */
|
/* this function must be called with ses_lock and chan_lock held */
|
||||||
static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx)
|
static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx)
|
||||||
{
|
{
|
||||||
if (ctx->sectype != Unspecified &&
|
struct TCP_Server_Info *server = ses->server;
|
||||||
ctx->sectype != ses->sectype)
|
enum securityEnum ctx_sec, ses_sec;
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If an existing session is limited to less channels than
|
* If an existing session is limited to less channels than
|
||||||
@@ -1892,11 +1891,20 @@ static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx)
|
|||||||
if (ses->chan_max < ctx->max_channels)
|
if (ses->chan_max < ctx->max_channels)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (ses->sectype) {
|
ctx_sec = server->ops->select_sectype(server, ctx->sectype);
|
||||||
|
ses_sec = server->ops->select_sectype(server, ses->sectype);
|
||||||
|
|
||||||
|
if (ctx_sec != ses_sec)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
switch (ctx_sec) {
|
||||||
|
case IAKerb:
|
||||||
case Kerberos:
|
case Kerberos:
|
||||||
if (!uid_eq(ctx->cred_uid, ses->cred_uid))
|
if (!uid_eq(ctx->cred_uid, ses->cred_uid))
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
case NTLMv2:
|
||||||
|
case RawNTLMSSP:
|
||||||
default:
|
default:
|
||||||
/* NULL username means anonymous session */
|
/* NULL username means anonymous session */
|
||||||
if (ses->user_name == NULL) {
|
if (ses->user_name == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user