public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST
@ 2018-10-11  7:52 Ruiyu Ni
  2018-10-11 13:05 ` Jim.Dailey
  0 siblings, 1 reply; 3+ messages in thread
From: Ruiyu Ni @ 2018-10-11  7:52 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jaben Carsey

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1236

When "dmem" runs without additional arguments, it dumps the memory
content of EFI_SYSTEM_TABLE. But today's implementation dumps 512
bytes. It's not correct because sizeof (EFI_SYSTEM_TABLE) is less
than 512, the 512-read causes page fault exception in a heap-guard
enabled environment.

The patch changes the implementation to only dump
sizeof (EFI_SYSTEM_TABLE) bytes for gST.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
index f38593a9e9..a4c18c9b68 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
@@ -149,7 +149,7 @@ ShellCommandRunDmem (
       Temp1 = ShellCommandLineGetRawValue(Package, 1);
       if (Temp1 == NULL) {
         Address = gST;
-        Size = 512;
+        Size    = sizeof (*gST);
       } else {
         if (!ShellIsHexOrDecimalNumber(Temp1, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, (UINT64*)&Address, TRUE, FALSE))) {
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1);
-- 
2.16.1.windows.1



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

* Re: [PATCH] ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST
  2018-10-11  7:52 [PATCH] ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST Ruiyu Ni
@ 2018-10-11 13:05 ` Jim.Dailey
  2018-10-16  9:16   ` Ni, Ruiyu
  0 siblings, 1 reply; 3+ messages in thread
From: Jim.Dailey @ 2018-10-11 13:05 UTC (permalink / raw)
  To: ruiyu.ni; +Cc: jaben.carsey, edk2-devel

Is the line:

        Size = gST->Hdr.HeaderSize;

possibly a better way of handling this?  Either way:

Reviewed-by: Jim Dailey <jim_dailey@.com>

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Thursday, October 11, 2018 2:53 AM
To: edk2-devel@lists.01.org
Cc: Jaben Carsey
Subject: [edk2] [PATCH] ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST


REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1236

When "dmem" runs without additional arguments, it dumps the memory
content of EFI_SYSTEM_TABLE. But today's implementation dumps 512
bytes. It's not correct because sizeof (EFI_SYSTEM_TABLE) is less
than 512, the 512-read causes page fault exception in a heap-guard
enabled environment.

The patch changes the implementation to only dump
sizeof (EFI_SYSTEM_TABLE) bytes for gST.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
---
 ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
index f38593a9e9..a4c18c9b68 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
@@ -149,7 +149,7 @@ ShellCommandRunDmem (
       Temp1 = ShellCommandLineGetRawValue(Package, 1);
       if (Temp1 == NULL) {
         Address = gST;
-        Size = 512;
+        Size    = sizeof (*gST);
       } else {
         if (!ShellIsHexOrDecimalNumber(Temp1, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, (UINT64*)&Address, TRUE, FALSE))) {
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1);
-- 
2.16.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: [PATCH] ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST
  2018-10-11 13:05 ` Jim.Dailey
@ 2018-10-16  9:16   ` Ni, Ruiyu
  0 siblings, 0 replies; 3+ messages in thread
From: Ni, Ruiyu @ 2018-10-16  9:16 UTC (permalink / raw)
  To: Jim.Dailey; +Cc: jaben.carsey, edk2-devel

On 10/11/2018 9:05 PM, Jim.Dailey@dell.com wrote:
> Is the line:
> 
>          Size = gST->Hdr.HeaderSize;
> 
> possibly a better way of handling this?  Either way:
> 
> Reviewed-by: Jim Dailey <jim_dailey@.com>

Thanks! I will stick to use sizeof().

> 
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
> Sent: Thursday, October 11, 2018 2:53 AM
> To: edk2-devel@lists.01.org
> Cc: Jaben Carsey
> Subject: [edk2] [PATCH] ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST
> 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1236
> 
> When "dmem" runs without additional arguments, it dumps the memory
> content of EFI_SYSTEM_TABLE. But today's implementation dumps 512
> bytes. It's not correct because sizeof (EFI_SYSTEM_TABLE) is less
> than 512, the 512-read causes page fault exception in a heap-guard
> enabled environment.
> 
> The patch changes the implementation to only dump
> sizeof (EFI_SYSTEM_TABLE) bytes for gST.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> ---
>   ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
> index f38593a9e9..a4c18c9b68 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
> +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dmem.c
> @@ -149,7 +149,7 @@ ShellCommandRunDmem (
>         Temp1 = ShellCommandLineGetRawValue(Package, 1);
>         if (Temp1 == NULL) {
>           Address = gST;
> -        Size = 512;
> +        Size    = sizeof (*gST);
>         } else {
>           if (!ShellIsHexOrDecimalNumber(Temp1, TRUE, FALSE) || EFI_ERROR(ShellConvertStringToUint64(Temp1, (UINT64*)&Address, TRUE, FALSE))) {
>             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"dmem", Temp1);
> 


-- 
Thanks,
Ray


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

end of thread, other threads:[~2018-10-16  9:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-11  7:52 [PATCH] ShellPkg/dmem: Only dump sizeof (EFI_SYSTEM_TABLE) bytes for gST Ruiyu Ni
2018-10-11 13:05 ` Jim.Dailey
2018-10-16  9:16   ` Ni, Ruiyu

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