public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg: Fix runtime panic in ValidateSetVariable()
@ 2020-11-25 20:13 James Bottomley
  2020-11-25 21:00 ` Laszlo Ersek
  2020-11-25 21:05 ` Ard Biesheuvel
  0 siblings, 2 replies; 10+ messages in thread
From: James Bottomley @ 2020-11-25 20:13 UTC (permalink / raw)
  To: devel
  Cc: Bret Barkelew, Liming Gao (Byosoft address),
	Ard Biesheuvel (ARM address), Laszlo Ersek

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>
---
 MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c
index 5029ddb96adb..12944ac7ea81 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;
     }
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-12-03 23:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-25 20:13 [PATCH] MdeModulePkg: Fix runtime panic in ValidateSetVariable() James Bottomley
2020-11-25 21:00 ` Laszlo Ersek
2020-11-26  1:23   ` 回复: " gaoliming
     [not found]   ` <164AEA4706B9EEF6.8857@groups.io>
2020-11-27  0:58     ` 回复: [edk2-devel] " gaoliming
2020-11-25 21:05 ` Ard Biesheuvel
2020-11-25 21:17   ` Laszlo Ersek
2020-12-01 21:12     ` [EXTERNAL] Re: [edk2-devel] " Bret Barkelew
2020-12-03 10:39       ` Laszlo Ersek
2020-12-03 11:25         ` Ard Biesheuvel
2020-12-03 23:33           ` Laszlo Ersek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox