From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.295.1571627808394459173 for ; Sun, 20 Oct 2019 20:16:48 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Oct 2019 20:16:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,322,1566889200"; d="scan'208";a="280841940" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 20 Oct 2019 20:16:47 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 20 Oct 2019 20:16:47 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 20 Oct 2019 20:16:46 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 20 Oct 2019 20:16:46 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.166]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.96]) with mapi id 14.03.0439.000; Mon, 21 Oct 2019 11:16:45 +0800 From: "Liming Gao" To: "devel@edk2.groups.io" , "vit9696@protonmail.com" CC: "Yao, Jiewen" , "Wang, Jian J" , "Gao, Liming" , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH v1 1/1] MdePkg: Add PCD to disable safe string constraint assertions Thread-Topic: [edk2-devel] [PATCH v1 1/1] MdePkg: Add PCD to disable safe string constraint assertions Thread-Index: AQHVh0cm+VNYtFU4E0qucplGEnYFUqdkbQKA Date: Mon, 21 Oct 2019 03:16:44 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E51F6EB@SHSMSX104.ccr.corp.intel.com> References: <20191020130553.42851-1-vit9696@protonmail.com> <20191020130553.42851-2-vit9696@protonmail.com> In-Reply-To: <20191020130553.42851-2-vit9696@protonmail.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Include more people.=20 Basically, to keep the compatible behavior, PcdAssertOnSafeStringConstraint= s default value should be TRUE.=20 The different platform can configure it.=20 Thanks Liming >-----Original Message----- >From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >Vitaly Cheptsov via Groups.Io >Sent: Sunday, October 20, 2019 9:06 PM >To: devel@edk2.groups.io >Subject: [edk2-devel] [PATCH v1 1/1] MdePkg: Add PCD to disable safe strin= g >constraint assertions > >REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2054 > >Runtime data checks are not meant to cause debug assertions >unless explicitly needed by some debug code (thus the PCD) >as this breaks debug builds validating data with BaseLib. > >Signed-off-by: Vitaly Cheptsov > >--- > MdePkg/MdePkg.dec | 6 ++++++ > MdePkg/Library/BaseLib/BaseLib.inf | 11 ++++++----- > MdePkg/Library/BaseLib/SafeString.c | 4 +++- > MdePkg/MdePkg.uni | 6 ++++++ > 4 files changed, 21 insertions(+), 6 deletions(-) > >diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec >index 3fd7d1634c..dda2cdf401 100644 >--- a/MdePkg/MdePkg.dec >+++ b/MdePkg/MdePkg.dec >@@ -2221,6 +2221,12 @@ [PcdsFixedAtBuild,PcdsPatchableInModule] > # @Prompt Memory Address of GuidedExtractHandler Table. > >gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|0x10000 >00|UINT64|0x30001015 > >+ ## Indicates if safe string constraint violation should assert.

>+ # TRUE - Safe string constraint violation causes assertion.
>+ # FALSE - Safe string constraint violation does not cause assertion.<= BR> >+ # @Prompt Enable safe string constraint violation assertions. >+ >gEfiMdePkgTokenSpaceGuid.PcdAssertOnSafeStringConstraints|FALSE|BOOL >EAN|0x0000002e >+ > [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] > ## This value is used to set the base address of PCI express hierarchy. > # @Prompt PCI Express Base Address. >diff --git a/MdePkg/Library/BaseLib/BaseLib.inf >b/MdePkg/Library/BaseLib/BaseLib.inf >index 3586beb0ab..bc98bc6134 100644 >--- a/MdePkg/Library/BaseLib/BaseLib.inf >+++ b/MdePkg/Library/BaseLib/BaseLib.inf >@@ -390,11 +390,12 @@ [LibraryClasses] > BaseMemoryLib > > [Pcd] >- gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength ## >SOMETIMES_CONSUMES >- gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength ## >SOMETIMES_CONSUMES >- gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength ## >SOMETIMES_CONSUMES >- gEfiMdePkgTokenSpaceGuid.PcdControlFlowEnforcementPropertyMask >## SOMETIMES_CONSUMES >- gEfiMdePkgTokenSpaceGuid.PcdSpeculationBarrierType ## >SOMETIMES_CONSUMES >+ gEfiMdePkgTokenSpaceGuid.PcdAssertOnSafeStringConstraints ## >SOMETIMES_CONSUMES >+ gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength ## >SOMETIMES_CONSUMES >+ gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength ## >SOMETIMES_CONSUMES >+ gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength ## >SOMETIMES_CONSUMES >+ gEfiMdePkgTokenSpaceGuid.PcdControlFlowEnforcementPropertyMask >## SOMETIMES_CONSUMES >+ gEfiMdePkgTokenSpaceGuid.PcdSpeculationBarrierType ## >SOMETIMES_CONSUMES > > [FeaturePcd] > gEfiMdePkgTokenSpaceGuid.PcdVerifyNodeInList ## CONSUMES >diff --git a/MdePkg/Library/BaseLib/SafeString.c >b/MdePkg/Library/BaseLib/SafeString.c >index 7dc03d2caa..56b5e34a8d 100644 >--- a/MdePkg/Library/BaseLib/SafeString.c >+++ b/MdePkg/Library/BaseLib/SafeString.c >@@ -14,7 +14,9 @@ > > #define SAFE_STRING_CONSTRAINT_CHECK(Expression, Status) \ > do { \ >- ASSERT (Expression); \ >+ if (PcdGetBool (PcdAssertOnSafeStringConstraints)) { \ >+ ASSERT (Expression); \ >+ } \ > if (!(Expression)) { \ > return Status; \ > } \ >diff --git a/MdePkg/MdePkg.uni b/MdePkg/MdePkg.uni >index 5c1fa24065..425b66bb43 100644 >--- a/MdePkg/MdePkg.uni >+++ b/MdePkg/MdePkg.uni >@@ -287,6 +287,12 @@ > > #string >STR_gEfiMdePkgTokenSpaceGuid_PcdGuidedExtractHandlerTableAddress_H >ELP #language en-US "This value is used to set the available memory addre= ss >to store Guided Extract Handlers. The required memory space is decided by >the value of PcdMaximumGuidedExtractHandler." > >+#string >STR_gEfiMdePkgTokenSpaceGuid_PcdAssertOnSafeStringConstraints_PROM >PT #language en-US "Enable safe string constraint violation assertions" >+ >+#string >STR_gEfiMdePkgTokenSpaceGuid_PcdAssertOnSafeStringConstraints_HELP >#language en-US "Indicates if safe string constraint violation should >assert.

\n" >+ = "TRUE - Safe string constraint >violation causes assertion.
\n" >+ = "FALSE - Safe string constraint >violation does not cause assertion.
" >+ > #string >STR_gEfiMdePkgTokenSpaceGuid_PcdPciExpressBaseAddress_PROMPT >#language en-US "PCI Express Base Address" > > #string STR_gEfiMdePkgTokenSpaceGuid_PcdPciExpressBaseAddress_HELP >#language en-US "This value is used to set the base address of PCI express >hierarchy." >-- >2.21.0 (Apple Git-122) > > >-=3D-=3D-=3D-=3D-=3D-=3D >Groups.io Links: You receive all messages sent to this group. > >View/Reply Online (#49255): https://edk2.groups.io/g/devel/message/49255 >Mute This Topic: https://groups.io/mt/35943317/1759384 >Group Owner: devel+owner@edk2.groups.io >Unsubscribe: https://edk2.groups.io/g/devel/unsub [liming.gao@intel.com] >-=3D-=3D-=3D-=3D-=3D-=3D