<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Getting caught up on emails from last week. I wanted to say thanks for the good catch and the good patch in my absence!</p>
<p class="MsoNormal">Sorry for the oversight. :-/</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- Bret <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:lersek=redhat.com@groups.io">Laszlo Ersek via groups.io</a><br>
<b>Sent: </b>Wednesday, November 25, 2020 1:17 PM<br>
<b>To: </b><a href="mailto:ard.biesheuvel@arm.com">Ard Biesheuvel</a>; <a href="mailto:jejb@linux.ibm.com">
jejb@linux.ibm.com</a>; <a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a><br>
<b>Cc: </b><a href="mailto:Bret.Barkelew@microsoft.com">Bret Barkelew</a>; <a href="mailto:gaoliming@byosoft.com.cn">
Liming Gao (Byosoft address)</a><br>
<b>Subject: </b>[EXTERNAL] Re: [edk2-devel] [PATCH] MdeModulePkg: Fix runtime panic in ValidateSetVariable()</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">On 11/25/20 22:05, Ard Biesheuvel wrote:<br>
> On 11/25/20 9:13 PM, James Bottomley wrote:<br>
>> The current variable policy is allocated by AllocatePool(), which is<br>
>> boot time only.  This means that if you do any variable setting in the<br>
>> runtime, the policy has been freed.  Ordinarily this isn't detected<br>
>> because freed memory is still there, but when you boot the Linux<br>
>> kernel, it's been remapped so the actual memory no longer exists in<br>
>> the memory map causing a page fault.<br>
>><br>
>> Fix this by making it AllocateRuntimePool().  For SMM drivers, the<br>
>> platform DSC is responsible for resolving the MemoryAllocationLib<br>
>> class to the SmmMemoryAllocationLib instance. In the<br>
>> SmmMemoryAllocationLib instance, AllocatePool() and<br>
>> AllocateRuntimePool() are implemented identically. Therefore this<br>
>> change is a no-op when the RegisterVariablePolicy() function is built<br>
>> into an SMM driver. The fix affects runtime DXE drivers only.<br>
>><br>
>> Ref: <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3092&amp;data=04%7C01%7Cbret.barkelew%40microsoft.com%7C2e91993035204bbd307d08d891878686%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637419358545184416%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=uYtJTRY5RRS5XJ7j%2Bo%2B75qH12ROX9%2FQ4v1GMdUbLk3I%3D&amp;reserved=0">
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3092&amp;data=04%7C01%7Cbret.barkelew%40microsoft.com%7C2e91993035204bbd307d08d891878686%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637419358545184416%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=uYtJTRY5RRS5XJ7j%2Bo%2B75qH12ROX9%2FQ4v1GMdUbLk3I%3D&amp;reserved=0</a><br>
>> Signed-off-by: James Bottomley <jejb@linux.ibm.com><br>
> <br>
> Thanks James<br>
> <br>
> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com><br>
> <br>
>> ---<br>
>>   MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c | 2 +-<br>
>>   1 file changed, 1 insertion(+), 1 deletion(-)<br>
>><br>
>> diff --git<br>
>> a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c<br>
>> b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c<br>
>> index 5029ddb96adb..12944ac7ea81 100644<br>
>> --- a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c<br>
>> +++ b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c<br>
>> @@ -411,7 +411,7 @@ RegisterVariablePolicy (<br>
>>       }<br>
>>         // Reallocate and copy the table.<br>
>> -    NewTable = AllocatePool( NewSize );<br>
>> +    NewTable = AllocateRuntimePool( NewSize );<br>
>>       if (NewTable == NULL) {<br>
>>         return EFI_OUT_OF_RESOURCES;<br>
>>       }<br>
>><br>
> <br>
> BTW I wouldn't mind if the whitespace gets fixed up here at merge time.<br>
> <br>
<br>
The coding style all over the VariablePolicy code (that I have<br>
investigated) is non-idiomatic for edk2 -- it should have been pointed<br>
out during the original patch review sessions.<br>
<br>
The coding style can also be fixed up retro-actively whole-sale, of course.<br>
<br>
In the present patch, James is only sticking with the (non-idiomatic)<br>
style that's been part of the VariablePolicy contribution.<br>
<br>
I'm quite displeased myself with the reams of non-idiomatic coding style<br>
in VariablePolicy, but I don't blame that on the contribution -- IMO it<br>
should have been caught in review.<br>
<br>
(<br>
<br>
Meta-request: Ard, can you please start signing your emails? (Such as,<br>
in "Bye: Ard", not as in cryptographic signing.) It's quite hit-or-miss<br>
to know where your emails end; in the present case, I *almost* didn't<br>
scroll down to the bottom (because in many other cases, you insert an<br>
A-b, don't remove the tail, and add nothing at the bottom, so the reader<br>
kind of gets conditioned to stop reading after the A-b, seeing<br>
repeatedly how scrolling down to the bottom is a waste). Consistently<br>
using a manual signature does away with this problem. Another solution<br>
is of course to always strip the tail, when you're done responding.<br>
Sorry about this verbiage, I just wanted to have it said. :)<br>
<br>
)<br>
<br>
Thanks,<br>
Laszlo<br>
<br>
<br>
<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr> Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/68149">View/Reply Online (#68149)</a> |    |  <a target="_blank" href="https://groups.io/mt/78644930/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>