Revision: 18425
          http://sourceforge.net/p/edk2/code/18425
Author:   abiesheuvel
Date:     2015-09-09 13:37:50 +0000 (Wed, 09 Sep 2015)
Log Message:
-----------
ArmPkg/Mmu: Fix potential page table memory leak

During page entry attribute update, if there are table entries
between starting BlockEntry and LastBlockEntry, table entries will be
set as block entries and the allocated memory of the tables will be
leaked.

So instead, we break the inner loop when we find a table entry and run
outer loop again to step into the table by the same logic.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <[email protected]>
Cc: Leif Lindholm <[email protected]>

[ardb: move termination condition check inside the loop]
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c

Modified: trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c
===================================================================
--- trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c       2015-09-09 
13:37:41 UTC (rev 18424)
+++ trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Mmu.c       2015-09-09 
13:37:50 UTC (rev 18425)
@@ -455,6 +455,13 @@
       RegionStart += BlockEntrySize;
       RemainingRegionLength -= BlockEntrySize;
       BlockEntry++;
+
+      // Break the inner loop when next block is a table
+      // Rerun GetBlockEntryListFromAddress to avoid page table memory leak
+      if (TableLevel != 3 &&
+          (*BlockEntry & TT_TYPE_MASK) == TT_TYPE_TABLE_ENTRY) {
+            break;
+      }
     } while ((RemainingRegionLength >= BlockEntrySize) && (BlockEntry <= 
LastBlockEntry));
   } while (RemainingRegionLength != 0);
 


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to