[edk2-devel] [PATCH v2 4/7] ArmPkg/DefaultExceptionHandlerLib: Check DebugImageInfoTable type safely

Marvin Häuser posted 7 patches 4 years, 6 months ago
[edk2-devel] [PATCH v2 4/7] ArmPkg/DefaultExceptionHandlerLib: Check DebugImageInfoTable type safely
Posted by Marvin Häuser 4 years, 6 months ago
C does not allow casting to or dereferencing incompatible pointer
types. Use the ImageInfoType member of the union first to determine
the data type before dereferencing NormalImage.

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
---
 ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
index e9fea4038252..9befb6d4db9b 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
@@ -51,8 +51,8 @@ GetImageName (
 

   Address = (CHAR8 *)(UINTN)FaultAddress;

   for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {

-    if (DebugTable->NormalImage != NULL) {

-      if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&

+    if (DebugTable->ImageInfoType != NULL) {

+      if ((*DebugTable->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&

           (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {

         if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&

             (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {

-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78943): https://edk2.groups.io/g/devel/message/78943
Mute This Topic: https://groups.io/mt/84764906/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v2 4/7] ArmPkg/DefaultExceptionHandlerLib: Check DebugImageInfoTable type safely
Posted by Ard Biesheuvel 4 years, 6 months ago
On Mon, 9 Aug 2021 at 11:51, Marvin Häuser <mhaeuser@posteo.de> wrote:
>
> C does not allow casting to or dereferencing incompatible pointer
> types. Use the ImageInfoType member of the union first to determine
> the data type before dereferencing NormalImage.
>
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Vitaly Cheptsov <vit9696@protonmail.com>
> Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>

Hi Marvin,

Could you please organize your patches into a consistent series,
include a cover letter and cc me on everything?

I am going to disregard anything you sent yesterday and today, as it
is a bit of a jumble.

Thanks,
Ard.


> ---
>  ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
> index e9fea4038252..9befb6d4db9b 100644
> --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
> +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
> @@ -51,8 +51,8 @@ GetImageName (
>
>    Address = (CHAR8 *)(UINTN)FaultAddress;
>    for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {
> -    if (DebugTable->NormalImage != NULL) {
> -      if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
> +    if (DebugTable->ImageInfoType != NULL) {
> +      if ((*DebugTable->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
>            (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
>          if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
>              (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {
> --
> 2.31.1
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78954): https://edk2.groups.io/g/devel/message/78954
Mute This Topic: https://groups.io/mt/84764906/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v2 4/7] ArmPkg/DefaultExceptionHandlerLib: Check DebugImageInfoTable type safely
Posted by Marvin Häuser 4 years, 6 months ago
On 09/08/2021 13:55, Ard Biesheuvel wrote:
> On Mon, 9 Aug 2021 at 11:51, Marvin Häuser <mhaeuser@posteo.de> wrote:
>> C does not allow casting to or dereferencing incompatible pointer
>> types. Use the ImageInfoType member of the union first to determine
>> the data type before dereferencing NormalImage.
>>
>> Cc: Leif Lindholm <leif@nuviainc.com>
>> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
>> Cc: Vitaly Cheptsov <vit9696@protonmail.com>
>> Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
> Hi Marvin,
>
> Could you please organize your patches into a consistent series,
> include a cover letter and cc me on everything?

Hey Ard,

It's a series and there is a cover letter at: 
https://edk2.groups.io/g/devel/topic/patch_v2_0_7_fix_various/84764899?p=,,,20,0,0,0::recentpostdate%2Fsticky,,,20,2,0,84764899
The mails from yesterday can certainly be discarded, for some reason 
format-patch did not number the patches without the argument.
The mails from today are numbered and there is a cover letter, but for 
some reason the threading is all wrong in Thunderbird for me. All 
subsequent patches have the "In-Reply-To" header in the patch files, I 
think it is supposed to work off of that? Is threading broken for you as 
well? Any idea what could have gone wrong?

I will create a V3 with you CC'd on all patches once I understand 
everything that went wrong. Is it normal to CC all people from each 
patch on all patches of a series?

Thanks and so sorry for the hassle!

Best regards,
Marvin

> I am going to disregard anything you sent yesterday and today, as it
> is a bit of a jumble.
>
> Thanks,
> Ard.
>
>
>> ---
>>   ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
>> index e9fea4038252..9befb6d4db9b 100644
>> --- a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
>> +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
>> @@ -51,8 +51,8 @@ GetImageName (
>>
>>     Address = (CHAR8 *)(UINTN)FaultAddress;
>>     for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, DebugTable++) {
>> -    if (DebugTable->NormalImage != NULL) {
>> -      if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
>> +    if (DebugTable->ImageInfoType != NULL) {
>> +      if ((*DebugTable->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
>>             (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
>>           if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
>>               (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {
>> --
>> 2.31.1
>>
>
> 
>
>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78955): https://edk2.groups.io/g/devel/message/78955
Mute This Topic: https://groups.io/mt/84764906/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v2 4/7] ArmPkg/DefaultExceptionHandlerLib: Check DebugImageInfoTable type safely
Posted by Marvin Häuser 4 years, 6 months ago
On 09/08/2021 14:40, Marvin Häuser wrote:
> On 09/08/2021 13:55, Ard Biesheuvel wrote:
>> On Mon, 9 Aug 2021 at 11:51, Marvin Häuser <mhaeuser@posteo.de> wrote:
>>> C does not allow casting to or dereferencing incompatible pointer
>>> types. Use the ImageInfoType member of the union first to determine
>>> the data type before dereferencing NormalImage.
>>>
>>> Cc: Leif Lindholm <leif@nuviainc.com>
>>> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
>>> Cc: Vitaly Cheptsov <vit9696@protonmail.com>
>>> Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
>> Hi Marvin,
>>
>> Could you please organize your patches into a consistent series,
>> include a cover letter and cc me on everything?
>
> Hey Ard,
>
> It's a series and there is a cover letter at: 
> https://edk2.groups.io/g/devel/topic/patch_v2_0_7_fix_various/84764899?p=,,,20,0,0,0::recentpostdate%2Fsticky,,,20,2,0,84764899
> The mails from yesterday can certainly be discarded, for some reason 
> format-patch did not number the patches without the argument.
> The mails from today are numbered and there is a cover letter, but for 
> some reason the threading is all wrong in Thunderbird for me. All 
> subsequent patches have the "In-Reply-To" header in the patch files, I 
> think it is supposed to work off of that? Is threading broken for you 
> as well? Any idea what could have gone wrong?

Today I learned two things.

1) Both format-patch and send-email support threading individually, and 
they don't cooperate [1].

2) Groups.io does not like patch sets [2].

*Sigh*. Sorry.

Best regards,
Marvin


[1] "It is up to the user to ensure that no In-Reply-To header already 
exists when git send-email is asked to add it (especially note that git 
format-patch can be configured to do the threading itself). Failure to 
do so may not produce the expected result in the recipient’s MUA.", 
https://git-scm.com/docs/git-send-email

[2] "Note: This checkbox is selected by default in new Groups.io 
accounts. If you do not want to see copies of your own messages, clear 
this checkbox. [...] (For those interested in the technical details: 
When this checkbox is selected, Groups.io replaces the Message-Id header 
with a new, system-generated one and renames the original Message-Id 
header to X-Orig-Message-Id.)", 
https://groups.io/helpcenter/membersmanual?single=true

>
> I will create a V3 with you CC'd on all patches once I understand 
> everything that went wrong. Is it normal to CC all people from each 
> patch on all patches of a series?
>
> Thanks and so sorry for the hassle!
>
> Best regards,
> Marvin
>
>> I am going to disregard anything you sent yesterday and today, as it
>> is a bit of a jumble.
>>
>> Thanks,
>> Ard.
>>
>>
>>> ---
>>> ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c 
>>> | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git 
>>> a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c 
>>> b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c 
>>>
>>> index e9fea4038252..9befb6d4db9b 100644
>>> --- 
>>> a/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
>>> +++ 
>>> b/ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerUefi.c
>>> @@ -51,8 +51,8 @@ GetImageName (
>>>
>>>     Address = (CHAR8 *)(UINTN)FaultAddress;
>>>     for (Entry = 0; Entry < DebugTableHeader->TableSize; Entry++, 
>>> DebugTable++) {
>>> -    if (DebugTable->NormalImage != NULL) {
>>> -      if ((DebugTable->NormalImage->ImageInfoType == 
>>> EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
>>> +    if (DebugTable->ImageInfoType != NULL) {
>>> +      if ((*DebugTable->ImageInfoType == 
>>> EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
>>> (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
>>>           if ((Address >= (CHAR8 
>>> *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
>>>               (Address <= ((CHAR8 
>>> *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + 
>>> DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {
>>> -- 
>>> 2.31.1
>>>
>>
>> 
>>
>>
>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78992): https://edk2.groups.io/g/devel/message/78992
Mute This Topic: https://groups.io/mt/84764906/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v2 4/7] ArmPkg/DefaultExceptionHandlerLib: Check DebugImageInfoTable type safely
Posted by Ard Biesheuvel 4 years, 5 months ago
On Mon, 9 Aug 2021 at 23:19, Marvin Häuser <mhaeuser@posteo.de> wrote:
>
> On 09/08/2021 14:40, Marvin Häuser wrote:
> > On 09/08/2021 13:55, Ard Biesheuvel wrote:
> >> On Mon, 9 Aug 2021 at 11:51, Marvin Häuser <mhaeuser@posteo.de> wrote:
> >>> C does not allow casting to or dereferencing incompatible pointer
> >>> types. Use the ImageInfoType member of the union first to determine
> >>> the data type before dereferencing NormalImage.
> >>>
> >>> Cc: Leif Lindholm <leif@nuviainc.com>
> >>> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> >>> Cc: Vitaly Cheptsov <vit9696@protonmail.com>
> >>> Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
> >> Hi Marvin,
> >>
> >> Could you please organize your patches into a consistent series,
> >> include a cover letter and cc me on everything?
> >
> > Hey Ard,
> >
> > It's a series and there is a cover letter at:
> > https://edk2.groups.io/g/devel/topic/patch_v2_0_7_fix_various/84764899?p=,,,20,0,0,0::recentpostdate%2Fsticky,,,20,2,0,84764899
> > The mails from yesterday can certainly be discarded, for some reason
> > format-patch did not number the patches without the argument.
> > The mails from today are numbered and there is a cover letter, but for
> > some reason the threading is all wrong in Thunderbird for me. All
> > subsequent patches have the "In-Reply-To" header in the patch files, I
> > think it is supposed to work off of that? Is threading broken for you
> > as well? Any idea what could have gone wrong?
>
> Today I learned two things.
>
> 1) Both format-patch and send-email support threading individually, and
> they don't cooperate [1].
>
> 2) Groups.io does not like patch sets [2].
>
> *Sigh*. Sorry.
>

No worries.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79346): https://edk2.groups.io/g/devel/message/79346
Mute This Topic: https://groups.io/mt/84764906/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-