public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@arm.com>,
	jejb@linux.ibm.com, devel@edk2.groups.io
Cc: Bret Barkelew <brbarkel@microsoft.com>,
	"Liming Gao (Byosoft address)" <gaoliming@byosoft.com.cn>
Subject: Re: [PATCH] MdeModulePkg: Fix runtime panic in ValidateSetVariable()
Date: Wed, 25 Nov 2020 22:17:21 +0100	[thread overview]
Message-ID: <0f6e92d4-f600-8495-53af-5898a2cdbe2a@redhat.com> (raw)
In-Reply-To: <1b9adc6f-37e3-0a9b-29cc-2c97e8a9e0f5@arm.com>

On 11/25/20 22:05, Ard Biesheuvel wrote:
> On 11/25/20 9:13 PM, James Bottomley wrote:
>> 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>
> 
> Thanks James
> 
> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.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;
>>       }
>>
> 
> BTW I wouldn't mind if the whitespace gets fixed up here at merge time.
> 

The coding style all over the VariablePolicy code (that I have
investigated) is non-idiomatic for edk2 -- it should have been pointed
out during the original patch review sessions.

The coding style can also be fixed up retro-actively whole-sale, of course.

In the present patch, James is only sticking with the (non-idiomatic)
style that's been part of the VariablePolicy contribution.

I'm quite displeased myself with the reams of non-idiomatic coding style
in VariablePolicy, but I don't blame that on the contribution -- IMO it
should have been caught in review.

(

Meta-request: Ard, can you please start signing your emails? (Such as,
in "Bye: Ard", not as in cryptographic signing.) It's quite hit-or-miss
to know where your emails end; in the present case, I *almost* didn't
scroll down to the bottom (because in many other cases, you insert an
A-b, don't remove the tail, and add nothing at the bottom, so the reader
kind of gets conditioned to stop reading after the A-b, seeing
repeatedly how scrolling down to the bottom is a waste). Consistently
using a manual signature does away with this problem. Another solution
is of course to always strip the tail, when you're done responding.
Sorry about this verbiage, I just wanted to have it said. :)

)

Thanks,
Laszlo


  reply	other threads:[~2020-11-25 21:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f6e92d4-f600-8495-53af-5898a2cdbe2a@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox