summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Core
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-02-23 03:09:55 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-02-23 03:09:55 +0000
commit89cd8129f72bc2c445839efcddace560bfdfeb8f (patch)
tree250846f6b5adee2d466831f6c827610698889cec /MdeModulePkg/Core
parent59424fff04b0d47b796e91b47d6826db6aac1721 (diff)
downloadedk2-platforms-89cd8129f72bc2c445839efcddace560bfdfeb8f.tar.xz
Update PeiCore and DxeCore to verify FFS data checksum.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11332 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Core')
-rw-r--r--MdeModulePkg/Core/Dxe/FwVol/Ffs.c15
-rw-r--r--MdeModulePkg/Core/Pei/FwVol/FwVol.c11
2 files changed, 21 insertions, 5 deletions
diff --git a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c
index aec08b221b..5eb22d0ac5 100644
--- a/MdeModulePkg/Core/Dxe/FwVol/Ffs.c
+++ b/MdeModulePkg/Core/Dxe/FwVol/Ffs.c
@@ -217,6 +217,8 @@ IsValidFfsFile (
)
{
EFI_FFS_FILE_STATE FileState;
+ UINT8 DataCheckSum;
+ UINT32 FileLength;
FileState = GetFileState (ErasePolarity, FfsHeader);
switch (FileState) {
@@ -224,11 +226,14 @@ IsValidFfsFile (
case EFI_FILE_DELETED:
case EFI_FILE_DATA_VALID:
case EFI_FILE_MARKED_FOR_UPDATE:
- //
- // Some other vliadation like file content checksum might be done here.
- // For performance issue, Tiano only do FileState check.
- //
- return TRUE;
+ DataCheckSum = FFS_FIXED_CHECKSUM;
+ FileLength = *(UINT32 *)(FfsHeader->Size) & 0x00FFFFFF;
+ if ((FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) == FFS_ATTRIB_CHECKSUM) {
+ DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *)FfsHeader + sizeof(EFI_FFS_FILE_HEADER), FileLength - sizeof(EFI_FFS_FILE_HEADER));
+ }
+ if (FfsHeader->IntegrityCheck.Checksum.File == DataCheckSum) {
+ return TRUE;
+ }
default:
return FALSE;
diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
index c40f0ea86b..941657c07f 100644
--- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c
@@ -162,6 +162,7 @@ FindFileEx (
UINT64 FvLength;
UINT8 ErasePolarity;
UINT8 FileState;
+ UINT8 DataCheckSum;
//
// Convert the handle of FV to FV header for memory-mapped firmware volume
@@ -219,6 +220,16 @@ FindFileEx (
FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
FileOccupiedSize = GET_OCCUPIED_SIZE(FileLength, 8);
+ DataCheckSum = FFS_FIXED_CHECKSUM;
+ if ((FfsFileHeader->Attributes & FFS_ATTRIB_CHECKSUM) == FFS_ATTRIB_CHECKSUM) {
+ DataCheckSum = CalculateCheckSum8 ((CONST UINT8 *)FfsFileHeader + sizeof(EFI_FFS_FILE_HEADER), FileLength - sizeof(EFI_FFS_FILE_HEADER));
+ }
+ if (FfsFileHeader->IntegrityCheck.Checksum.File != DataCheckSum) {
+ ASSERT (FALSE);
+ *FileHeader = NULL;
+ return EFI_NOT_FOUND;
+ }
+
if (FileName != NULL) {
if (CompareGuid (&FfsFileHeader->Name, (EFI_GUID*)FileName)) {
*FileHeader = FfsFileHeader;