SecurityPkg: DxeTpm2MeasureBootLib: SECURITY PATCH 4117 - CVE 2022-36763
This commit contains the patch files and tests for DxeTpm2MeasureBootLib CVE 2022-36763. Cc: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Doug Flick [MSFT] <doug.edk2@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
a4b8944e27
commit
2244465432
@ -0,0 +1,113 @@
|
||||
/** @file
|
||||
This file includes the function prototypes for the sanitization functions.
|
||||
|
||||
These are those functions:
|
||||
|
||||
DxeTpm2MeasureBootLibImageRead() function will make sure the PE/COFF image content
|
||||
read is within the image buffer.
|
||||
|
||||
Tcg2MeasureGptTable() function will receive untrusted GPT partition table, and parse
|
||||
partition data carefully.
|
||||
|
||||
Copyright (c) Microsoft Corporation.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef DXE_TPM2_MEASURE_BOOT_LIB_SANITATION_
|
||||
#define DXE_TPM2_MEASURE_BOOT_LIB_SANITATION_
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Uefi/UefiSpec.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <IndustryStandard/UefiTcgPlatform.h>
|
||||
#include <Protocol/Tcg2Protocol.h>
|
||||
|
||||
/**
|
||||
This function will validate the EFI_PARTITION_TABLE_HEADER structure is safe to parse
|
||||
However this function will not attempt to verify the validity of the GPT partition
|
||||
It will check the following:
|
||||
- Signature
|
||||
- Revision
|
||||
- AlternateLBA
|
||||
- FirstUsableLBA
|
||||
- LastUsableLBA
|
||||
- PartitionEntryLBA
|
||||
- NumberOfPartitionEntries
|
||||
- SizeOfPartitionEntry
|
||||
- BlockIo
|
||||
|
||||
@param[in] PrimaryHeader
|
||||
Pointer to the EFI_PARTITION_TABLE_HEADER structure.
|
||||
|
||||
@param[in] BlockIo
|
||||
Pointer to the EFI_BLOCK_IO_PROTOCOL structure.
|
||||
|
||||
@retval EFI_SUCCESS
|
||||
The EFI_PARTITION_TABLE_HEADER structure is valid.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER
|
||||
The EFI_PARTITION_TABLE_HEADER structure is invalid.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SanitizeEfiPartitionTableHeader (
|
||||
IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader,
|
||||
IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo
|
||||
);
|
||||
|
||||
/**
|
||||
This function will validate that the allocation size from the primary header is sane
|
||||
It will check the following:
|
||||
- AllocationSize does not overflow
|
||||
|
||||
@param[in] PrimaryHeader
|
||||
Pointer to the EFI_PARTITION_TABLE_HEADER structure.
|
||||
|
||||
@param[out] AllocationSize
|
||||
Pointer to the allocation size.
|
||||
|
||||
@retval EFI_SUCCESS
|
||||
The allocation size is valid.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES
|
||||
The allocation size is invalid.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SanitizePrimaryHeaderAllocationSize (
|
||||
IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader,
|
||||
OUT UINT32 *AllocationSize
|
||||
);
|
||||
|
||||
/**
|
||||
This function will validate that the Gpt Event Size calculated from the primary header is sane
|
||||
It will check the following:
|
||||
- EventSize does not overflow
|
||||
|
||||
Important: This function includes the entire length of the allocated space, including
|
||||
(sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event)) . When hashing the buffer allocated with this
|
||||
size, the caller must subtract the size of the (sizeof (EFI_TCG2_EVENT) - sizeof (Tcg2Event->Event))
|
||||
from the size of the buffer before hashing.
|
||||
|
||||
@param[in] PrimaryHeader - Pointer to the EFI_PARTITION_TABLE_HEADER structure.
|
||||
@param[in] NumberOfPartition - Number of partitions.
|
||||
@param[out] EventSize - Pointer to the event size.
|
||||
|
||||
@retval EFI_SUCCESS
|
||||
The event size is valid.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES
|
||||
Overflow would have occurred.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER
|
||||
One of the passed parameters was invalid.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SanitizePrimaryHeaderGptEventSize (
|
||||
IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader,
|
||||
IN UINTN NumberOfPartition,
|
||||
OUT UINT32 *EventSize
|
||||
);
|
||||
|
||||
#endif // DXE_TPM2_MEASURE_BOOT_LIB_SANITATION_
|
Reference in New Issue
Block a user