public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference
@ 2019-08-24  2:54 Kubacki, Michael A
  2019-08-26 23:41 ` Chaganty, Rangasai V
  2019-08-26 23:51 ` Ni, Ray
  0 siblings, 2 replies; 4+ messages in thread
From: Kubacki, Michael A @ 2019-08-24  2:54 UTC (permalink / raw)
  To: devel; +Cc: Ray Ni, Rangasai V Chaganty

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

Cc: Ray Ni <ray.ni@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
---
 Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
index 956ebb2d3d..9b6135ef94 100644
--- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
+++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
@@ -158,10 +158,13 @@ ProcessRequestedAccessAttribute (
 }
 
 /**
-  return the UEFI memory information.
+  Return UEFI memory map information.
+
+  @param[out] Below4GMemoryLimit  The below 4GiB memory limit address or 0 if insufficient resources exist to
+                                  determine the address.
+  @param[out] Above4GMemoryLimit  The above 4GiB memory limit address or 0 if insufficient resources exist to
+                                  determine the address.
 
-  @param[out] Below4GMemoryLimit  The below 4GiB memory limit
-  @param[out] Above4GMemoryLimit  The above 4GiB memory limit
 **/
 VOID
 ReturnUefiMemoryMap (
@@ -206,7 +209,11 @@ ReturnUefiMemoryMap (
     // we process bogus entries and create bogus E820 entries.
     //
     EfiMemoryMap = (EFI_MEMORY_DESCRIPTOR *) AllocatePool (EfiMemoryMapSize);
-    ASSERT (EfiMemoryMap != NULL);
+    if (EfiMemoryMap == NULL) {
+      ASSERT (EfiMemoryMap != NULL);
+      return;
+    }
+
     Status = gBS->GetMemoryMap (
                     &EfiMemoryMapSize,
                     EfiMemoryMap,
@@ -218,7 +225,6 @@ ReturnUefiMemoryMap (
       FreePool (EfiMemoryMap);
     }
   } while (Status == EFI_BUFFER_TOO_SMALL);
-
   ASSERT_EFI_ERROR (Status);
 
   //
@@ -242,9 +248,6 @@ ReturnUefiMemoryMap (
     NextEfiEntry  = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
   }
 
-  //
-  //
-  //
   DEBUG ((DEBUG_INFO, "MemoryMap:\n"));
   EfiEntry        = EfiMemoryMap;
   EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) EfiMemoryMap + EfiMemoryMapSize);
-- 
2.16.2.windows.1


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

* Re: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference
  2019-08-24  2:54 [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference Kubacki, Michael A
@ 2019-08-26 23:41 ` Chaganty, Rangasai V
  2019-08-26 23:51 ` Ni, Ray
  1 sibling, 0 replies; 4+ messages in thread
From: Chaganty, Rangasai V @ 2019-08-26 23:41 UTC (permalink / raw)
  To: Kubacki, Michael A, devel@edk2.groups.io; +Cc: Ni, Ray

Reviewed-by: Sai Chaganty <rangasai.v.chaganty@intel.com>

-----Original Message-----
From: Kubacki, Michael A 
Sent: Friday, August 23, 2019 7:54 PM
To: devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>
Subject: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference

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

Cc: Ray Ni <ray.ni@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
---
 Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
index 956ebb2d3d..9b6135ef94 100644
--- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
+++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtectio
+++ n.c
@@ -158,10 +158,13 @@ ProcessRequestedAccessAttribute (  }
 
 /**
-  return the UEFI memory information.
+  Return UEFI memory map information.
+
+  @param[out] Below4GMemoryLimit  The below 4GiB memory limit address or 0 if insufficient resources exist to
+                                  determine the address.
+  @param[out] Above4GMemoryLimit  The above 4GiB memory limit address or 0 if insufficient resources exist to
+                                  determine the address.
 
-  @param[out] Below4GMemoryLimit  The below 4GiB memory limit
-  @param[out] Above4GMemoryLimit  The above 4GiB memory limit  **/  VOID  ReturnUefiMemoryMap ( @@ -206,7 +209,11 @@ ReturnUefiMemoryMap (
     // we process bogus entries and create bogus E820 entries.
     //
     EfiMemoryMap = (EFI_MEMORY_DESCRIPTOR *) AllocatePool (EfiMemoryMapSize);
-    ASSERT (EfiMemoryMap != NULL);
+    if (EfiMemoryMap == NULL) {
+      ASSERT (EfiMemoryMap != NULL);
+      return;
+    }
+
     Status = gBS->GetMemoryMap (
                     &EfiMemoryMapSize,
                     EfiMemoryMap,
@@ -218,7 +225,6 @@ ReturnUefiMemoryMap (
       FreePool (EfiMemoryMap);
     }
   } while (Status == EFI_BUFFER_TOO_SMALL);
-
   ASSERT_EFI_ERROR (Status);
 
   //
@@ -242,9 +248,6 @@ ReturnUefiMemoryMap (
     NextEfiEntry  = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
   }
 
-  //
-  //
-  //
   DEBUG ((DEBUG_INFO, "MemoryMap:\n"));
   EfiEntry        = EfiMemoryMap;
   EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) EfiMemoryMap + EfiMemoryMapSize);
--
2.16.2.windows.1


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

* Re: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference
  2019-08-24  2:54 [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference Kubacki, Michael A
  2019-08-26 23:41 ` Chaganty, Rangasai V
@ 2019-08-26 23:51 ` Ni, Ray
  2019-08-27  0:47   ` Ni, Ray
  1 sibling, 1 reply; 4+ messages in thread
From: Ni, Ray @ 2019-08-26 23:51 UTC (permalink / raw)
  To: Kubacki, Michael A, devel@edk2.groups.io; +Cc: Chaganty, Rangasai V

Michael,


> -----Original Message-----
> From: Kubacki, Michael A
> Sent: Friday, August 23, 2019 7:54 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>
> Subject: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2116
> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
> Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
> ---
>  Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
> b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
> index 956ebb2d3d..9b6135ef94 100644
> --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
> +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
> @@ -158,10 +158,13 @@ ProcessRequestedAccessAttribute (
>  }
> 
>  /**
> -  return the UEFI memory information.
> +  Return UEFI memory map information.
> +
> +  @param[out] Below4GMemoryLimit  The below 4GiB memory limit address or 0 if insufficient resources exist to
> +                                  determine the address.
> +  @param[out] Above4GMemoryLimit  The above 4GiB memory limit address or 0 if insufficient resources exist to
> +                                  determine the address.
> 
> -  @param[out] Below4GMemoryLimit  The below 4GiB memory limit
> -  @param[out] Above4GMemoryLimit  The above 4GiB memory limit
>  **/
>  VOID
>  ReturnUefiMemoryMap (
> @@ -206,7 +209,11 @@ ReturnUefiMemoryMap (
>      // we process bogus entries and create bogus E820 entries.
>      //
>      EfiMemoryMap = (EFI_MEMORY_DESCRIPTOR *) AllocatePool (EfiMemoryMapSize);
> -    ASSERT (EfiMemoryMap != NULL);
> +    if (EfiMemoryMap == NULL) {
> +      ASSERT (EfiMemoryMap != NULL);

Above line may trigger a unreachable code error from some static code scanner.
How about move assertion to the line before if?

> +      return;
> +    }
> +
>      Status = gBS->GetMemoryMap (
>                      &EfiMemoryMapSize,
>                      EfiMemoryMap,
> @@ -218,7 +225,6 @@ ReturnUefiMemoryMap (
>        FreePool (EfiMemoryMap);
>      }
>    } while (Status == EFI_BUFFER_TOO_SMALL);
> -
>    ASSERT_EFI_ERROR (Status);
> 
>    //
> @@ -242,9 +248,6 @@ ReturnUefiMemoryMap (
>      NextEfiEntry  = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
>    }
> 
> -  //
> -  //
> -  //
>    DEBUG ((DEBUG_INFO, "MemoryMap:\n"));
>    EfiEntry        = EfiMemoryMap;
>    EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) EfiMemoryMap + EfiMemoryMapSize);
> --
> 2.16.2.windows.1


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

* Re: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference
  2019-08-26 23:51 ` Ni, Ray
@ 2019-08-27  0:47   ` Ni, Ray
  0 siblings, 0 replies; 4+ messages in thread
From: Ni, Ray @ 2019-08-27  0:47 UTC (permalink / raw)
  To: Kubacki, Michael A, 'devel@edk2.groups.io'; +Cc: Chaganty, Rangasai V

sorry for the false alarm.

The issue I met before is not like this one. There is no unreachable code issue.

Reviewed-by: Ray Ni <ray.ni@intel.com>

Thanks,
Ray

> -----Original Message-----
> From: Ni, Ray
> Sent: Monday, August 26, 2019 4:52 PM
> To: Kubacki, Michael A <michael.a.kubacki@intel.com>; devel@edk2.groups.io
> Cc: Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>
> Subject: RE: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference
> 
> Michael,
> 
> 
> > -----Original Message-----
> > From: Kubacki, Michael A
> > Sent: Friday, August 23, 2019 7:54 PM
> > To: devel@edk2.groups.io
> > Cc: Ni, Ray <ray.ni@intel.com>; Chaganty, Rangasai V <rangasai.v.chaganty@intel.com>
> > Subject: [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference
> >
> > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2116
> >
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
> > Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
> > ---
> >  Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c | 19 +++++++++++--------
> >  1 file changed, 11 insertions(+), 8 deletions(-)
> >
> > diff --git a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
> > b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
> > index 956ebb2d3d..9b6135ef94 100644
> > --- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
> > +++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
> > @@ -158,10 +158,13 @@ ProcessRequestedAccessAttribute (
> >  }
> >
> >  /**
> > -  return the UEFI memory information.
> > +  Return UEFI memory map information.
> > +
> > +  @param[out] Below4GMemoryLimit  The below 4GiB memory limit address or 0 if insufficient resources exist to
> > +                                  determine the address.
> > +  @param[out] Above4GMemoryLimit  The above 4GiB memory limit address or 0 if insufficient resources exist to
> > +                                  determine the address.
> >
> > -  @param[out] Below4GMemoryLimit  The below 4GiB memory limit
> > -  @param[out] Above4GMemoryLimit  The above 4GiB memory limit
> >  **/
> >  VOID
> >  ReturnUefiMemoryMap (
> > @@ -206,7 +209,11 @@ ReturnUefiMemoryMap (
> >      // we process bogus entries and create bogus E820 entries.
> >      //
> >      EfiMemoryMap = (EFI_MEMORY_DESCRIPTOR *) AllocatePool (EfiMemoryMapSize);
> > -    ASSERT (EfiMemoryMap != NULL);
> > +    if (EfiMemoryMap == NULL) {
> > +      ASSERT (EfiMemoryMap != NULL);
> 
> Above line may trigger a unreachable code error from some static code scanner.
> How about move assertion to the line before if?
> 
> > +      return;
> > +    }
> > +
> >      Status = gBS->GetMemoryMap (
> >                      &EfiMemoryMapSize,
> >                      EfiMemoryMap,
> > @@ -218,7 +225,6 @@ ReturnUefiMemoryMap (
> >        FreePool (EfiMemoryMap);
> >      }
> >    } while (Status == EFI_BUFFER_TOO_SMALL);
> > -
> >    ASSERT_EFI_ERROR (Status);
> >
> >    //
> > @@ -242,9 +248,6 @@ ReturnUefiMemoryMap (
> >      NextEfiEntry  = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
> >    }
> >
> > -  //
> > -  //
> > -  //
> >    DEBUG ((DEBUG_INFO, "MemoryMap:\n"));
> >    EfiEntry        = EfiMemoryMap;
> >    EfiMemoryMapEnd = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) EfiMemoryMap + EfiMemoryMapSize);
> > --
> > 2.16.2.windows.1


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

end of thread, other threads:[~2019-08-27  0:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-24  2:54 [edk2-platforms][PATCH V1 1/1] IntelSiliconPkg/IntelVTdDxe: Fix NULL pointer dereference Kubacki, Michael A
2019-08-26 23:41 ` Chaganty, Rangasai V
2019-08-26 23:51 ` Ni, Ray
2019-08-27  0:47   ` Ni, Ray

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