From 6062002bd5a394fef46243dd866860c3480d918e Mon Sep 17 00:00:00 2001 From: "Edwards, Craig" Date: Thu, 6 Jan 2022 00:02:53 +0800 Subject: [PATCH] MdeModulePkg/PartitionDxe: Add break to handle invalid LBA0 in MBR Read Disk does a modification of ExtMbrStartingLba with the code MultU64x32 (ExtMbrStartingLba, BlockSize) Error detection to see if ExtMbrStartingLBA has a value of 0. This is invalid as LBA 0 = MBR. After modification, the next time ExtMbrStartingLba is in this function if ExtMbrStartingLba is set to 0 in the MBR it never passes the while/do evaluation It is multiplied by 0 by read disk , set to 0 by an invalid MBR and goes back to evaluation This condition will also cause Ws19 and WS22 to hang, however Microsoft has developed a hotfix patch that will be released in 2022 Cc: Liming Gao Cc: Jian J Wang Cc: Hao A Wu Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Craig Edwards Reviewed-by: Hao A Wu --- MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c index 0f8dc54865..531b3b45ea 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Mbr.c @@ -293,6 +293,13 @@ PartitionInstallMbrChildHandles ( (Mbr->Partition[0].OSIndicator == EXTENDED_WINDOWS_PARTITION)) { ExtMbrStartingLba = UNPACK_UINT32 (Mbr->Partition[0].StartingLBA); + // + // A value of 0 is invalid for StartingLBA + // + if (ExtMbrStartingLba == 0) { + break; + } + continue; } -- 2.39.2