From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1.protonmail.ch (mail1.protonmail.ch [185.70.40.18]) by mx.groups.io with SMTP id smtpd.web11.2267.1571728398443993693 for ; Tue, 22 Oct 2019 00:13:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@protonmail.com header.s=default header.b=YmhBcCZ+; spf=pass (domain: protonmail.com, ip: 185.70.40.18, mailfrom: vit9696@protonmail.com) Date: Tue, 22 Oct 2019 07:13:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1571728395; bh=ZrcK6N/WFBt9O7giIuqOk2OVaVLP7lb8xPkMuE0o2cY=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:Feedback-ID: From; b=YmhBcCZ+i87ydd5+Veb3w4YpEU6GAHxogM4OeVlGSCGm4CT0tfEKfDuQqTjLYc3Kj Om5iDOhqNKg3qwKHsL1JUYFYMvsQR5zEynffChr70P5EDKVGBJOFy4ipH3FpT/sMN+ AQLHhO0Ab5hBxk5lcS74+aelnb10JAZMmbWFFAgM= To: devel@edk2.groups.io From: "Vitaly Cheptsov" Reply-To: Vitaly Cheptsov Subject: [PATCH v2 1/1] MdePkg: Add PCD to disable safe string constraint assertions Message-ID: <20191022071310.18719-2-vit9696@protonmail.com> In-Reply-To: <20191022071310.18719-1-vit9696@protonmail.com> References: <20191022071310.18719-1-vit9696@protonmail.com> Feedback-ID: p9QuX-L1wMgUm6nrSvNrf8juLupNs0VSnzXGVXuYDxlEahFdWtaedWDMB9zpwGDklGt7kzs1-RBc0cqz327Gcg==:Ext:ProtonMail MIME-Version: 1.0 X-Spam-Status: No, score=-0.7 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FREEMAIL_REPLYTO_END_DIGIT autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch X-Groupsio-MsgNum: 49327 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha256; boundary="---------------------0310f9fd6880631d240b66b5a1ad6284"; charset=UTF-8 -----------------------0310f9fd6880631d240b66b5a1ad6284 Content-Transfer-Encoding: quoted-printable Date: Tue, 22 Oct 2019 10:13:10 +0300 From: Vitaly Cheptsov In-Reply-To: <20191022071310.18719-1-vit9696@protonmail.com> Message-Id: <20191022071310.18719-2-vit9696@protonmail.com> Mime-Version: 1.0 References: <20191022071310.18719-1-vit9696@protonmail.com> Subject: [PATCH v2 1/1] MdePkg: Add PCD to disable safe string constraint assertions To: devel@edk2.groups.io X-Mailer: git-send-email 2.21.0 (Apple Git-122) 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..c1671333f6 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -2221,6 +2221,12 @@ [PcdsFixedAtBuild,PcdsPatchableInModule] # @Prompt Memory Address of GuidedExtractHandler Table. gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|0x1000000|U= INT64|0x30001015 =20 + ## Indicates if safe string constraint violation should assert.

+ # TRUE - Safe string constraint violation causes assertion.
+ # FALSE - Safe string constraint violation does not cause assertion. + # @Prompt Enable safe string constraint violation assertions. + gEfiMdePkgTokenSpaceGuid.PcdAssertOnSafeStringConstraints|TRUE|BOOLEAN|0= x0000002e + [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/Ba= seLib.inf index 3586beb0ab..bc98bc6134 100644 --- a/MdePkg/Library/BaseLib/BaseLib.inf +++ b/MdePkg/Library/BaseLib/BaseLib.inf @@ -390,11 +390,12 @@ [LibraryClasses] BaseMemoryLib =20 [Pcd] - gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength ## SOMETIMES_CO= NSUMES - gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength ## SOMETIMES_CO= NSUMES - gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength ## SOMETIMES_CO= NSUMES - gEfiMdePkgTokenSpaceGuid.PcdControlFlowEnforcementPropertyMask ## SOME= TIMES_CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdSpeculationBarrierType ## SOMETIMES_CO= NSUMES + gEfiMdePkgTokenSpaceGuid.PcdAssertOnSafeStringConstraints ## SOMET= IMES_CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength ## SOMET= IMES_CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength ## SOMET= IMES_CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength ## SOMET= IMES_CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdControlFlowEnforcementPropertyMask ## SOMET= IMES_CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdSpeculationBarrierType ## SOMET= IMES_CONSUMES =20 [FeaturePcd] gEfiMdePkgTokenSpaceGuid.PcdVerifyNodeInList ## CONSUMES diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/S= afeString.c index 7dc03d2caa..56b5e34a8d 100644 --- a/MdePkg/Library/BaseLib/SafeString.c +++ b/MdePkg/Library/BaseLib/SafeString.c @@ -14,7 +14,9 @@ =20 #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 @@ =20 #string STR_gEfiMdePkgTokenSpaceGuid_PcdGuidedExtractHandlerTableAddress_H= ELP #language en-US "This value is used to set the available memory addres= s to store Guided Extract Handlers. The required memory space is decided by= the value of PcdMaximumGuidedExtractHandler." =20 +#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 ass= ert.

\n" + = "TRUE - Safe string constraint violation causes assertion.
\n" + = "FALSE - Safe string constraint violation does not cause assertion= .
" + #string STR_gEfiMdePkgTokenSpaceGuid_PcdPciExpressBaseAddress_PROMPT #lan= guage en-US "PCI Express Base Address" =20 #string STR_gEfiMdePkgTokenSpaceGuid_PcdPciExpressBaseAddress_HELP #langu= age en-US "This value is used to set the base address of PCI express hierar= chy." --=20 2.21.0 (Apple Git-122) -----------------------0310f9fd6880631d240b66b5a1ad6284 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: ProtonMail wsBmBAEBCAAQBQJdrqwJCRBPsoxt7Hy0xQAKCRBPsoxt7Hy0xbZ5CAAkb0jR ka9eS0s60Ig1nI86scPIpf1726U0ryOUkCyuFQr/9uakHZF4bnuEB8or97Ic smtSXAZAsOQpHpM3zSkF91Y6M5vPGDQ+PXn5DMQEn6O/lx90z9Ir/qoYaCt6 2s+Dt5uBUON+8R/P6W4BZ0kL0tSopOGHVrWEV+nFGlQ0y3ULTaPopyx6SA8d ErkTeKt+GBkj1Jm+r0tr6PwxuCWTHb4ZrUS0L1Bau+HLRT8Zq2j6K2sr2K1S ZXdDFMEXlP81dGSMDvLk9m2tGBGb8/JquBoaeXUbJ4rdM1FEHhKAEi+H5MRx MiWEKVNJ4exDGJcaR5YslL1vTa1oX/HPRF4Z =3d2e -----END PGP SIGNATURE----- -----------------------0310f9fd6880631d240b66b5a1ad6284--