]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmMmuLib ARM: handle unmapped section in GetMemoryRegion()
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 30 Nov 2018 11:28:26 +0000 (12:28 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 3 Dec 2018 14:54:39 +0000 (15:54 +0100)
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>
ArmPkg/Drivers/CpuDxe/Arm/Mmu.c

index 12ca5b26673e834932e5a522d5e8b1e48943df39..3b29d33d0a9cb8ab89d5198115eb57e824043e54 100644 (file)
@@ -457,6 +457,9 @@ GetMemoryRegion (
 \r
   // Get the section at the given index\r
   SectionDescriptor = FirstLevelTable[TableIndex];\r
+  if (!SectionDescriptor) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
 \r
   // If 'BaseAddress' belongs to the section then round it to the section boundary\r
   if (((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) ||\r