From 872f953262d68a11da7bc2fb3ded16df234b8700 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Thu, 26 Nov 2020 04:13:48 +0800 Subject: 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. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3092 Signed-off-by: James Bottomley Reviewed-by: Laszlo Ersek Tested-by: Laszlo Ersek Reviewed-by: Liming Gao --- MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c index 5029ddb96a..12944ac7ea 100644 --- a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c +++ b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c @@ -411,7 +411,7 @@ RegisterVariablePolicy ( } // Reallocate and copy the table. - NewTable = AllocatePool( NewSize ); + NewTable = AllocateRuntimePool( NewSize ); if (NewTable == NULL) { return EFI_OUT_OF_RESOURCES; } -- cgit v1.2.3