]> git.proxmox.com Git - mirror_edk2.git/commit
ArmPkg/ArmMmuLib AARCH64: limit recursion when freeing page tables
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 25 Mar 2020 14:54:09 +0000 (15:54 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 26 Mar 2020 10:34:14 +0000 (10:34 +0000)
commitd390920ed41ebdf78402288416a284cf8bcde620
tree196ab24b1b085722e1dbcd71759c14ee0d316b1c
parentf52b30e73ddee9a3a609a6e5aa87e79cf4f50879
ArmPkg/ArmMmuLib AARCH64: limit recursion when freeing page tables

FreePageTablesRecursive () traverses the page table tree depth first
to free all pages that it finds, without taking into account the
level at which it is operating.

Since TT_TYPE_TABLE_ENTRY aliases TT_TYPE_BLOCK_ENTRY_LEVEL3, we cannot
distinguish table entries from block entries unless we take the level
into account, and so we may be dereferencing garbage if we happen to
try and free a hierarchy of page tables that has level 3 pages in it.

Let's fix this by passing the level into FreePageTablesRecursive (),
and limit the recursion to levels < 3.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Ashish Singhal <ashishsingha@nvidia.com>
Tested-by: Ashish Singhal <ashishsingha@nvidia.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c