MdeModulePkg/FaultTolerantWriteDxe: Add validation for FtwWorkSpaceHeader

Add validation for FtwWorkSpaceHeader within the
WorkSpaceRefresh() function to address an issue where the
variable store cannot recover from the FTW spare block if the
variable store is erased or corrupted during an FTW write or
reclaim operation.

Signed-off-by: Wenbo Hou <wenbo.hou@microsoft.com>
This commit is contained in:
Wenbo Hou 2025-05-23 23:54:58 +08:00 committed by Liming Gao
parent 51d273d8c3
commit d165ebcf43
2 changed files with 8 additions and 1 deletions

View file

@ -1300,7 +1300,10 @@ InitFtwProtocol (
// Refresh the working space data from working block
//
Status = WorkSpaceRefresh (FtwDevice);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Ftw: Init.. WorkSpaceRefresh failed: Status = %r\n", Status));
}
//
// If the working block workspace is not valid, try the spare block
//

View file

@ -286,6 +286,10 @@ WorkSpaceRefresh (
return EFI_ABORTED;
}
if (!IsValidWorkSpace (FtwDevice->FtwWorkSpaceHeader)) {
return EFI_ABORTED;
}
//
// Refresh the FtwLastWriteHeader
//