diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2018-11-30 12:28:26 +0100 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2018-12-03 15:54:39 +0100 |
commit | 36a87fec6879b4bd96de88a7234f9a98c69af8e1 (patch) | |
tree | 0f14ee0816c47804d51e40dab33fee8327c6c738 /ArmPkg/Drivers | |
parent | a2df8587bf7a4f3da37d7a906ca66d65d293665d (diff) | |
download | edk2-36a87fec6879b4bd96de88a7234f9a98c69af8e1.tar.gz edk2-36a87fec6879b4bd96de88a7234f9a98c69af8e1.tar.bz2 edk2-36a87fec6879b4bd96de88a7234f9a98c69af8e1.zip |
ArmPkg/ArmMmuLib ARM: handle unmapped section in GetMemoryRegion()
GetMemoryRegion() is used to obtain the attributes of an existing
mapping, to permit permission attribute changes to be optimized
away if the attributes don't actually change.
The current ARM code assumes that a section mapping or a page mapping
exists for any region passed into GetMemoryRegion(), but the region
may be unmapped entirely, in which case the code will crash. So check
if a section mapping exists before dereferencing it.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'ArmPkg/Drivers')
-rw-r--r-- | ArmPkg/Drivers/CpuDxe/Arm/Mmu.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c b/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c index 12ca5b2667..3b29d33d0a 100644 --- a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c +++ b/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c @@ -457,6 +457,9 @@ GetMemoryRegion ( // Get the section at the given index
SectionDescriptor = FirstLevelTable[TableIndex];
+ if (!SectionDescriptor) {
+ return EFI_NOT_FOUND;
+ }
// If 'BaseAddress' belongs to the section then round it to the section boundary
if (((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) ||
|