summaryrefslogtreecommitdiffstats
path: root/FatPkg/FatPei/FatLiteFmt.h
diff options
context:
space:
mode:
authorOliver Smith-Denny <osde@microsoft.com>2025-01-10 14:42:17 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-21 18:40:11 +0000
commit58766a472932c485d41163b1746fb1d9e7984f07 (patch)
tree64a0872b9a62a95b0682a530f702f1b381a0044b /FatPkg/FatPei/FatLiteFmt.h
parent35232f165cba2314cb4af2e0a5aa2fbb23695a0a (diff)
downloadedk2-58766a472932c485d41163b1746fb1d9e7984f07.tar.gz
FatPkg: Validate Reserved FAT Entries on Volume Open
There are two reserved FAT entries in the FAT filesystem that are expected to have valid contents in them. Today the FAT drivers do not validate these entries when reading from a device for the first time. This can cause infinite loops in the FAT driver when trying to read corrupted disks as reported in https://github.com/tianocore/edk2/issues/9679. This PR follows the recommended update requested in that bug to check the two reserved FAT entries and validate their contents against the spec defined values in both FatPei and EnhancedFatDxe when opening a device for the first time. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
Diffstat (limited to 'FatPkg/FatPei/FatLiteFmt.h')
-rw-r--r--FatPkg/FatPei/FatLiteFmt.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/FatPkg/FatPei/FatLiteFmt.h b/FatPkg/FatPei/FatLiteFmt.h
index fef70fe1de..b179b5f95f 100644
--- a/FatPkg/FatPei/FatLiteFmt.h
+++ b/FatPkg/FatPei/FatLiteFmt.h
@@ -27,6 +27,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define FAT_CLUSTER_BAD (FAT_CLUSTER_SPECIAL)
#define FAT_CLUSTER_LAST (-1)
+#define FAT_CLUSTER_MASK_FAT12 0xFFF
+#define FAT_CLUSTER_UNMASK_FAT12 0xF000
+#define FAT_CLUSTER_MASK_FAT16 0xFFFF
+#define FAT_CLUSTER_UNMASK_FAT16 0xF0000
+#define FAT_CLUSTER_MASK_FAT32 0x0FFFFFFF
+#define FAT_CLUSTER_UNMASK_FAT32 0xF0000000
+
#define DELETE_ENTRY_MARK 0xE5
#define EMPTY_ENTRY_MARK 0x00