Commit 872f9532 authored by James Bottomley's avatar James Bottomley Committed by mergify[bot]
Browse files

MdeModulePkg/VariablePolicyLib: Fix runtime panic in ValidateSetVariable()

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.


Signed-off-by: default avatarJames Bottomley <>
Reviewed-by: default avatarLaszlo Ersek <>
Tested-by: default avatarLaszlo Ersek <>
Reviewed-by: default avatarLiming Gao <>
parent 21f984ce
......@@ -411,7 +411,7 @@ RegisterVariablePolicy (
// Reallocate and copy the table.
NewTable = AllocatePool( NewSize );
NewTable = AllocateRuntimePool( NewSize );
if (NewTable == NULL) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment