]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/VariablePolicyLib: Fix runtime panic in ValidateSetVariable() edk2-stable202011
authorJames Bottomley <jejb@linux.ibm.com>
Wed, 25 Nov 2020 20:13:48 +0000 (04:13 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 27 Nov 2020 01:19:34 +0000 (01:19 +0000)
The current variable policy is allocated by AllocatePool(), which is
boot time only.  This means that if you do any variable setting in the
runtime, the policy has been freed.  Ordinarily this isn't detected
because freed memory is still there, but when you boot the Linux
kernel, it's been remapped so the actual memory no longer exists in
the memory map causing a page fault.

Fix this by making it AllocateRuntimePool().  For SMM drivers, the
platform DSC is responsible for resolving the MemoryAllocationLib
class to the SmmMemoryAllocationLib instance. In the
SmmMemoryAllocationLib instance, AllocatePool() and
AllocateRuntimePool() are implemented identically. Therefore this
change is a no-op when the RegisterVariablePolicy() function is built
into an SMM driver. The fix affects runtime DXE drivers only.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3092
Signed-off-by: James Bottomley <jejb@linux.ibm.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c

index 5029ddb96adb129e53a79094614fec17a807c3f7..12944ac7ea8112d01407d038ec9809b621fe5423 100644 (file)
@@ -411,7 +411,7 @@ RegisterVariablePolicy (
     }\r
 \r
     // Reallocate and copy the table.\r
-    NewTable = AllocatePool( NewSize );\r
+    NewTable = AllocateRuntimePool( NewSize );\r
     if (NewTable == NULL) {\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r