From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 54735223DB798 for ; Fri, 9 Feb 2018 01:14:54 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Feb 2018 01:20:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,482,1511856000"; d="scan'208";a="18564520" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 09 Feb 2018 01:20:38 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 9 Feb 2018 01:20:38 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 9 Feb 2018 01:20:38 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.125]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.130]) with mapi id 14.03.0319.002; Fri, 9 Feb 2018 17:20:36 +0800 From: "Gao, Liming" To: "Bi, Dandan" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" , "Zeng, Star" Thread-Topic: [edk2] [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token" Thread-Index: AQHToXyHQ7Gsq7iKkEeVjpp7Y0tVSKOby3yQ Date: Fri, 9 Feb 2018 09:20:35 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1CAE88@SHSMSX104.ccr.corp.intel.com> References: <1518163418-23228-1-git-send-email-dandan.bi@intel.com> In-Reply-To: <1518163418-23228-1-git-send-email-dandan.bi@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token" X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 09:14:55 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >Dandan Bi >Sent: Friday, February 09, 2018 4:04 PM >To: edk2-devel@lists.01.org >Cc: Yao, Jiewen ; Zeng, Star ; >Gao, Liming >Subject: [edk2] [patch] MdeModulePkg/PerfLib: Add NULL pointer check for >"Token" > >"Token" is passed through the perf entry, it's may be NULL. >So we need to add NULL pointer check before reference it. > >Cc: Liming Gao >Cc: Star Zeng >Cc: Jiewen Yao >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Dandan Bi >--- > MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c >| 6 +++++- > MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c | 6 >+++++- > >MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib. >c | 6 +++++- > 3 files changed, 15 insertions(+), 3 deletions(-) > >diff --git >a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib. >c >b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib. >c >index 8363b0e..9b3224e 100644 >--- >a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib. >c >+++ >b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib. >c >@@ -113,10 +113,14 @@ Check whether the Token is a known one which is >uesed by core. > BOOLEAN > IsKnownTokens ( > IN CONST CHAR8 *Token > ) > { >+ if (Token =3D=3D NULL) { >+ return FALSE; >+ } >+ > if (AsciiStrCmp (Token, SEC_TOK) =3D=3D 0 || > AsciiStrCmp (Token, PEI_TOK) =3D=3D 0 || > AsciiStrCmp (Token, DXE_TOK) =3D=3D 0 || > AsciiStrCmp (Token, BDS_TOK) =3D=3D 0 || > AsciiStrCmp (Token, DRIVERBINDING_START_TOK) =3D=3D 0 || >@@ -845,11 +849,11 @@ InsertFpdtMeasurement ( > return Status; > } > > // > // If PERF_START()/PERF_END() have specified the ProgressID,it has high >priority. >- // !!! Note: If the Pref is not the known Token used in the core but ha= ve >same >+ // !!! Note: If the Perf is not the known Token used in the core but ha= ve >same > // ID with the core Token, this case will not be supported. > // And in currtnt usage mode, for the unkown ID, there is a general rul= e: > // If it is start pref: the lower 4 bits of the ID should be 0. > // If it is end pref: the lower 4 bits of the ID should not be 0. > // If input ID doesn't follow the rule, we will adjust it. >diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c >b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c >index 79b67e8..f770a35 100644 >--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c >+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c >@@ -47,10 +47,14 @@ Check whether the Token is a known one which is >uesed by core. > BOOLEAN > IsKnownTokens ( > IN CONST CHAR8 *Token > ) > { >+ if (Token =3D=3D NULL) { >+ return FALSE; >+ } >+ > if (AsciiStrCmp (Token, SEC_TOK) =3D=3D 0 || > AsciiStrCmp (Token, PEI_TOK) =3D=3D 0 || > AsciiStrCmp (Token, DXE_TOK) =3D=3D 0 || > AsciiStrCmp (Token, BDS_TOK) =3D=3D 0 || > AsciiStrCmp (Token, DRIVERBINDING_START_TOK) =3D=3D 0 || >@@ -264,11 +268,11 @@ InsertPeiFpdtMeasurement ( > return Status; > } > > // > // If PERF_START()/PERF_END() have specified the ProgressID,it has high >priority. >- // !!! Note: If the Pref is not the known Token used in the core but ha= ve >same >+ // !!! Note: If the Perf is not the known Token used in the core but ha= ve >same > // ID with the core Token, this case will not be supported. > // And in currtnt usage mode, for the unkown ID, there is a general rul= e: > // If it is start pref: the lower 4 bits of the ID should be 0. > // If it is end pref: the lower 4 bits of the ID should not be 0. > // If input ID doesn't follow the rule, we will adjust it. >diff --git >a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL >ib.c >b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL >ib.c >index 2834a68..dbc1166 100644 >--- >a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL >ib.c >+++ >b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceL >ib.c >@@ -83,10 +83,14 @@ Check whether the Token is a known one which is >uesed by core. > BOOLEAN > IsKnownTokens ( > IN CONST CHAR8 *Token > ) > { >+ if (Token =3D=3D NULL) { >+ return FALSE; >+ } >+ > if (AsciiStrCmp (Token, SEC_TOK) =3D=3D 0 || > AsciiStrCmp (Token, PEI_TOK) =3D=3D 0 || > AsciiStrCmp (Token, DXE_TOK) =3D=3D 0 || > AsciiStrCmp (Token, BDS_TOK) =3D=3D 0 || > AsciiStrCmp (Token, DRIVERBINDING_START_TOK) =3D=3D 0 || >@@ -495,11 +499,11 @@ InsertFpdtMeasurement ( > return Status; > } > > // > // If PERF_START()/PERF_END() have specified the ProgressID,it has high >priority. >- // !!! Note: If the Pref is not the known Token used in the core but ha= ve >same >+ // !!! Note: If the Perf is not the known Token used in the core but ha= ve >same > // ID with the core Token, this case will not be supported. > // And in currtnt usage mode, for the unkown ID, there is a general rul= e: > // If it is start pref: the lower 4 bits of the ID should be 0. > // If it is end pref: the lower 4 bits of the ID should not be 0. > // If input ID doesn't follow the rule, we will adjust it. >-- >1.9.5.msysgit.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel