public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg SmbiosMeasurementDxe: Add NominalSpeed in Type 27 to black list
@ 2016-09-01  2:01 Star Zeng
  2016-09-01  2:19 ` Yao, Jiewen
  0 siblings, 1 reply; 2+ messages in thread
From: Star Zeng @ 2016-09-01  2:01 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 .../SmbiosMeasurementDxe/SmbiosMeasurementDxe.c    | 31 ++++++++++++++--------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
index f9e0196677a9..bc5e7464e133 100644
--- a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
+++ b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c
@@ -1,7 +1,7 @@
 /** @file
   This driver measures SMBIOS table to TPM.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -84,6 +84,9 @@ SMBIOS_FILTER_TABLE  mSmbiosFilterType22BlackList[] = {
 SMBIOS_FILTER_TABLE  mSmbiosFilterType23BlackList[] = {
   {0x17, OFFSET_OF(SMBIOS_TABLE_TYPE23, ResetCount),          FIELD_SIZE_OF(SMBIOS_TABLE_TYPE23, ResetCount),          0},
 };
+SMBIOS_FILTER_TABLE  mSmbiosFilterType27BlackList[] = {
+  {0x1B, OFFSET_OF(SMBIOS_TABLE_TYPE27, NominalSpeed),        FIELD_SIZE_OF(SMBIOS_TABLE_TYPE27, NominalSpeed),        0},
+};
 SMBIOS_FILTER_TABLE  mSmbiosFilterType39BlackList[] = {
   {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39, SerialNumber),        FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39, SerialNumber),        SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
   {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39, AssetTagNumber),      FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39, AssetTagNumber),      SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
@@ -101,6 +104,7 @@ SMBIOS_FILTER_STRUCT  mSmbiosFilterStandardTableBlackList[] = {
   {0x12, NULL, 0},
   {0x16, mSmbiosFilterType22BlackList, sizeof(mSmbiosFilterType22BlackList)/sizeof(mSmbiosFilterType22BlackList[0])},
   {0x17, mSmbiosFilterType23BlackList, sizeof(mSmbiosFilterType23BlackList)/sizeof(mSmbiosFilterType23BlackList[0])},
+  {0x1B, mSmbiosFilterType27BlackList, sizeof(mSmbiosFilterType27BlackList)/sizeof(mSmbiosFilterType27BlackList[0])},
   {0x1F, NULL, 0},
   {0x21, NULL, 0},
   {0x27, mSmbiosFilterType39BlackList, sizeof(mSmbiosFilterType39BlackList)/sizeof(mSmbiosFilterType39BlackList[0])},
@@ -281,18 +285,23 @@ FilterSmbiosEntry (
     } else {
       Filter = FilterStruct->Filter;
       for (Index = 0; Index < FilterStruct->FilterCount; Index++) {
-        if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
-          CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, sizeof(StringId));
-          if (StringId != 0) {
-            // set ' ' for string field
-            String = GetSmbiosStringById (TableEntry, StringId, &StringLen);
-            ASSERT (String != NULL);
-            //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
-            SetMem (String, StringLen, ' ');
+        if (((SMBIOS_STRUCTURE *) TableEntry)->Length >= (Filter[Index].Offset + Filter[Index].Size)) {
+          //
+          // The field is present in the SMBIOS entry.
+          //
+          if ((Filter[Index].Flags & SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
+            CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset, sizeof(StringId));
+            if (StringId != 0) {
+              // set ' ' for string field
+              String = GetSmbiosStringById (TableEntry, StringId, &StringLen);
+              ASSERT (String != NULL);
+              //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId, String, StringLen));
+              SetMem (String, StringLen, ' ');
+            }
           }
+          // zero non-string field
+          ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, Filter[Index].Size);
         }
-        // zero non-string field
-        ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset, Filter[Index].Size);
       }
     }
   }
-- 
2.7.0.windows.1



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

* Re: [PATCH] MdeModulePkg SmbiosMeasurementDxe: Add NominalSpeed in Type 27 to black list
  2016-09-01  2:01 [PATCH] MdeModulePkg SmbiosMeasurementDxe: Add NominalSpeed in Type 27 to black list Star Zeng
@ 2016-09-01  2:19 ` Yao, Jiewen
  0 siblings, 0 replies; 2+ messages in thread
From: Yao, Jiewen @ 2016-09-01  2:19 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org

Reviewed-by: Jiewen.yao@intel.com

> -----Original Message-----
> From: Zeng, Star
> Sent: Thursday, September 1, 2016 10:01 AM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH] MdeModulePkg SmbiosMeasurementDxe: Add
> NominalSpeed in Type 27 to black list
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  .../SmbiosMeasurementDxe/SmbiosMeasurementDxe.c    | 31
> ++++++++++++++--------
>  1 file changed, 20 insertions(+), 11 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurement
> Dxe.c
> b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurement
> Dxe.c
> index f9e0196677a9..bc5e7464e133 100644
> ---
> a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurement
> Dxe.c
> +++
> b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurement
> Dxe.c
> @@ -1,7 +1,7 @@
>  /** @file
>    This driver measures SMBIOS table to TPM.
> 
> -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
>  This program and the accompanying materials
>  are licensed and made available under the terms and conditions of the BSD
> License
>  which accompanies this distribution.  The full text of the license may be
> found at
> @@ -84,6 +84,9 @@ SMBIOS_FILTER_TABLE
> mSmbiosFilterType22BlackList[] = {
>  SMBIOS_FILTER_TABLE  mSmbiosFilterType23BlackList[] = {
>    {0x17, OFFSET_OF(SMBIOS_TABLE_TYPE23, ResetCount),
> FIELD_SIZE_OF(SMBIOS_TABLE_TYPE23, ResetCount),          0},
>  };
> +SMBIOS_FILTER_TABLE  mSmbiosFilterType27BlackList[] = {
> +  {0x1B, OFFSET_OF(SMBIOS_TABLE_TYPE27, NominalSpeed),
> FIELD_SIZE_OF(SMBIOS_TABLE_TYPE27, NominalSpeed),        0},
> +};
>  SMBIOS_FILTER_TABLE  mSmbiosFilterType39BlackList[] = {
>    {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39, SerialNumber),
> FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39, SerialNumber),
> SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
>    {0x27, OFFSET_OF(SMBIOS_TABLE_TYPE39, AssetTagNumber),
> FIELD_SIZE_OF(SMBIOS_TABLE_TYPE39, AssetTagNumber),
> SMBIOS_FILTER_TABLE_FLAG_IS_STRING},
> @@ -101,6 +104,7 @@ SMBIOS_FILTER_STRUCT
> mSmbiosFilterStandardTableBlackList[] = {
>    {0x12, NULL, 0},
>    {0x16, mSmbiosFilterType22BlackList,
> sizeof(mSmbiosFilterType22BlackList)/sizeof(mSmbiosFilterType22BlackList[0
> ])},
>    {0x17, mSmbiosFilterType23BlackList,
> sizeof(mSmbiosFilterType23BlackList)/sizeof(mSmbiosFilterType23BlackList[0
> ])},
> +  {0x1B, mSmbiosFilterType27BlackList,
> sizeof(mSmbiosFilterType27BlackList)/sizeof(mSmbiosFilterType27BlackList[0
> ])},
>    {0x1F, NULL, 0},
>    {0x21, NULL, 0},
>    {0x27, mSmbiosFilterType39BlackList,
> sizeof(mSmbiosFilterType39BlackList)/sizeof(mSmbiosFilterType39BlackList[0
> ])},
> @@ -281,18 +285,23 @@ FilterSmbiosEntry (
>      } else {
>        Filter = FilterStruct->Filter;
>        for (Index = 0; Index < FilterStruct->FilterCount; Index++) {
> -        if ((Filter[Index].Flags &
> SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
> -          CopyMem (&StringId, (UINT8 *)TableEntry + Filter[Index].Offset,
> sizeof(StringId));
> -          if (StringId != 0) {
> -            // set ' ' for string field
> -            String = GetSmbiosStringById (TableEntry, StringId,
> &StringLen);
> -            ASSERT (String != NULL);
> -            //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId,
> String, StringLen));
> -            SetMem (String, StringLen, ' ');
> +        if (((SMBIOS_STRUCTURE *) TableEntry)->Length >=
> (Filter[Index].Offset + Filter[Index].Size)) {
> +          //
> +          // The field is present in the SMBIOS entry.
> +          //
> +          if ((Filter[Index].Flags &
> SMBIOS_FILTER_TABLE_FLAG_IS_STRING) != 0) {
> +            CopyMem (&StringId, (UINT8 *)TableEntry +
> Filter[Index].Offset, sizeof(StringId));
> +            if (StringId != 0) {
> +              // set ' ' for string field
> +              String = GetSmbiosStringById (TableEntry, StringId,
> &StringLen);
> +              ASSERT (String != NULL);
> +              //DEBUG ((EFI_D_INFO,"StrId(0x%x)-%a(%d)\n", StringId,
> String, StringLen));
> +              SetMem (String, StringLen, ' ');
> +            }
>            }
> +          // zero non-string field
> +          ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset,
> Filter[Index].Size);
>          }
> -        // zero non-string field
> -        ZeroMem ((UINT8 *)TableEntry + Filter[Index].Offset,
> Filter[Index].Size);
>        }
>      }
>    }
> --
> 2.7.0.windows.1



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

end of thread, other threads:[~2016-09-01  2:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-01  2:01 [PATCH] MdeModulePkg SmbiosMeasurementDxe: Add NominalSpeed in Type 27 to black list Star Zeng
2016-09-01  2:19 ` Yao, Jiewen

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