Skip to content

Commit

Permalink
Merged PR 5400: SecurityPkg: Tcg2Smm: Added communicate buffer check
Browse files Browse the repository at this point in the history
Added communicate buffer check for the Tcg2Smm driver in lieu of the legacy MmOutsideValid check.
  • Loading branch information
kuqin12 authored and kenlautner committed Dec 18, 2023
1 parent e48cd93 commit 4d4080f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ TpmNvsCommunciate (
return EFI_ACCESS_DENIED;
}

if (!IsBufferOutsideMmValid ((UINTN)CommBuffer, TempCommBufferSize)) {
if (!IsCommBufferValid ((UINTN)CommBuffer, TempCommBufferSize)) {
DEBUG ((DEBUG_ERROR, "[%a] - MM Communication buffer in invalid location!\n", __func__));
return EFI_ACCESS_DENIED;
}
Expand Down
16 changes: 16 additions & 0 deletions SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ IsBufferOutsideMmValid (
IN UINT64 Length
);

/**
This function is wrapper function to validate the communicate buffer.
@param Buffer The buffer start address to be checked.
@param Length The buffer length to be checked.
@retval TRUE This buffer is valid per processor architecture and not overlap with SMRAM.
@retval FALSE This buffer is not valid per processor architecture or overlap with SMRAM.
**/
BOOLEAN
EFIAPI
IsCommBufferValid (
IN EFI_PHYSICAL_ADDRESS Buffer,
IN UINT64 Length
);

/**
The driver's common initialization routine.
Expand Down
19 changes: 19 additions & 0 deletions SecurityPkg/Tcg/Tcg2Smm/Tcg2StandaloneMm.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ IsBufferOutsideMmValid (
return MmIsBufferOutsideMmValid (Buffer, Length);
}

/**
This function is wrapper function to validate the communicate buffer.
@param Buffer The buffer start address to be checked.
@param Length The buffer length to be checked.
@retval TRUE This buffer is valid per processor architecture and not overlap with SMRAM.
@retval FALSE This buffer is not valid per processor architecture or overlap with SMRAM.
**/
BOOLEAN
EFIAPI
IsCommBufferValid (
IN EFI_PHYSICAL_ADDRESS Buffer,
IN UINT64 Length
)
{
return MmCommBufferValid (Buffer, Length);
}

/**
The driver's entry point.
Expand Down
19 changes: 19 additions & 0 deletions SecurityPkg/Tcg/Tcg2Smm/Tcg2TraditionalMm.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ IsBufferOutsideMmValid (
return SmmIsBufferOutsideSmmValid (Buffer, Length);
}

/**
This function is wrapper function to validate the communicate buffer.
@param Buffer The buffer start address to be checked.
@param Length The buffer length to be checked.
@retval TRUE This buffer is valid per processor architecture and not overlap with SMRAM.
@retval FALSE This buffer is not valid per processor architecture or overlap with SMRAM.
**/
BOOLEAN
EFIAPI
IsCommBufferValid (
IN EFI_PHYSICAL_ADDRESS Buffer,
IN UINT64 Length
)
{
return SmmIsBufferOutsideSmmValid (Buffer, Length);
}

/**
The driver's entry point.
Expand Down

0 comments on commit 4d4080f

Please sign in to comment.