From nobody Sun Apr 28 17:25:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+49255+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49255+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1571576766; cv=none; d=zoho.com; s=zohoarc; b=nwpIMGAIJjuBftk1rPSUIhLcmX2Pi4MjvivJ1t0g08U0Jx3rxvbbOUS+gtk7u/KtAHODvj4lf5QU1GFECVoLaeMVnxkRdnPbyrXIZZpea/u2u+rm1g2FZDI6kqZTZTGoI9wC/BC9Ag4j5Y43TOypyOaLbVksEi6lGWs6yW/qqkk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576766; h=Content-Type:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=urZ285h0jKovF88qqlQzHDJ7YygHJ+1yO8jjTKUEcRo=; b=ZWl0LUooCeWaNz+B2Zr2oX7R0mEc0RG6eU9ts3EbewomDPysQdWk2FFyEfMOSw+yiCyp/k+YfCf07cFyJjfLgNcU0deio2tLLRhkuiWericDstCMblifkhuZZod8O0At75Ts9lS4bFQR1BJQ0G/salnj2c3AfJJCMc2Iu4A4pP8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49255+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1571576765880946.3676161333533; Sun, 20 Oct 2019 06:06:05 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Sun, 20 Oct 2019 06:06:05 -0700 X-Received: from mail4.protonmail.ch (mail4.protonmail.ch [185.70.40.27]) by mx.groups.io with SMTP id smtpd.web11.1924.1571576763302665414 for ; Sun, 20 Oct 2019 06:06:04 -0700 Date: Sun, 20 Oct 2019 13:05:56 +0000 To: devel@edk2.groups.io From: "Vitaly Cheptsov via Groups.Io" Reply-To: devel@edk2.groups.io,vit9696@protonmail.com Subject: [edk2-devel] [PATCH v1 1/1] MdePkg: Add PCD to disable safe string constraint assertions Message-ID: <20191020130553.42851-2-vit9696@protonmail.com> In-Reply-To: <20191020130553.42851-1-vit9696@protonmail.com> References: <20191020130553.42851-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 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha256; boundary="---------------------f1bbb231a1e0ee1443ee043974de5809"; charset=UTF-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1571576765; bh=Mvzx+07yoWD0Rxlt/iwOvYbVjFL1+C29XmxSfvpvr1M=; h=Content-Type:Date:From:Reply-To:Subject:To; b=I1xJ5rKgEYBknOrrScoB71R8Mt6rysABeQiftXukV1JDyo7bvwVfhhS5a+uHbvqsI4b dVSo+nMerUcBlw66AZmrxNwy/SpB+XOVdmLFagjR4PSpo7GEmEoiYCIDzLyhGFqR2Aqit ezujXCQ2x+49QRvopmzLOYrRn7dmsvi8Xpo= X-Zoho-Virus-Status: 1 X-ZohoMail-DKIM: pass (identity @groups.io) -----------------------f1bbb231a1e0ee1443ee043974de5809 Content-Transfer-Encoding: quoted-printable Date: Sun, 20 Oct 2019 16:05:53 +0300 From: Vitaly Cheptsov In-Reply-To: <20191020130553.42851-1-vit9696@protonmail.com> Message-Id: <20191020130553.42851-2-vit9696@protonmail.com> Mime-Version: 1.0 References: <20191020130553.42851-1-vit9696@protonmail.com> Subject: [PATCH v1 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) Content-Type: text/plain; charset="utf-8" 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|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|FALSE|BOOLEAN|= 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/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) -=3D-=3D-=3D-=3D-=3D-=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/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- -----------------------f1bbb231a1e0ee1443ee043974de5809 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: ProtonMail wsBmBAEBCAAQBQJdrFu0CRBPsoxt7Hy0xQAKCRBPsoxt7Hy0xU5yCAAqDIOJ rcYIfvXDLPz1efasL6NQ6gI9E2D1Mou0sBVWBQdRjZr3k1kXv3yhe833WEin ac9xMARchLzDZTaZpLexW3ETpxgJ6r6npjJzyKXgt6LpUbghTYo86QAMzVQX GzWrVuE1FD3iXwYK3xyRNvLEu820zD3CvkJi+nuS8XhiFGCbCEWGB7TFa87Y nVfJs42nQE7DLrZL+zyn+4cjsb17aW+y4XMCqwelj/VtmgHp+EdUKc+lo49g 6GavEtF4vLZv+0uWOAwBVprxn0c67aL2wCdCb+PVqAv4GmkfcI2A8Y3JtmAw V2E/8dmB7gUkgxuXHZG5GQ8GcrVCfD5TQN1w =4cUm -----END PGP SIGNATURE----- -----------------------f1bbb231a1e0ee1443ee043974de5809--