Skip to content

Commit 6586c4d

Browse files
committed
Merge tag '6.3-rc6-ksmbd-server-fix' of git://git.samba.org/ksmbd
Pull ksmbd server fix from Steve French: "smb311 server preauth integrity negotiate context parsing fix (check for out of bounds access)" * tag '6.3-rc6-ksmbd-server-fix' of git://git.samba.org/ksmbd: ksmbd: avoid out of bounds access in decode_preauth_ctxt()
2 parents 3e7bb4f + e7067a4 commit 6586c4d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

fs/ksmbd/smb2pdu.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -876,17 +876,21 @@ static void assemble_neg_contexts(struct ksmbd_conn *conn,
876876
}
877877

878878
static __le32 decode_preauth_ctxt(struct ksmbd_conn *conn,
879-
struct smb2_preauth_neg_context *pneg_ctxt)
879+
struct smb2_preauth_neg_context *pneg_ctxt,
880+
int len_of_ctxts)
880881
{
881-
__le32 err = STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP;
882+
/*
883+
* sizeof(smb2_preauth_neg_context) assumes SMB311_SALT_SIZE Salt,
884+
* which may not be present. Only check for used HashAlgorithms[1].
885+
*/
886+
if (len_of_ctxts < MIN_PREAUTH_CTXT_DATA_LEN)
887+
return STATUS_INVALID_PARAMETER;
882888

883-
if (pneg_ctxt->HashAlgorithms == SMB2_PREAUTH_INTEGRITY_SHA512) {
884-
conn->preauth_info->Preauth_HashId =
885-
SMB2_PREAUTH_INTEGRITY_SHA512;
886-
err = STATUS_SUCCESS;
887-
}
889+
if (pneg_ctxt->HashAlgorithms != SMB2_PREAUTH_INTEGRITY_SHA512)
890+
return STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP;
888891

889-
return err;
892+
conn->preauth_info->Preauth_HashId = SMB2_PREAUTH_INTEGRITY_SHA512;
893+
return STATUS_SUCCESS;
890894
}
891895

892896
static void decode_encrypt_ctxt(struct ksmbd_conn *conn,
@@ -1014,7 +1018,8 @@ static __le32 deassemble_neg_contexts(struct ksmbd_conn *conn,
10141018
break;
10151019

10161020
status = decode_preauth_ctxt(conn,
1017-
(struct smb2_preauth_neg_context *)pctx);
1021+
(struct smb2_preauth_neg_context *)pctx,
1022+
len_of_ctxts);
10181023
if (status != STATUS_SUCCESS)
10191024
break;
10201025
} else if (pctx->ContextType == SMB2_ENCRYPTION_CAPABILITIES) {

0 commit comments

Comments
 (0)