mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 20:10:23 +09:00
ksmbd: avoid out of bounds access in decode_preauth_ctxt()
[ Upstream commit e7067a4462 ]
Confirm that the accessed pneg_ctxt->HashAlgorithms address sits within
the SMB request boundary; deassemble_neg_contexts() only checks that the
eight byte smb2_neg_context header + (client controlled) DataLength are
within the packet boundary, which is insufficient.
Checking for sizeof(struct smb2_preauth_neg_context) is overkill given
that the type currently assumes SMB311_SALT_SIZE bytes of trailing Salt.
Signed-off-by: David Disseldorp <ddiss@suse.de>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
921536046b
commit
39f5b4b313
@@ -907,17 +907,21 @@ static void assemble_neg_contexts(struct ksmbd_conn *conn,
|
||||
}
|
||||
|
||||
static __le32 decode_preauth_ctxt(struct ksmbd_conn *conn,
|
||||
struct smb2_preauth_neg_context *pneg_ctxt)
|
||||
struct smb2_preauth_neg_context *pneg_ctxt,
|
||||
int len_of_ctxts)
|
||||
{
|
||||
__le32 err = STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP;
|
||||
/*
|
||||
* sizeof(smb2_preauth_neg_context) assumes SMB311_SALT_SIZE Salt,
|
||||
* which may not be present. Only check for used HashAlgorithms[1].
|
||||
*/
|
||||
if (len_of_ctxts < 6)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
if (pneg_ctxt->HashAlgorithms == SMB2_PREAUTH_INTEGRITY_SHA512) {
|
||||
conn->preauth_info->Preauth_HashId =
|
||||
SMB2_PREAUTH_INTEGRITY_SHA512;
|
||||
err = STATUS_SUCCESS;
|
||||
}
|
||||
if (pneg_ctxt->HashAlgorithms != SMB2_PREAUTH_INTEGRITY_SHA512)
|
||||
return STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP;
|
||||
|
||||
return err;
|
||||
conn->preauth_info->Preauth_HashId = SMB2_PREAUTH_INTEGRITY_SHA512;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void decode_encrypt_ctxt(struct ksmbd_conn *conn,
|
||||
@@ -1045,7 +1049,8 @@ static __le32 deassemble_neg_contexts(struct ksmbd_conn *conn,
|
||||
break;
|
||||
|
||||
status = decode_preauth_ctxt(conn,
|
||||
(struct smb2_preauth_neg_context *)pctx);
|
||||
(struct smb2_preauth_neg_context *)pctx,
|
||||
len_of_ctxts);
|
||||
if (status != STATUS_SUCCESS)
|
||||
break;
|
||||
} else if (pctx->ContextType == SMB2_ENCRYPTION_CAPABILITIES) {
|
||||
|
||||
Reference in New Issue
Block a user