From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101825+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101825+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679690978; cv=none; d=zohomail.com; s=zohoarc; b=fGiM3fZBh5pnYQr0I3fyWwD7dLcAABVakgodKCPldAtUhu1J7T1RU6BWH7NhpVEQPOg5kh/Vyj4QXlQR6CRoLL0JvLbVoZCY+DIGhQwnDQ6GhBC+pK+Z2XJJgflJDFn3Rj9xoEoSsLjkizMZNuiQsyvhvgIlT63B+l/5pXZ6aiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679690978; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=VzA/fKonoxm5ueGA2xyCH0A4wcFJa9NMW+h1PHNYCqE=; b=NebTGHN7+gTkzF9KAvSKckqHMqyjobL0ssSZlO+2aee86V/1hykAzufz80T2ZeEJXfVJiTQ1ewPwv3qPSH82NzSLuyf/zgYtFy678QPJdoESOKbhBRGz9ASyahm4fxRD9miWAkW+7J/H5DdpgyCijioNoNq+3V78Teg5DfhU4KQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101825+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679690978371384.21080965207; Fri, 24 Mar 2023 13:49:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id uqKFYY1788612xXoHiRYU78J; Fri, 24 Mar 2023 13:49:38 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.8287.1679690977350758718 for ; Fri, 24 Mar 2023 13:49:37 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id B225E20FC455; Fri, 24 Mar 2023 13:49:35 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B225E20FC455 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Dandan Bi , Erich McMillan , Jian J Wang , Liming Gao , Michael Kubacki , Star Zeng , Zhichao Gao , Zhiguang Liu , Michael Kubacki Subject: [edk2-devel] [PATCH v6 01/12] MdeModulePkg/SmbiosDxe: Fix pointer and buffer overflow CodeQL alerts Date: Fri, 24 Mar 2023 16:48:27 -0400 Message-Id: <20230324204838.1485-2-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: LXctV9QEoH3BNGo0W0kTxBT9x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679690978; bh=OMlmj3SLlnd6e38w54QTaNUiJMcjLlfc3N+HGw2xaGY=; h=Cc:Date:From:Reply-To:Subject:To; b=SY6oIBNYOv0f3xyhbQAjdOOzSsCcAn8oBMJBKWJF+7QZ2ePTFJgGKLNj6ceQx4vaSMc gWQHNwurxgEtPApIFfZ/pxejjCbZ3by3jRrKfswqsKbFjfjpzhngdMA/BM/5lyzl+5L3P Uyzp0r7PCjyxXGmFRrm7pj8KluLBb80ZDZ8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679690979361100001 Content-Type: text/plain; charset="utf-8" From: Erich McMillan Details for these CodeQL alerts can be found here: - Pointer overflow check (cpp/pointer-overflow-check): - https://cwe.mitre.org/data/definitions/758.html - Potential buffer overflow check (cpp/potential-buffer-overflow): - https://cwe.mitre.org/data/definitions/676.html CodeQL alert: - Line 1612 in MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c - Type: Pointer overflow check - Severity: Low - Problem: Range check relying on pointer overflow Cc: Dandan Bi Cc: Erich McMillan Cc: Jian J Wang Cc: Liming Gao Cc: Michael Kubacki Cc: Star Zeng Cc: Zhichao Gao Cc: Zhiguang Liu Co-authored-by: Michael Kubacki Signed-off-by: Erich McMillan Reviewed-by: Liming Gao --- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Un= iversal/SmbiosDxe/SmbiosDxe.c index 1d43adc7662c..dd077bb0cf19 100644 --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c @@ -1608,9 +1608,7 @@ ParseAndAddExistingSmbiosTable ( // // Make sure not to access memory beyond SmbiosEnd // - if ((Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw) || - (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw)) - { + if ((UINTN)(SmbiosEnd.Raw - Smbios.Raw) < sizeof (SMBIOS_STRUCTURE)) { return EFI_INVALID_PARAMETER; } =20 @@ -1625,9 +1623,7 @@ ParseAndAddExistingSmbiosTable ( // Make sure not to access memory beyond SmbiosEnd // Each structure shall be terminated by a double-null (0000h). // - if ((Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) > SmbiosEnd.= Raw) || - (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw= )) - { + if ((UINTN)(SmbiosEnd.Raw - Smbios.Raw) < (Smbios.Hdr->Length + 2U)) { return EFI_INVALID_PARAMETER; } =20 --=20 2.40.0.windows.1 -=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 (#101825): https://edk2.groups.io/g/devel/message/101825 Mute This Topic: https://groups.io/mt/97832891/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101826+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101826+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679690989; cv=none; d=zohomail.com; s=zohoarc; b=EExtbIFP7L2th26jg/bks9jfFdHWyfE2eJjGxBIzp+BTO0zBkTBN+trwcWR6skTh4GtXL9/WapB8BCC49ZpFxGJdcx3QMEhKyUJpoE28JV4ZZDjaM2Kugj+1VJsoz1AL481BPa986dIn1GFUQmf2EWDL+ssmVeCP3XXiMUkof2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679690989; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=3oaERa9Ixq2OorpH9eK7bE8UTLQOEA82BCL79HdGG7Y=; b=iVYeiWvlc3FxWYxZNir5rxFNZbfAb9aCuhaZVo5ianpeVHa2731p0RRI0NppqJzw9d+6PJyB7TTZongYrktExccHIQDoJ+kw6DwHWPnK4IdDICNtrhxdbAOulVGjdzSCbl3dFTnyqDNFa5DZJzZYxEqHKPH2EMzInoEZpccG9Go= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101826+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679690989558195.21245398258202; Fri, 24 Mar 2023 13:49:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id QkDRYY1788612xwTfKp5n7Kq; Fri, 24 Mar 2023 13:49:49 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.8288.1679690983446302671 for ; Fri, 24 Mar 2023 13:49:43 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 1A17520FC455; Fri, 24 Mar 2023 13:49:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1A17520FC455 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Michael D Kinney , Sean Brogan , Yuwei Chen Subject: [edk2-devel] [PATCH v6 02/12] BaseTools/PatchCheck.py: Add PCCTS to tab exemption list Date: Fri, 24 Mar 2023 16:48:28 -0400 Message-Id: <20230324204838.1485-3-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: GCAzfiopTbpkl1ClmwhtXMybx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679690989; bh=uax9j4dk45QnIpd3ppd/V4Z0Xm0ZJ2u3bUUHeiFJhIc=; h=Cc:Date:From:Reply-To:Subject:To; b=hEWeJ3QqWxNsKjLtLJ23+l04KrF/e3/+PfmuIfFGEEttEUFurSDdQpgVxDBhFXwtYcp 8ypIJjYrI+klWVw+y53dcLX7fDka8Ftw9t3jhm821IIRaMmme4T8JhAxxz30bvZkv4SXH AQLkwLCIIRwORnVjJhj+laliMyY+TQihuFU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679690991398100005 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Purdue Compiler Construction Tool Set (PCCTS) source code was copied/ pasted into BaseTools/Source/C/VfrCompile/Pccts/. The code contains tab characters instead of spaces. PatchCheck.py gives an error on modifications to files that contain tabs. This change adds that directory to the pre-existing list of directories in which tab checks are ignored in PatchCheck.py. The goal of my upcoming change there is not to mix tabs and spaces but to fix a bug while preserving its current formatting characters. Cc: Bob Feng Cc: Liming Gao Cc: Michael D Kinney Cc: Sean Brogan Cc: Yuwei Chen Signed-off-by: Michael Kubacki Reviewed-by: Liming Gao Reviewed-by: Michael D Kinney --- BaseTools/Scripts/PatchCheck.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchCheck= .py index fcdabfc8acea..84d56b8c8b70 100755 --- a/BaseTools/Scripts/PatchCheck.py +++ b/BaseTools/Scripts/PatchCheck.py @@ -383,7 +383,9 @@ class GitDiffCheck: self.force_crlf =3D False self.force_notabs =3D False if os.path.basename(self.filename) =3D=3D 'GNUmakefile' or= \ - os.path.basename(self.filename) =3D=3D 'Makefile': + os.path.basename(self.filename) =3D=3D 'Makefile' or \ + self.filename.startswith( + 'BaseTools/Source/C/VfrCompile/Pccts/'): self.force_notabs =3D False elif len(line.rstrip()) !=3D 0: self.format_error("didn't find diff command") --=20 2.40.0.windows.1 -=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 (#101826): https://edk2.groups.io/g/devel/message/101826 Mute This Topic: https://groups.io/mt/97832892/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101827+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101827+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679690988; cv=none; d=zohomail.com; s=zohoarc; b=Kk+hSdK53xRbmWYFjH9F+r72lPicnGHqcih3lafx75vw/uPL9EhugK3jK8fQgGV7m7wiVPGbZGE0CkxPwZxKI2cu9mrCewWniSY0MAH2TBCIJfDHLC7HVJNnHBuoWCssK43wLYYfvlF+bgPNeeHWK+smx1/6vmO6f2TlSPCYb0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679690988; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=kMXXxAy12KL+xZgh1n3nIGDHmhoOjwsEj+7ttdBvQf0=; b=D74qgR/U5yjYZzjkPStw8ZnU97dPNsOA/bSYSwifjciEyapiNaVd+67bp0ESMmt35wy6wkq2QBreC0d0mOHAh6ZrMZt4lEEcZ3vd0SzgglSCFJGUoQo+w8+DmVGVNJNtna3oj0i3lBXRJdFKNtbjbQGviJ06+7Q+cas7aTET7Es= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101827+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16796909882691016.1128521607426; Fri, 24 Mar 2023 13:49:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id nhumYY1788612xaO1y4hBzS1; Fri, 24 Mar 2023 13:49:47 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.8323.1679690987162892620 for ; Fri, 24 Mar 2023 13:49:47 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 0365620FC45C; Fri, 24 Mar 2023 13:49:45 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0365620FC45C From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao , Michael D Kinney , Sean Brogan , Yuwei Chen Subject: [edk2-devel] [PATCH v6 03/12] BaseTools/VfrCompile: Fix potential buffer overwrites Date: Fri, 24 Mar 2023 16:48:29 -0400 Message-Id: <20230324204838.1485-4-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: m9UBJbLaZlIJJAP4cMshBRkax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679690987; bh=J2SaN/SLZkayh1RnIwWFvjEEodkbqJ66Wpp/iH0gf0g=; h=Cc:Date:From:Reply-To:Subject:To; b=hNr444V6K1A6uBR/9oaVXMRyMygKgMf4Zb1QEeNRLnj1Q/CxWwOBo6cUTroF9wICmJP YOSbf5/7MMWjEJVe3bbHs53IdNMHDIz3epYrjik9F0rvwuk28ZlggN8k6WSEyBlTdtqKR cNws2usvPM4neFu4HnQ7sKuFXFg3G4+9mBE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679690989404100002 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki While more portable methods exist to handle these cases, this change does not attempt to do more than fix the immediate problem and follow the conventions already established in this code. `snprintf()` is introduced as the minimum improvement apart from making the buffers larger. Fixes the following CodeQL alerts: 1. Failure on line 2339 in BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c - Type: Potentially overrunning write - Severity: Critical - Problem: This 'call to sprintf' operation requires 17 bytes but the destination is only 16 bytes. 2. Failure on line 2341 in BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c - Type: Potentially overrunning write - Severity: Critical - Problem: This 'call to sprintf' operation requires 17 bytes but the destination is only 16 bytes. 3. Failure on line 1309 in BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c - Type: Potentially overrunning write - Severity: Critical - Problem: This 'call to sprintf' operation requires 25 bytes but the destination is only 20 bytes. Cc: Bob Feng Cc: Liming Gao Cc: Michael D Kinney Cc: Sean Brogan Cc: Yuwei Chen Signed-off-by: Michael Kubacki Reviewed-by: Liming Gao Reviewed-by: Michael D Kinney --- BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c | 10 +++++----- BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c b/BaseTools/So= urce/C/VfrCompile/Pccts/antlr/gen.c index 8e41239f4751..33d9cac4c7de 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c +++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c @@ -2331,14 +2331,14 @@ TokNode *p; set_nameErrSet =3D bufErrSet; /* MR23 */ } else { /* wild card */ - static char buf[sizeof("zzerr")+10]; - static char bufErrSet[sizeof("zzerr")+10]; + static char buf[sizeof("zzerr")+11]; + static char bufErrSet[sizeof("zzerr")+11]; int n =3D DefErrSet( &b, 0, NULL ); int nErrSet =3D DefErrSetWithSuffix(0, &bErrSet, 1, NULL, "_set"); - if ( GenCC ) sprintf(buf, "err%d", n); - else sprintf(buf, "zzerr%d", n); + if ( GenCC ) snprintf(buf, 11, "err%d", n); + else snprintf(buf, 11, "zzerr%d", n); if ( GenCC ) sprintf(bufErrSet, "err%d", nErrSet); - else sprintf(bufErrSet, "zzerr%d", nErrSet); + else snprintf(bufErrSet, 11, "zzerr%d", nErrSet); set_name =3D buf; set_nameErrSet =3D bufErrSet; } diff --git a/BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c b/BaseTools/S= ource/C/VfrCompile/Pccts/antlr/main.c index 051ee4ec5d28..488b4b90461c 100644 --- a/BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c +++ b/BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c @@ -1295,7 +1295,7 @@ int token; #endif { int j; - static char imag_name[20]; + static char imag_name[25]; =20 /* look in all lexclasses for the token */ if ( TokenString(token) !=3D NULL ) return TokenString(token); @@ -1306,7 +1306,7 @@ int token; } =20 if (1) { - sprintf(imag_name,"UnknownToken#%d",token); /* MR13 */ + snprintf(imag_name, 25, "UnknownToken#%d", token); /* MR13 */ return imag_name; /* MR13 */ } =20 --=20 2.40.0.windows.1 -=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 (#101827): https://edk2.groups.io/g/devel/message/101827 Mute This Topic: https://groups.io/mt/97832895/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101828+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101828+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679690992; cv=none; d=zohomail.com; s=zohoarc; b=ECR1IpGZG0oDxnOahdrm4cnVCkoRrOa5YvrF7gqGWiv6dDABMS4BBc9bXOZX83em6cFJwZwILjRbVRKZCogQvg/YJMkXP4z/OBUwYEWgtDSu/7JblT76nAO6YElEYjkROj8LV1QdxHNbxDMP+Er714oN2Iz5RUT/2dO8UYyKooQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679690992; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=BTXWS4ufhfhZ0f7JyK3aKGr4cXwtD/EdpJnWFuo+KAw=; b=hUh6j5NPbEQBPXG85O3uHtRrqU1ZL+Fq0gtwOToA/mVAxrKddpAFSX69rLg6SumKz0DFJJw27EQHYJWeMD9LuCc0mOEAyAKg3wfScSbmijUeRnF+Ipq1xJIse5OfXd8YFUBmn4nhbf59dCY4ysCS+OfoAT9G9x/tjSBJ7XrPf2U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101828+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679690992526247.69311145166137; Fri, 24 Mar 2023 13:49:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id lFbMYY1788612x1qyVWZ2cCH; Fri, 24 Mar 2023 13:49:52 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.8324.1679690991612583910 for ; Fri, 24 Mar 2023 13:49:51 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 4C8E820FC455; Fri, 24 Mar 2023 13:49:50 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4C8E820FC455 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Erich McMillan , Guomin Jiang , Jian J Wang , Jiewen Yao , Michael Kubacki , Xiaoyu Lu , Jiewen Yao Subject: [edk2-devel] [PATCH v6 04/12] CryptoPkg: Fix conditionally uninitialized variable Date: Fri, 24 Mar 2023 16:48:30 -0400 Message-Id: <20230324204838.1485-5-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: 41qhE0n1Ga0h24dtCwP53lF8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679690992; bh=0T6OJKrahy4Bz0ZApuuy+f3wrdAhjXOqIOOVU7IZnnE=; h=Cc:Date:From:Reply-To:Subject:To; b=rWH18sPjPyB3yQY2DYGdkGrJvDAb8Q+iQXXJYgAMtsaNOYXdqml4Fm+axTExPiySNKU 0LaOgyRjGgm9HDUZafYh2xDueW/uvkxgq1ZdzKY0wA8ucGMclTK4xwCOGLh60fcHjyZkX 4SfAXI2MUuqbeQ2oep6VvXEEUEx1Tx+WE/I= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679690993400100007 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Checks the return value from `ASN1_get_object()` to verify values set by the function are valid. Note that the function returns literal `0x80`: `return (0x80);` That is used to check the return value is as the case in other areas of the code. Cc: Erich McMillan Cc: Guomin Jiang Cc: Jian J Wang Cc: Jiewen Yao Cc: Michael Kubacki Cc: Xiaoyu Lu Co-authored-by: Erich McMillan Signed-off-by: Michael Kubacki Reviewed-by: Jiewen Yao --- CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c b/CryptoPkg/Libr= ary/BaseCryptLib/Pk/CryptX509.c index 2333157e0d17..1182323b63ee 100644 --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c +++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c @@ -807,6 +807,7 @@ X509GetTBSCert ( UINT32 Asn1Tag; UINT32 ObjClass; UINTN Length; + UINTN Inf; =20 // // Check input parameters. @@ -836,9 +837,9 @@ X509GetTBSCert ( // Temp =3D Cert; Length =3D 0; - ASN1_get_object (&Temp, (long *)&Length, (int *)&Asn1Tag, (int *)&ObjCla= ss, (long)CertSize); + Inf =3D ASN1_get_object (&Temp, (long *)&Length, (int *)&Asn1Tag, (in= t *)&ObjClass, (long)CertSize); =20 - if (Asn1Tag !=3D V_ASN1_SEQUENCE) { + if (((Inf & 0x80) =3D=3D 0x00) && (Asn1Tag !=3D V_ASN1_SEQUENCE)) { return FALSE; } =20 @@ -848,7 +849,7 @@ X509GetTBSCert ( // // Verify the parsed TBSCertificate is one correct SEQUENCE data. // - if (Asn1Tag !=3D V_ASN1_SEQUENCE) { + if (((Inf & 0x80) =3D=3D 0x00) && (Asn1Tag !=3D V_ASN1_SEQUENCE)) { return FALSE; } =20 @@ -1888,18 +1889,20 @@ Asn1GetTag ( IN UINT32 Tag ) { - UINT8 *PtrOld; - INT32 ObjTag; - INT32 ObjCls; - long ObjLength; + UINT8 *PtrOld; + INT32 ObjTag; + INT32 ObjCls; + long ObjLength; + UINT32 Inf; =20 // // Save Ptr position // PtrOld =3D *Ptr; =20 - ASN1_get_object ((CONST UINT8 **)Ptr, &ObjLength, &ObjTag, &ObjCls, (INT= 32)(End - (*Ptr))); - if ((ObjTag =3D=3D (INT32)(Tag & CRYPTO_ASN1_TAG_VALUE_MASK)) && + Inf =3D ASN1_get_object ((CONST UINT8 **)Ptr, &ObjLength, &ObjTag, &ObjC= ls, (INT32)(End - (*Ptr))); + if (((Inf & 0x80) =3D=3D 0x00) && + (ObjTag =3D=3D (INT32)(Tag & CRYPTO_ASN1_TAG_VALUE_MASK)) && (ObjCls =3D=3D (INT32)(Tag & CRYPTO_ASN1_TAG_CLASS_MASK))) { *Length =3D (UINTN)ObjLength; --=20 2.40.0.windows.1 -=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 (#101828): https://edk2.groups.io/g/devel/message/101828 Mute This Topic: https://groups.io/mt/97832896/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101829+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101829+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679690996; cv=none; d=zohomail.com; s=zohoarc; b=LMXnSLXsMoir3dtuJdoP2ipBHrFfwNL28hB7fjA+o7ngyqMGBVs4s0EeXiubM2JoClQAzADfTP9yq0pQN4B+E79bwibn5ebRbayn4HAjXwt3c3u+ZEE7gDCEkb7nsfsnG3EysJ4eSxG4UWIuj+hbifJdJ5IV6KhtfUWeqG1lVQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679690996; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=VEr42qZeJCF4yjXQEn5Hv7sKLWFs24Jv4oVMbep820k=; b=FcHiAHhLK7g2mkQwTQ2p/aoqj36KnfbHXv9wmvt9703V4k3tgV8PV4hkQjypXyH6e/nZEldfM+TWco+NZC7skZEgoqw/qM3Z8PoYeEJT7lUo16P34fM+4Cd/7Ihwv0Cr3VKD0piV6FikWbTSLmyxBrTUbnqzdeDRA6v8nDpFfIs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101829+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679690996480485.25945538539884; Fri, 24 Mar 2023 13:49:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0Ty5YY1788612x676ihZzewG; Fri, 24 Mar 2023 13:49:56 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.8291.1679690995381799763 for ; Fri, 24 Mar 2023 13:49:55 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id E561220FC455; Fri, 24 Mar 2023 13:49:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E561220FC455 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Dandan Bi , Eric Dong , Erich McMillan , Guomin Jiang , Jian J Wang , Liming Gao , Michael Kubacki , Ray Ni , Zhichao Gao Subject: [edk2-devel] [PATCH v6 05/12] MdeModulePkg: Fix conditionally uninitialized variables Date: Fri, 24 Mar 2023 16:48:31 -0400 Message-Id: <20230324204838.1485-6-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: m9ElBq1nUHHeq6x5TO7GQ9fYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679690996; bh=qaR8Ez6tCqXkU96jk66cpi4Olt3Cf/0bmFEnyJK1st8=; h=Cc:Date:From:Reply-To:Subject:To; b=uBRtvifABq0GUX5QTxJPPLAaI9IMtpkpSHDltg9do0IRAZrvnOLwMd11p+6DzwnWgK1 OVMMsB70WJBzqoNRz7Qs8r26C12Ctm9Kg0HbrjOelKPciyakwjVlI1us+7JtfmXgrZzgu scBKpab3e387jJc6BbXVadJtahrFwk8eH88= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679690997461100001 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Dandan Bi Cc: Eric Dong Cc: Erich McMillan Cc: Guomin Jiang Cc: Jian J Wang Cc: Liming Gao Cc: Michael Kubacki Cc: Ray Ni Cc: Zhichao Gao Co-authored-by: Erich McMillan Signed-off-by: Michael Kubacki Reviewed-by: Liming Gao --- MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 5 +-- MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c | 24 +++++++= +------ MdeModulePkg/Core/Dxe/Mem/Page.c | 17 +++++--= --- MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c | 25 +++++++= ++------ MdeModulePkg/Library/FileExplorerLib/FileExplorer.c | 5 ++- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 33 +++++++= ++++--------- MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c | 11 ++++--- MdeModulePkg/Universal/HiiDatabaseDxe/Font.c | 14 ++++++-= -- MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 2 +- 9 files changed, 80 insertions(+), 56 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/= PciBusDxe/PciIo.c index 843815d0cb18..14bed5472958 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c @@ -1407,6 +1407,7 @@ SupportPaletteSnoopAttributes ( IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation ) { + EFI_STATUS Status; PCI_IO_DEVICE *Temp; UINT16 VGACommand; =20 @@ -1444,13 +1445,13 @@ SupportPaletteSnoopAttributes ( // Check if they are on the same bus // if (Temp->Parent =3D=3D PciIoDevice->Parent) { - PCI_READ_COMMAND_REGISTER (Temp, &VGACommand); + Status =3D PCI_READ_COMMAND_REGISTER (Temp, &VGACommand); =20 // // If they are on the same bus, either one can // be set to snoop, the other set to decode // - if ((VGACommand & EFI_PCI_COMMAND_VGA_PALETTE_SNOOP) !=3D 0) { + if (!EFI_ERROR (Status) && ((VGACommand & EFI_PCI_COMMAND_VGA_PALETTE_= SNOOP) !=3D 0)) { // // VGA has set to snoop, so GFX can be only set to disable snoop // diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c b/MdeModulePkg/Bus/Pci/Uhc= iDxe/Uhci.c index 48741085e507..496ffbd5c4cc 100644 --- a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c +++ b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c @@ -730,10 +730,12 @@ Uhci2ControlTransfer ( =20 Uhc->PciIo->Flush (Uhc->PciIo); =20 - *TransferResult =3D QhResult.Result; + if (!EFI_ERROR (Status)) { + *TransferResult =3D QhResult.Result; =20 - if (DataLength !=3D NULL) { - *DataLength =3D QhResult.Complete; + if (DataLength !=3D NULL) { + *DataLength =3D QhResult.Complete; + } } =20 UhciDestoryTds (Uhc, TDs); @@ -884,9 +886,11 @@ Uhci2BulkTransfer ( =20 Uhc->PciIo->Flush (Uhc->PciIo); =20 - *TransferResult =3D QhResult.Result; - *DataToggle =3D QhResult.NextToggle; - *DataLength =3D QhResult.Complete; + if (!EFI_ERROR (Status)) { + *TransferResult =3D QhResult.Result; + *DataToggle =3D QhResult.NextToggle; + *DataLength =3D QhResult.Complete; + } =20 UhciDestoryTds (Uhc, TDs); Uhc->PciIo->Unmap (Uhc->PciIo, DataMap); @@ -1210,9 +1214,11 @@ Uhci2SyncInterruptTransfer ( UhciUnlinkTdFromQh (Uhc->SyncIntQh, TDs); Uhc->PciIo->Flush (Uhc->PciIo); =20 - *TransferResult =3D QhResult.Result; - *DataToggle =3D QhResult.NextToggle; - *DataLength =3D QhResult.Complete; + if (!EFI_ERROR (Status)) { + *TransferResult =3D QhResult.Result; + *DataToggle =3D QhResult.NextToggle; + *DataLength =3D QhResult.Complete; + } =20 UhciDestoryTds (Uhc, TDs); Uhc->PciIo->Unmap (Uhc->PciIo, DataMap); diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c index 5903ce7ab525..41af50b3d5ab 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Page.c +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c @@ -449,14 +449,15 @@ PromoteMemoryResource ( // Promoted =3D PromoteGuardedFreePages (&StartAddress, &EndAddress); if (Promoted) { - CoreGetMemorySpaceDescriptor (StartAddress, &Descriptor); - CoreAddRange ( - EfiConventionalMemory, - StartAddress, - EndAddress, - Descriptor.Capabilities & ~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIA= LIZED | - EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME) - ); + if (!EFI_ERROR (CoreGetMemorySpaceDescriptor (StartAddress, &Descrip= tor))) { + CoreAddRange ( + EfiConventionalMemory, + StartAddress, + EndAddress, + Descriptor.Capabilities & ~(EFI_MEMORY_PRESENT | EFI_MEMORY_INIT= IALIZED | + EFI_MEMORY_TESTED | EFI_MEMORY_RUNTI= ME) + ); + } } } =20 diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c = b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c index cdaa2db15365..e22aaf3039f1 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c @@ -909,23 +909,28 @@ BootFromFile ( IN EFI_DEVICE_PATH_PROTOCOL *FilePath ) { + EFI_STATUS Status; EFI_BOOT_MANAGER_LOAD_OPTION BootOption; CHAR16 *FileName; =20 + Status =3D EFI_NOT_STARTED; FileName =3D NULL; =20 FileName =3D ExtractFileNameFromDevicePath (FilePath); if (FileName !=3D NULL) { - EfiBootManagerInitializeLoadOption ( - &BootOption, - 0, - LoadOptionTypeBoot, - LOAD_OPTION_ACTIVE, - FileName, - FilePath, - NULL, - 0 - ); + Status =3D EfiBootManagerInitializeLoadOption ( + &BootOption, + 0, + LoadOptionTypeBoot, + LOAD_OPTION_ACTIVE, + FileName, + FilePath, + NULL, + 0 + ); + } + + if (!EFI_ERROR (Status)) { // // Since current no boot from removable media directly is allowed */ // diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModul= ePkg/Library/FileExplorerLib/FileExplorer.c index ef949267fcc2..804a03d868f2 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -1075,7 +1075,10 @@ LibCreateNewFile ( NewHandle =3D NULL; FullFileName =3D NULL; =20 - LibGetFileHandleFromDevicePath (gFileExplorerPrivate.RetDevicePath, &Fil= eHandle, &ParentName, &DeviceHandle); + if (EFI_ERROR (LibGetFileHandleFromDevicePath (gFileExplorerPrivate.RetD= evicePath, &FileHandle, &ParentName, &DeviceHandle))) { + return EFI_DEVICE_ERROR; + } + FullFileName =3D LibAppendFileName (ParentName, FileName); if (FullFileName =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Univer= sal/BdsDxe/BdsEntry.c index 766dde3aaeeb..72de8d3211b7 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -691,6 +691,7 @@ BdsEntry ( EFI_DEVICE_PATH_PROTOCOL *FilePath; EFI_STATUS BootManagerMenuStatus; EFI_BOOT_MANAGER_LOAD_OPTION PlatformDefaultBootOption; + BOOLEAN PlatformDefaultBootOptionValid; =20 HotkeyTriggered =3D NULL; Status =3D EFI_SUCCESS; @@ -809,24 +810,24 @@ BdsEntry ( CpuDeadLoop (); } =20 - Status =3D EfiBootManagerInitializeLoadOption ( - &PlatformDefaultBootOption, - LoadOptionNumberUnassigned, - LoadOptionTypePlatformRecovery, - LOAD_OPTION_ACTIVE, - L"Default PlatformRecovery", - FilePath, - NULL, - 0 - ); - ASSERT_EFI_ERROR (Status); + PlatformDefaultBootOptionValid =3D EfiBootManagerInitializeLoadOption ( + &PlatformDefaultBootOption, + LoadOptionNumberUnassigned, + LoadOptionTypePlatformRecovery, + LOAD_OPTION_ACTIVE, + L"Default PlatformRecovery", + FilePath, + NULL, + 0 + ) =3D=3D EFI_SUCCESS; + ASSERT (PlatformDefaultBootOptionValid =3D=3D TRUE); =20 // // System firmware must include a PlatformRecovery#### variable specifyi= ng // a short-form File Path Media Device Path containing the platform defa= ult // file path for removable media if the platform supports Platform Recov= ery. // - if (PcdGetBool (PcdPlatformRecoverySupport)) { + if (PlatformDefaultBootOptionValid && PcdGetBool (PcdPlatformRecoverySup= port)) { LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, LoadOp= tionTypePlatformRecovery); if (EfiBootManagerFindLoadOption (&PlatformDefaultBootOption, LoadOpti= ons, LoadOptionCount) =3D=3D -1) { for (Index =3D 0; Index < LoadOptionCount; Index++) { @@ -1104,15 +1105,17 @@ BdsEntry ( LoadOptions =3D EfiBootManagerGetLoadOptions (&LoadOptionCount, Load= OptionTypePlatformRecovery); ProcessLoadOptions (LoadOptions, LoadOptionCount); EfiBootManagerFreeLoadOptions (LoadOptions, LoadOptionCount); - } else { + } else if (PlatformDefaultBootOptionValid) { // // When platform recovery is not enabled, still boot to platform def= ault file path. // - EfiBootManagerProcessLoadOption (&PlatformDefaultBootOption); + PlatformDefaultBootOptionValid =3D EfiBootManagerProcessLoadOption (= &PlatformDefaultBootOption) =3D=3D EFI_SUCCESS; } } =20 - EfiBootManagerFreeLoadOption (&PlatformDefaultBootOption); + if (PlatformDefaultBootOptionValid) { + EfiBootManagerFreeLoadOption (&PlatformDefaultBootOption); + } =20 DEBUG ((DEBUG_ERROR, "[Bds] Unable to boot!\n")); PlatformBootManagerUnableToBoot (); diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c b/Mde= ModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c index dca3c1df07ba..0d4cfa4cf06f 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c @@ -944,13 +944,14 @@ PrintMismatchMenuInfo ( UINTN FormsetBufferSize; =20 Question =3D MenuOption->ThisTag; - HiiGetFormSetFromHiiHandle (gFormData->HiiHandle, &FormsetBuffer, &Forms= etBufferSize); =20 - FormSetTitleStr =3D GetToken (FormsetBuffer->FormSetTitle, gFormData->Hi= iHandle); - FormTitleStr =3D GetToken (gFormData->FormTitle, gFormData->HiiHandle= ); + if (!EFI_ERROR (HiiGetFormSetFromHiiHandle (gFormData->HiiHandle, &Forms= etBuffer, &FormsetBufferSize))) { + FormSetTitleStr =3D GetToken (FormsetBuffer->FormSetTitle, gFormData->= HiiHandle); + FormTitleStr =3D GetToken (gFormData->FormTitle, gFormData->HiiHand= le); =20 - DEBUG ((DEBUG_ERROR, "\n[%a]: Mismatch Formset : Formset Guid =3D %g,= FormSet title =3D %s\n", gEfiCallerBaseName, &gFormData->FormSetGuid, For= mSetTitleStr)); - DEBUG ((DEBUG_ERROR, "[%a]: Mismatch Form : FormId =3D %d, Form t= itle =3D %s.\n", gEfiCallerBaseName, gFormData->FormId, FormTitleStr)); + DEBUG ((DEBUG_ERROR, "\n[%a]: Mismatch Formset : Formset Guid =3D %= g, FormSet title =3D %s\n", gEfiCallerBaseName, &gFormData->FormSetGuid, F= ormSetTitleStr)); + DEBUG ((DEBUG_ERROR, "[%a]: Mismatch Form : FormId =3D %d, Form= title =3D %s.\n", gEfiCallerBaseName, gFormData->FormId, FormTitleStr)); + } =20 if (Question->OpCode->OpCode =3D=3D EFI_IFR_ORDERED_LIST_OP) { QuestionName =3D GetToken (((EFI_IFR_ORDERED_LIST *)MenuOption->ThisTa= g->OpCode)->Question.Header.Prompt, gFormData->HiiHandle); diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Un= iversal/HiiDatabaseDxe/Font.c index 399f90feb783..8a0b12f72fbe 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c @@ -1745,6 +1745,7 @@ HiiStringToImage ( Attributes =3D (UINT8 *)AllocateZeroPool (StrLength * sizeof (UINT8)); ASSERT (Attributes !=3D NULL); =20 + FontInfo =3D NULL; RowInfo =3D NULL; Status =3D EFI_SUCCESS; StringIn2 =3D NULL; @@ -1787,11 +1788,14 @@ HiiStringToImage ( Background =3D ((EFI_FONT_DISPLAY_INFO *)StringInfo)->BackgroundCol= or; } else if (Status =3D=3D EFI_SUCCESS) { FontInfo =3D &StringInfoOut->FontInfo; - IsFontInfoExisted (Private, FontInfo, NULL, NULL, &GlobalFont); - Height =3D GlobalFont->FontPackage->Height; - BaseLine =3D GlobalFont->FontPackage->BaseLine; - Foreground =3D StringInfoOut->ForegroundColor; - Background =3D StringInfoOut->BackgroundColor; + if (IsFontInfoExisted (Private, FontInfo, NULL, NULL, &GlobalFont)) { + Height =3D GlobalFont->FontPackage->Height; + BaseLine =3D GlobalFont->FontPackage->BaseLine; + Foreground =3D StringInfoOut->ForegroundColor; + Background =3D StringInfoOut->BackgroundColor; + } else { + goto Exit; + } } else { goto Exit; } diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeMod= ulePkg/Universal/Variable/RuntimeDxe/Variable.c index 14c176887a55..3eb7d935b4d2 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -2453,7 +2453,7 @@ VariableServiceGetVariable ( AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.Variab= leServicesLock); =20 Status =3D FindVariable (VariableName, VendorGuid, &Variable, &mVariable= ModuleGlobal->VariableGlobal, FALSE); - if ((Variable.CurrPtr =3D=3D NULL) || EFI_ERROR (Status)) { + if (EFI_ERROR (Status) || (Variable.CurrPtr =3D=3D NULL)) { goto Done; } =20 --=20 2.40.0.windows.1 -=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 (#101829): https://edk2.groups.io/g/devel/message/101829 Mute This Topic: https://groups.io/mt/97832897/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101830+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101830+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679690999; cv=none; d=zohomail.com; s=zohoarc; b=l+/HQ7/HrvCkqZuZ5ua9xq1WWqnEHoM0cwL9wyK0hegEELLckuG+lhFmTV4ynHBWNLtqjR4eK4yINx+uwb/sUS/cJC9K3Z99u3c9wWW4Ylcss61lt6OXk9MuYfrockCeg3Ih0agFoLByYG3G3rOw9pSFhxpkJL4m6D3pJTtw+9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679690999; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=TCu7dck6FxPh6U8LuHLPT0m0h5g3/nHmFXtQSb58b78=; b=ZraRMAT0smqrLv3o+MGLcrRoAEzrWxWsSVqtDI3U8ymgn5NvJ5e4Bj9rnja0hknjfHUyAr30Auc3eVgSPOyrVJ+58S37pRVtCWXVnpj2UeSWzsS19zblyt7BX/qv6//3MxdBG7e9BR9uk4WsFhkgFJZFSWTh8ByM8cTtrdsjSlA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101830+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679690999613541.4837373208806; Fri, 24 Mar 2023 13:49:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id NdLmYY1788612xTBDIt7KYFp; Fri, 24 Mar 2023 13:49:59 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.8297.1679690998674627490 for ; Fri, 24 Mar 2023 13:49:58 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 802EF20FC45C; Fri, 24 Mar 2023 13:49:57 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 802EF20FC45C From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Erich McMillan , Liming Gao , Michael D Kinney , Michael Kubacki , Zhiguang Liu Subject: [edk2-devel] [PATCH v6 06/12] MdePkg: Fix conditionally uninitialized variables Date: Fri, 24 Mar 2023 16:48:32 -0400 Message-Id: <20230324204838.1485-7-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: CNsHhrwyAdsQ05eHmy1uBLXTx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679690999; bh=DjA5DoEFbZID44KD6VTrwmSDVaA4MPUvi0vnSq26Wbk=; h=Cc:Date:From:Reply-To:Subject:To; b=YBa7N0F6f1P2HsI44VoLZs/q9Ak9C4RW3iOiBlFU3rCRqkzsJ1SM1I/Ihw/cWFVlO78 MczBTWxLLiVgZzzCrFwUPx27J3JldJVdvLX7Rq23M+4Lm1BDfok55I75TTUaL9nRkSM7C VfrOTcmFbkt0VxKD29TDO4FGas4ExSxGrrE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679691001467100002 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Note that this change affects the actual return value from the following functions. The functions documented that if an integer overflow occurred, MAX_UINTN would be returned. They were implemented to actually return an undefined value from the stack. This change makes the function follow its description. However, this is technically different than what callers may have previously expected. MdePkg/Library/BaseLib/String.c: - StrDecimalToUintn() - StrDecimalToUint64() - StrHexToUintn() - StrHexToUint64() - AsciiStrDecimalToUintn() - AsciiStrDecimalToUint64() - AsciiStrHexToUintn() - AsciiStrHexToUint64() Cc: Erich McMillan Cc: Liming Gao Cc: Michael D Kinney Cc: Michael Kubacki Cc: Zhiguang Liu Co-authored-by: Erich McMillan Signed-off-by: Michael Kubacki Reviewed-by: Liming Gao --- MdePkg/Library/BaseLib/String.c | 40 ++++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/Strin= g.c index 98e6d31463e0..637c96e7b31b 100644 --- a/MdePkg/Library/BaseLib/String.c +++ b/MdePkg/Library/BaseLib/String.c @@ -408,7 +408,10 @@ StrDecimalToUintn ( { UINTN Result; =20 - StrDecimalToUintnS (String, (CHAR16 **)NULL, &Result); + if (RETURN_ERROR (StrDecimalToUintnS (String, (CHAR16 **)NULL, &Result))= ) { + return MAX_UINTN; + } + return Result; } =20 @@ -454,7 +457,10 @@ StrDecimalToUint64 ( { UINT64 Result; =20 - StrDecimalToUint64S (String, (CHAR16 **)NULL, &Result); + if (RETURN_ERROR (StrDecimalToUint64S (String, (CHAR16 **)NULL, &Result)= )) { + return MAX_UINT64; + } + return Result; } =20 @@ -501,7 +507,10 @@ StrHexToUintn ( { UINTN Result; =20 - StrHexToUintnS (String, (CHAR16 **)NULL, &Result); + if (RETURN_ERROR (StrHexToUintnS (String, (CHAR16 **)NULL, &Result))) { + return MAX_UINTN; + } + return Result; } =20 @@ -548,7 +557,10 @@ StrHexToUint64 ( { UINT64 Result; =20 - StrHexToUint64S (String, (CHAR16 **)NULL, &Result); + if (RETURN_ERROR (StrHexToUint64S (String, (CHAR16 **)NULL, &Result))) { + return MAX_UINT64; + } + return Result; } =20 @@ -989,7 +1001,10 @@ AsciiStrDecimalToUintn ( { UINTN Result; =20 - AsciiStrDecimalToUintnS (String, (CHAR8 **)NULL, &Result); + if (RETURN_ERROR (AsciiStrDecimalToUintnS (String, (CHAR8 **)NULL, &Resu= lt))) { + return MAX_UINTN; + } + return Result; } =20 @@ -1031,7 +1046,10 @@ AsciiStrDecimalToUint64 ( { UINT64 Result; =20 - AsciiStrDecimalToUint64S (String, (CHAR8 **)NULL, &Result); + if (RETURN_ERROR (AsciiStrDecimalToUint64S (String, (CHAR8 **)NULL, &Res= ult))) { + return MAX_UINT64; + } + return Result; } =20 @@ -1077,7 +1095,10 @@ AsciiStrHexToUintn ( { UINTN Result; =20 - AsciiStrHexToUintnS (String, (CHAR8 **)NULL, &Result); + if (RETURN_ERROR (AsciiStrHexToUintnS (String, (CHAR8 **)NULL, &Result))= ) { + return MAX_UINTN; + } + return Result; } =20 @@ -1123,7 +1144,10 @@ AsciiStrHexToUint64 ( { UINT64 Result; =20 - AsciiStrHexToUint64S (String, (CHAR8 **)NULL, &Result); + if (RETURN_ERROR (AsciiStrHexToUint64S (String, (CHAR8 **)NULL, &Result)= )) { + return MAX_UINT64; + } + return Result; } =20 --=20 2.40.0.windows.1 -=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 (#101830): https://edk2.groups.io/g/devel/message/101830 Mute This Topic: https://groups.io/mt/97832901/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101831+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101831+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679691002; cv=none; d=zohomail.com; s=zohoarc; b=lgqKmt0z23xCVpfXmysXYNcVE9fGQrvNqPJQaSlHKy6U09VFh3dlfH+CTB4txEfuNkpDTp79ahrM9N7pQ/GwWJ/yDyhvoTTHLXEbQ1wamF2BjCD3V2ed/24h3+GVLxyDIFl2ip1BI/68tL4qWJ/Yu8TauOTDiDWJnbelX5KJDDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679691002; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=aQFqpC6cJAD/CcEROP6Gn2UqEyUT3oe4ZMHYz0ofPUQ=; b=G+pAaUp+8HRyTQkYZZYgge3LeBH128HDFYV/i8gEkHkd1HjWaDxO6gPlQMtg+0rMRlen/ToKoa3y9xZivJ/cxVSRbT4S1OTgsadn4lh8IsmZaHT1zOM4GlWQ0Qufnu6e3ZsH5UjgalimYUjqmcjIE6pPEI4FgS3VJjfQg68UEYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101831+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679691002951516.1507969708564; Fri, 24 Mar 2023 13:50:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id E6TkYY1788612xqgqtkmGep3; Fri, 24 Mar 2023 13:50:02 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.8303.1679691002050929197 for ; Fri, 24 Mar 2023 13:50:02 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id B696820FC455; Fri, 24 Mar 2023 13:50:00 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com B696820FC455 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Erich McMillan , Jiaxin Wu , Maciej Rabeda , Michael D Kinney , Michael Kubacki , Siyuan Fu Subject: [edk2-devel] [PATCH v6 07/12] NetworkPkg: Fix conditionally uninitialized variables Date: Fri, 24 Mar 2023 16:48:33 -0400 Message-Id: <20230324204838.1485-8-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: nLUD77EgBO6UQjXXuGm4lmITx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679691002; bh=L0giLBk5rIUhzRT8Ht2sS4YaLKLEXqlD1Vr/fSfpTGk=; h=Cc:Date:From:Reply-To:Subject:To; b=d41J42pEV1fC8ZoaZrYktdQOmKdR7tRbFXmtEy/0RYcaXugol8+p8HbsSxlQlqV8hst rw/H6MxN1+p1eLixUMh2LsmTSdXXwfObaZlmU6pA+d827xpxoHMZ9rCAOxzbdobWsHuwl BkiIMDTXSiiE8IG0tYv3MV4l4EX8y7B3TZM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679691005449100003 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Erich McMillan Cc: Jiaxin Wu Cc: Maciej Rabeda Cc: Michael D Kinney Cc: Michael Kubacki Cc: Siyuan Fu Co-authored-by: Erich McMillan Signed-off-by: Michael Kubacki Reviewed-by: Michael D Kinney --- NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c | 2 +- NetworkPkg/TcpDxe/TcpInput.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c b/NetworkPkg/Librar= y/DxeHttpLib/DxeHttpLib.c index 6a5d78629bb3..21813463aa4f 100644 --- a/NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c +++ b/NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c @@ -753,7 +753,7 @@ HttpUrlGetPort ( =20 Status =3D AsciiStrDecimalToUintnS (Url + Parser->FieldData[HTTP_URI_FI= ELD_PORT].Offset, (CHAR8 **)NULL, &Data); =20 - if (Data > HTTP_URI_PORT_MAX_NUM) { + if (EFI_ERROR (Status) || (Data > HTTP_URI_PORT_MAX_NUM)) { Status =3D EFI_INVALID_PARAMETER; goto ON_EXIT; } diff --git a/NetworkPkg/TcpDxe/TcpInput.c b/NetworkPkg/TcpDxe/TcpInput.c index fb1aa827f8ba..7b329be64dfe 100644 --- a/NetworkPkg/TcpDxe/TcpInput.c +++ b/NetworkPkg/TcpDxe/TcpInput.c @@ -1570,6 +1570,9 @@ TcpIcmpInput ( BOOLEAN IcmpErrIsHard; BOOLEAN IcmpErrNotify; =20 + IcmpErrIsHard =3D FALSE; + IcmpErrNotify =3D FALSE; + if (Nbuf->TotalSize < sizeof (TCP_HEAD)) { goto CLEAN_EXIT; } --=20 2.40.0.windows.1 -=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 (#101831): https://edk2.groups.io/g/devel/message/101831 Mute This Topic: https://groups.io/mt/97832907/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101832+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101832+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679691006; cv=none; d=zohomail.com; s=zohoarc; b=Gl2okt2B04n9oVcd+Sodteqy6MPQqDoLGd/HQJ8hgmtKERwhsrmrxlgaKienF2suns5ZCyVlu6TrGSqMaZHCWhEAqUOYYmgYGvMtva0OsHk1BLTExOYiVDrvI7OWhFtlFGuNJ4KAc3WvmfbXZ8AX8ljlnTcx6us7P16Wvmmft/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679691006; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=VmO6YxM/W+EofGOq8gnWi5BWv1I42cjq2Zy9FOTToRA=; b=lA+9c8PNgdeRS92FKfZhTpW06h/ThF/xXsJNRfFNctyrLnEg+yd9hvMqC4A/dt7gv2taii204H+dh2pyqWRlR0CZ/lrWyOCoVRTsCiKaPbh54yEZrV7iU2hLFcpttXiIqwbr/hnI+I4sG10JMqUh7d+ZnFfgtC1ttQMvz0vM+jw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101832+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679691005951737.5386762116592; Fri, 24 Mar 2023 13:50:05 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id mVY7YY1788612xDAnwfiIndv; Fri, 24 Mar 2023 13:50:05 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.8336.1679691004817464126 for ; Fri, 24 Mar 2023 13:50:04 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id D54C520FC459; Fri, 24 Mar 2023 13:50:03 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D54C520FC459 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Erich McMillan , Michael D Kinney , Michael Kubacki , Ray Ni Subject: [edk2-devel] [PATCH v6 08/12] PcAtChipsetPkg: Fix conditionally uninitialized variables Date: Fri, 24 Mar 2023 16:48:34 -0400 Message-Id: <20230324204838.1485-9-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: 7ODDe5AcjPmrPBJ48EkIzv4Px1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679691005; bh=7uiJqV4fzzdkQLgStXRhC/jCZjatd2LdthM6ea7ZGSs=; h=Cc:Date:From:Reply-To:Subject:To; b=JFiJRUk5lNZcl3Vnk3wMR29RR/88nrIddRYwkSSt2rqDyxf8DkxQBB+BpRfROTFHyQ+ Ok3C8jgypCy8TPSrQWADKpbgDHjRSm6V3PbMwdglO/2NyTgo/0hCoR28RZRxGN2jCGz/P Xj5PMgb+tepWWTZ7lS4l/NMMYGSoV1lZc/M= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679691007475100006 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Erich McMillan Cc: Michael D Kinney Cc: Michael Kubacki Cc: Ray Ni Co-authored-by: Erich McMillan Signed-off-by: Michael Kubacki Reviewed-by: Michael D Kinney Reviewed-by: Ray Ni --- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChips= etPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index 9242a2e82600..57ea3153aa6b 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -344,7 +344,7 @@ PcRtcInit ( // so we can use them to get and set wakeup time. // Status =3D PcRtcGetWakeupTime (&Enabled, &Pending, &Time, Global); - if ((Enabled) || (!EFI_ERROR (Status))) { + if ((!EFI_ERROR (Status)) || (Enabled)) { return EFI_SUCCESS; } =20 @@ -836,8 +836,11 @@ PcRtcSetWakeupTime ( // // Just support set alarm time within 24 hours // - PcRtcGetTime (&RtcTime, &Capabilities, Global); - Status =3D RtcTimeFieldsValid (&RtcTime); + Status =3D PcRtcGetTime (&RtcTime, &Capabilities, Global); + if (!EFI_ERROR (Status)) { + Status =3D RtcTimeFieldsValid (&RtcTime); + } + if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } --=20 2.40.0.windows.1 -=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 (#101832): https://edk2.groups.io/g/devel/message/101832 Mute This Topic: https://groups.io/mt/97832908/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101833+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101833+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679691014; cv=none; d=zohomail.com; s=zohoarc; b=jAuoxIlLJTAjU9mzeV3XpdqLkCvYprVicCxLnoo+cYReXysC3lFDOFhjhcLDZfCPjryFg3ntbmiXbbYGJfVvqd+0MNReeP18V5cWh4OYXlXhb/QgrRbhNl8F7zfINbd/NGNswXYJJpn/XGCvWe0yCY7FwfO3wkI9JgKxOtVZCXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679691014; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=YUchA0LGRIYDb1v/w5FxqW+35WfPBDRL20gTCgQB97s=; b=j/FZT4mJ4wa4bV8oc2iHkqy9VEynU4t8SquIKL6GEzYDqqhhNTQFI4FnOHmHc43BQAUKpaEmN4Bt6Oghohi939qwIjnYNR+g9P0t54ZgTgsV5gNn69Tz6FKB5hntYZpTO2Y8HjM+t5f/VktCh5OLKd6x2zpOIKaj4xh8z1VtmT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101833+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679691014026675.3806281965196; Fri, 24 Mar 2023 13:50:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qdT5YY1788612xSAZLAUt0HV; Fri, 24 Mar 2023 13:50:13 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.8305.1679691008145226830 for ; Fri, 24 Mar 2023 13:50:08 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 11BD820FC459; Fri, 24 Mar 2023 13:50:06 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 11BD820FC459 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Erich McMillan , Michael D Kinney , Michael Kubacki , Ray Ni , Zhichao Gao Subject: [edk2-devel] [PATCH v6 09/12] ShellPkg: Fix conditionally uninitialized variables Date: Fri, 24 Mar 2023 16:48:35 -0400 Message-Id: <20230324204838.1485-10-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: rX99aqjpnOSzrYrPTjff4pprx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679691013; bh=5TRSxQhGXjfU8u0mDoxuTSf41g0HxXBqF9p4bk9YG+E=; h=Cc:Date:From:Reply-To:Subject:To; b=fPGtca//n7kiTx1w/4ALNIqAtQd1fHmcMy9U/AM9l/dDgMMRop9eWo9gJZLaeV8w32Z 4VAOE4V6ctw0dnWS048joPsj1BCAYdfpcbMZC144wawSB99GODqEAY1Mlhsibfg4umI2m w/ErmrnvU8TFqG04R3vbHZwbC3UhgRJXekQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679691015721100005 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Erich McMillan Cc: Michael D Kinney Cc: Michael Kubacki Cc: Ray Ni Cc: Zhichao Gao Co-authored-by: Erich McMillan Signed-off-by: Michael Kubacki Reviewed-by: Zhichao Gao --- ShellPkg/Application/Shell/Shell.c | 1 + ShellPkg/Application/Shell/ShellProtocol.c | 60 +++++++++= +---------- ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 56 +++++++++= --------- ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c | 18 +++--- ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c | 9 ++- ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c | 14 +++-- ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c | 17 ++++-- ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c | 21 +++---- 8 files changed, 107 insertions(+), 89 deletions(-) diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shel= l/Shell.c index 0ae6e14a34bf..f95c799bb2a4 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -1300,6 +1300,7 @@ DoStartupScript ( CHAR16 *FullFileStringPath; UINTN NewSize; =20 + CalleeStatus =3D EFI_SUCCESS; Key.UnicodeChar =3D CHAR_NULL; Key.ScanCode =3D 0; =20 diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Applicat= ion/Shell/ShellProtocol.c index e6d20ab16479..da8c31cb038a 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -735,50 +735,52 @@ EfiShellGetDeviceName ( // // Now check the parent controller using this as the child. // - if (DeviceNameToReturn =3D=3D NULL) { - PARSE_HANDLE_DATABASE_PARENTS (DeviceHandle, &ParentControllerCount,= &ParentControllerBuffer); + Status =3D PARSE_HANDLE_DATABASE_PARENTS (DeviceHandle, &ParentControl= lerCount, &ParentControllerBuffer); + if ((DeviceNameToReturn =3D=3D NULL) && !EFI_ERROR (Status)) { for (LoopVar =3D 0; LoopVar < ParentControllerCount; LoopVar++) { - PARSE_HANDLE_DATABASE_UEFI_DRIVERS (ParentControllerBuffer[LoopVar= ], &ParentDriverCount, &ParentDriverBuffer); - for (HandleCount =3D 0; HandleCount < ParentDriverCount; HandleCou= nt++) { - // - // try using that driver's component name with controller and ou= r driver as the child. - // - Status =3D gBS->OpenProtocol ( - ParentDriverBuffer[HandleCount], - &gEfiComponentName2ProtocolGuid, - (VOID **)&CompName2, - gImageHandle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { + Status =3D PARSE_HANDLE_DATABASE_UEFI_DRIVERS (ParentControllerBuf= fer[LoopVar], &ParentDriverCount, &ParentDriverBuffer); + if (!EFI_ERROR (Status)) { + for (HandleCount =3D 0; HandleCount < ParentDriverCount; HandleC= ount++) { + // + // try using that driver's component name with controller and = our driver as the child. + // Status =3D gBS->OpenProtocol ( ParentDriverBuffer[HandleCount], - &gEfiComponentNameProtocolGuid, + &gEfiComponentName2ProtocolGuid, (VOID **)&CompName2, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); - } + if (EFI_ERROR (Status)) { + Status =3D gBS->OpenProtocol ( + ParentDriverBuffer[HandleCount], + &gEfiComponentNameProtocolGuid, + (VOID **)&CompName2, + gImageHandle, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + } + + if (EFI_ERROR (Status)) { + continue; + } =20 - if (EFI_ERROR (Status)) { - continue; + Lang =3D GetBestLanguageForDriver (CompName2->SupportedLangu= ages, Language, FALSE); + Status =3D CompName2->GetControllerName (CompName2, ParentCont= rollerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn); + FreePool (Lang); + Lang =3D NULL; + if (!EFI_ERROR (Status) && (DeviceNameToReturn !=3D NULL)) { + break; + } } =20 - Lang =3D GetBestLanguageForDriver (CompName2->SupportedLanguag= es, Language, FALSE); - Status =3D CompName2->GetControllerName (CompName2, ParentContro= llerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn); - FreePool (Lang); - Lang =3D NULL; + SHELL_FREE_NON_NULL (ParentDriverBuffer); if (!EFI_ERROR (Status) && (DeviceNameToReturn !=3D NULL)) { break; } } - - SHELL_FREE_NON_NULL (ParentDriverBuffer); - if (!EFI_ERROR (Status) && (DeviceNameToReturn !=3D NULL)) { - break; - } } =20 SHELL_FREE_NON_NULL (ParentControllerBuffer); diff --git a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c b/S= hellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c index 36cf46fb2c38..4549cbde9b9a 100644 --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c @@ -1399,10 +1399,11 @@ ShellCommandCreateInitialMappingsAndPaths ( CHAR16 *MapName; SHELL_MAP_LIST *MapListItem; =20 - SplitCurDir =3D NULL; - MapName =3D NULL; - MapListItem =3D NULL; - HandleList =3D NULL; + ConsistMappingTable =3D NULL; + SplitCurDir =3D NULL; + MapName =3D NULL; + MapListItem =3D NULL; + HandleList =3D NULL; =20 // // Reset the static members back to zero @@ -1458,32 +1459,35 @@ ShellCommandCreateInitialMappingsAndPaths ( // PerformQuickSort (DevicePathList, Count, sizeof (EFI_DEVICE_PATH_PROTO= COL *), DevicePathCompare); =20 - ShellCommandConsistMappingInitialize (&ConsistMappingTable); - // - // Assign new Mappings to all... - // - for (Count =3D 0; HandleList[Count] !=3D NULL; Count++) { + if (!EFI_ERROR (ShellCommandConsistMappingInitialize (&ConsistMappingT= able))) { // - // Get default name first + // Assign new Mappings to all... // - NewDefaultName =3D ShellCommandCreateNewMappingName (MappingTypeFile= System); - ASSERT (NewDefaultName !=3D NULL); - Status =3D ShellCommandAddMapItemAndUpdatePath (NewDefaultName, Devi= cePathList[Count], 0, TRUE); - ASSERT_EFI_ERROR (Status); - FreePool (NewDefaultName); - - // - // Now do consistent name - // - NewConsistName =3D ShellCommandConsistMappingGenMappingName (DeviceP= athList[Count], ConsistMappingTable); - if (NewConsistName !=3D NULL) { - Status =3D ShellCommandAddMapItemAndUpdatePath (NewConsistName, De= vicePathList[Count], 0, FALSE); + for (Count =3D 0; HandleList[Count] !=3D NULL; Count++) { + // + // Get default name first + // + NewDefaultName =3D ShellCommandCreateNewMappingName (MappingTypeFi= leSystem); + ASSERT (NewDefaultName !=3D NULL); + Status =3D ShellCommandAddMapItemAndUpdatePath (NewDefaultName, De= vicePathList[Count], 0, TRUE); ASSERT_EFI_ERROR (Status); - FreePool (NewConsistName); + FreePool (NewDefaultName); + + // + // Now do consistent name + // + NewConsistName =3D ShellCommandConsistMappingGenMappingName (Devic= ePathList[Count], ConsistMappingTable); + if (NewConsistName !=3D NULL) { + Status =3D ShellCommandAddMapItemAndUpdatePath (NewConsistName, = DevicePathList[Count], 0, FALSE); + ASSERT_EFI_ERROR (Status); + FreePool (NewConsistName); + } } } =20 - ShellCommandConsistMappingUnInitialize (ConsistMappingTable); + if (ConsistMappingTable !=3D NULL) { + ShellCommandConsistMappingUnInitialize (ConsistMappingTable); + } =20 SHELL_FREE_NON_NULL (HandleList); SHELL_FREE_NON_NULL (DevicePathList); @@ -1626,12 +1630,12 @@ ShellCommandUpdateMapping ( // PerformQuickSort (DevicePathList, Count, sizeof (EFI_DEVICE_PATH_PROTO= COL *), DevicePathCompare); =20 - ShellCommandConsistMappingInitialize (&ConsistMappingTable); + Status =3D ShellCommandConsistMappingInitialize (&ConsistMappingTable); =20 // // Assign new Mappings to remainders // - for (Count =3D 0; !EFI_ERROR (Status) && HandleList[Count] !=3D NULL &= & !EFI_ERROR (Status); Count++) { + for (Count =3D 0; !EFI_ERROR (Status) && HandleList[Count] !=3D NULL; = Count++) { // // Skip ones that already have // diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c b/ShellPkg/= Library/UefiShellDebug1CommandsLib/Dblk.c index 97a4b57a932f..5329b559ba46 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c @@ -158,7 +158,10 @@ ShellCommandRunDblk ( ShellStatus =3D SHELL_INVALID_PARAMETER; } =20 - ShellConvertStringToUint64 (LbaString, &Lba, TRUE, FALSE); + if (EFI_ERROR (ShellConvertStringToUint64 (LbaString, &Lba, TRUE, = FALSE))) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),= gShellDebug1HiiHandle, L"dblk", LbaString); + ShellStatus =3D SHELL_INVALID_PARAMETER; + } } =20 if (BlockCountString =3D=3D NULL) { @@ -169,12 +172,13 @@ ShellCommandRunDblk ( ShellStatus =3D SHELL_INVALID_PARAMETER; } =20 - ShellConvertStringToUint64 (BlockCountString, &BlockCount, TRUE, F= ALSE); - if (BlockCount > 0x10) { - BlockCount =3D 0x10; - } else if (BlockCount =3D=3D 0) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV),= gShellDebug1HiiHandle, L"dblk", BlockCountString); - ShellStatus =3D SHELL_INVALID_PARAMETER; + if (!EFI_ERROR (ShellConvertStringToUint64 (BlockCountString, &Blo= ckCount, TRUE, FALSE))) { + if (BlockCount > 0x10) { + BlockCount =3D 0x10; + } else if (BlockCount =3D=3D 0) { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV= ), gShellDebug1HiiHandle, L"dblk", BlockCountString); + ShellStatus =3D SHELL_INVALID_PARAMETER; + } } } =20 diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c b/= ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c index 8bf23a2076a1..72f8c087cb69 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c @@ -112,10 +112,13 @@ ShellCommandRunEfiDecompress ( =20 if (ShellStatus =3D=3D SHELL_SUCCESS) { Status =3D FileHandleGetSize (InFileHandle, &Temp64Bit); - ASSERT (Temp64Bit <=3D (UINT32)(-1)); - InSize =3D (UINTN)Temp64Bit; ASSERT_EFI_ERROR (Status); - InBuffer =3D AllocateZeroPool (InSize); + if (!EFI_ERROR (Status)) { + ASSERT (Temp64Bit <=3D (UINT32)(-1)); + InSize =3D (UINTN)Temp64Bit; + InBuffer =3D AllocateZeroPool (InSize); + } + if (InBuffer =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; } else { diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c b/Shell= Pkg/Library/UefiShellDriver1CommandsLib/Connect.c index d7a133c0c5b4..870c5b0d1da7 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c @@ -508,9 +508,10 @@ ShellCommandRunConnect ( Count =3D ShellCommandLineGetCount (Package); =20 if (Param1 !=3D NULL) { - Status =3D ShellConvertStringToUint64 (Param1, &Intermediate, TRU= E, FALSE); - Handle1 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); - if (EFI_ERROR (Status)) { + Status =3D ShellConvertStringToUint64 (Param1, &Intermediate, TRUE= , FALSE); + if (!EFI_ERROR (Status)) { + Handle1 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); + } else { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE)= , gShellDriver1HiiHandle, L"connect", Param1); ShellStatus =3D SHELL_INVALID_PARAMETER; } @@ -519,9 +520,10 @@ ShellCommandRunConnect ( } =20 if (Param2 !=3D NULL) { - Status =3D ShellConvertStringToUint64 (Param2, &Intermediate, TRU= E, FALSE); - Handle2 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); - if (EFI_ERROR (Status)) { + Status =3D ShellConvertStringToUint64 (Param2, &Intermediate, TRUE= , FALSE); + if (!EFI_ERROR (Status)) { + Handle2 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); + } else { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE)= , gShellDriver1HiiHandle, L"connect", Param2); ShellStatus =3D SHELL_INVALID_PARAMETER; } diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c b/Sh= ellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c index 009ae5282b27..fd49d1f7ceb4 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c @@ -160,12 +160,17 @@ ShellCommandRunDisconnect ( Param1 =3D ShellCommandLineGetRawValue (Package, 1); Param2 =3D ShellCommandLineGetRawValue (Package, 2); Param3 =3D ShellCommandLineGetRawValue (Package, 3); - ShellConvertStringToUint64 (Param1, &Intermediate1, TRUE, FALSE); - Handle1 =3D Param1 !=3D NULL ? ConvertHandleIndexToHandle ((UINTN)= Intermediate1) : NULL; - ShellConvertStringToUint64 (Param2, &Intermediate2, TRUE, FALSE); - Handle2 =3D Param2 !=3D NULL ? ConvertHandleIndexToHandle ((UINTN)= Intermediate2) : NULL; - ShellConvertStringToUint64 (Param3, &Intermediate3, TRUE, FALSE); - Handle3 =3D Param3 !=3D NULL ? ConvertHandleIndexToHandle ((UINTN)= Intermediate3) : NULL; + if (!EFI_ERROR (ShellConvertStringToUint64 (Param1, &Intermediate1= , TRUE, FALSE))) { + Handle1 =3D Param1 !=3D NULL ? ConvertHandleIndexToHandle ((UINT= N)Intermediate1) : NULL; + } + + if (!EFI_ERROR (ShellConvertStringToUint64 (Param2, &Intermediate2= , TRUE, FALSE))) { + Handle2 =3D Param2 !=3D NULL ? ConvertHandleIndexToHandle ((UINT= N)Intermediate2) : NULL; + } + + if (!EFI_ERROR (ShellConvertStringToUint64 (Param3, &Intermediate3= , TRUE, FALSE))) { + Handle3 =3D Param3 !=3D NULL ? ConvertHandleIndexToHandle ((UINT= N)Intermediate3) : NULL; + } =20 if ((Param1 !=3D NULL) && (Handle1 =3D=3D NULL)) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE)= , gShellDriver1HiiHandle, L"disconnect", Param1); diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c b/Shell= Pkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c index c645c9fd6882..8f70d6b6af39 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c @@ -438,25 +438,22 @@ ShellCommandRunDrvDiag ( ControllerHandleStr =3D ShellCommandLineGetRawValue (Package, 2); ChildHandleStr =3D ShellCommandLineGetRawValue (Package, 3); =20 - if (DriverHandleStr =3D=3D NULL) { - Handle1 =3D NULL; - } else { - ShellConvertStringToUint64 (DriverHandleStr, &Intermediate, TRUE, FA= LSE); + if ((DriverHandleStr !=3D NULL) && ShellConvertStringToUint64 (DriverH= andleStr, &Intermediate, TRUE, FALSE)) { Handle1 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); + } else { + Handle1 =3D NULL; } =20 - if (ControllerHandleStr =3D=3D NULL) { - Handle2 =3D NULL; - } else { - ShellConvertStringToUint64 (ControllerHandleStr, &Intermediate, TRUE= , FALSE); + if ((ControllerHandleStr !=3D NULL) && ShellConvertStringToUint64 (Con= trollerHandleStr, &Intermediate, TRUE, FALSE)) { Handle2 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); + } else { + Handle2 =3D NULL; } =20 - if (ChildHandleStr =3D=3D NULL) { - Handle3 =3D NULL; - } else { - ShellConvertStringToUint64 (ChildHandleStr, &Intermediate, TRUE, FAL= SE); + if ((ChildHandleStr !=3D NULL) && ShellConvertStringToUint64 (ChildHan= dleStr, &Intermediate, TRUE, FALSE)) { Handle3 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); + } else { + Handle3 =3D NULL; } =20 Status =3D DoDiagnostics ( --=20 2.40.0.windows.1 -=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 (#101833): https://edk2.groups.io/g/devel/message/101833 Mute This Topic: https://groups.io/mt/97832909/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101834+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101834+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679691012; cv=none; d=zohomail.com; s=zohoarc; b=goCD+ugv3iohJke3/NS+p3S/Su64op9GryiQFeejYMg7Ndm4VnR6oRuICw+ys3QVXaTcV44iL9RHKsgPCGYc+eBxWIaFhq90h2cZ6tU4IsEX1ZGf7nl4rcaJECepKHd3Io3Fn4jQB3MMsO46untF8AeN1ODzDokF6fhgJEbb+Vs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679691012; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=/dr2JZ6OtFDbb3MqfVnGsHdYZuWEK0wirAccQBxvTEI=; b=LHypLMayr5DdRLsl5WbVrD17MDM2qf9j2DkgGS3Vsbeb1H0/whj7LMY9gOAYYfghZa7HkNYcmFdCNEGQPTWdwZPiPIrFf/BxBFJb5B3rYEk7p/yqZCmOwj32gcZaWa87OzBygk1ZdZK9zlYU+5vTZXFsvU6YTBgHgB6oUhSbV3c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101834+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679691012291553.205647844353; Fri, 24 Mar 2023 13:50:12 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id V33xYY1788612xOTJ2gNaeqd; Fri, 24 Mar 2023 13:50:11 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.8339.1679691011321294268 for ; Fri, 24 Mar 2023 13:50:11 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 31F3020FC455; Fri, 24 Mar 2023 13:50:10 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 31F3020FC455 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Eric Dong , Erich McMillan , Michael D Kinney , Michael Kubacki , Rahul Kumar , Ray Ni Subject: [edk2-devel] [PATCH v6 10/12] UefiCpuPkg: Fix conditionally uninitialized variables Date: Fri, 24 Mar 2023 16:48:36 -0400 Message-Id: <20230324204838.1485-11-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: R9LKJr5F1RLmQh9fXOJoKGqyx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679691011; bh=QiQMSiqQSB/zAFZ0S7Vky29X5HJdmrBPEA3OBBznqvk=; h=Cc:Date:From:Reply-To:Subject:To; b=Fw2/oCj514Cr0a1MX0iGMngP8TCzDhS1zJEmPcp+10LWl7k5yzOqIUbFpGc6VlA9eam OdeuhOCYGeqQBSGwi7VidhNTxo6hEsqJevvv2Yh2yc/uPqPa14Anouj5tHsnxQZ8qIIX0 k1Qfdrk9qQsyUg7MPiqT9yd0WdSsY9FoqUU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679691013660100002 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Eric Dong Cc: Erich McMillan Cc: Michael D Kinney Cc: Michael Kubacki Cc: Rahul Kumar Cc: Ray Ni Co-authored-by: Erich McMillan Signed-off-by: Michael Kubacki Reviewed-by: Michael D Kinney --- UefiCpuPkg/CpuMpPei/CpuBist.c | 8 +++++++- UefiCpuPkg/CpuMpPei/CpuMpPei.c | 8 +++++++- UefiCpuPkg/CpuMpPei/CpuPaging.c | 9 ++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/CpuMpPei/CpuBist.c b/UefiCpuPkg/CpuMpPei/CpuBist.c index 7dc93cd784d4..78e008703993 100644 --- a/UefiCpuPkg/CpuMpPei/CpuBist.c +++ b/UefiCpuPkg/CpuMpPei/CpuBist.c @@ -175,7 +175,13 @@ CollectBistDataFromPpi ( EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2; EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstanceInHob; =20 - MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledPro= cessors); + Status =3D MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberO= fEnabledProcessors); + ASSERT_EFI_ERROR (Status); + + if (EFI_ERROR (Status)) { + NumberOfProcessors =3D 1; + NumberOfEnabledProcessors =3D 1; + } =20 BistInformationSize =3D sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) + sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * Number= OfProcessors; diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index e7f1fe9f426c..b504bea3cfeb 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -473,7 +473,13 @@ InitializeMpExceptionStackSwitchHandlers ( return; } =20 - MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL); + Status =3D MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL); + ASSERT_EFI_ERROR (Status); + + if (EFI_ERROR (Status)) { + NumberOfProcessors =3D 1; + } + SwitchStackData =3D AllocatePages (EFI_SIZE_TO_PAGES (NumberOfProcessors= * sizeof (EXCEPTION_STACK_SWITCH_CONTEXT))); ASSERT (SwitchStackData !=3D NULL); ZeroMem (SwitchStackData, NumberOfProcessors * sizeof (EXCEPTION_STACK_S= WITCH_CONTEXT)); diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPagin= g.c index 135422225340..a471f089c8ae 100644 --- a/UefiCpuPkg/CpuMpPei/CpuPaging.c +++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c @@ -538,6 +538,7 @@ SetupStackGuardPage ( UINTN NumberOfProcessors; UINTN Bsp; UINTN Index; + EFI_STATUS Status; =20 // // One extra page at the bottom of the stack is needed for Guard page. @@ -547,7 +548,13 @@ SetupStackGuardPage ( ASSERT (FALSE); } =20 - MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL); + Status =3D MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL); + ASSERT_EFI_ERROR (Status); + + if (EFI_ERROR (Status)) { + NumberOfProcessors =3D 1; + } + MpInitLibWhoAmI (&Bsp); for (Index =3D 0; Index < NumberOfProcessors; ++Index) { StackBase =3D 0; --=20 2.40.0.windows.1 -=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 (#101834): https://edk2.groups.io/g/devel/message/101834 Mute This Topic: https://groups.io/mt/97832911/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101835+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101835+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679691018; cv=none; d=zohomail.com; s=zohoarc; b=GpMMTxt9NZCkvD39qdZQj+U/D/t1oYkG4/ZcYiiWI/8JReiXNoxioTzNBysRc/eP6Cx+4e+4Q5XEjAzQq+yaa1m9ST11TJh65d/xMsaaeyqWvoLKr+S3za5HV/daIgBydW9ohatFdq/JfThvO0USO4jjfS9swTuTWegqORw8GeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679691018; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=J0dznrk+sWpXETUXaIttbtG4COS3ZmB6R8i5oDllLT8=; b=LqvCsr2zLXT2+fn/cINCREtG8lZ6Yicoduc+chdAa57223HJSNtTwtZn0lnmQ1YQ4uEP709tOXM5Es/7/E9W6FbUbx06YU953qPVH0pIiJllJ+uqQ6GgGcEWP4OI4yPbUrluCn6rt2VEq2CmxWAqTTUU+nSjKl0Sa/61SVhOJfg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101835+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679691018554297.313284013409; Fri, 24 Mar 2023 13:50:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6q6pYY1788612xlQuQJ1KsWD; Fri, 24 Mar 2023 13:50:18 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.8312.1679691015776450374 for ; Fri, 24 Mar 2023 13:50:15 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id DF48E20FC459; Fri, 24 Mar 2023 13:50:12 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com DF48E20FC459 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Sean Brogan , Michael Kubacki , Michael D Kinney Subject: [edk2-devel] [PATCH v6 11/12] .github/codeql/edk2.qls: Enable CWE 457, 676, and 758 queries Date: Fri, 24 Mar 2023 16:48:37 -0400 Message-Id: <20230324204838.1485-12-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: 2US3s3wuaXUNj9V1K5FQzxNVx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679691018; bh=5LiuYQdHLsql1qT4qr8VMC9iNb7PYtL1j4aXsPi2k8M=; h=Cc:Date:From:Reply-To:Subject:To; b=XoOSvCFrZhX23qUguQ+XjOvsijUOOwNbxpib4tUFjakkp+svOJOw9IdVdd6Aoxas2HN f644MJxKwHSzbXDqCQGmQTrOeoy42ScL6lMIwlGSuP8q4acTEzzBqrZm6+x2isHP+THY4 /sTdTKlI3PrQpPai+T1ntQUBmu48ANThgwM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679691019677100001 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki The previous commits fixed issues with these queries across various packages. Now that those are resolved, enable the queries in the edk2 query set so regressions can be found in the future. Enables: 1. cpp/conditionallyuninitializedvariable - CWE: https://cwe.mitre.org/data/definitions/457.html - @name Conditionally uninitialized variable - @description An initialization function is used to initialize a local variable, but the returned status code is not checked. The variable may be left in an uninitialized state, and reading the variable may result in undefined behavior. - @kind problem - @problem.severity warning - @security-severity 7.8 - @id cpp/conditionally-uninitialized-variable - @tags security - external/cwe/cwe-457 2. cpp/pointer-overflow-check - CWE: https://cwe.mitre.org/data/definitions/758.html - @name Pointer overflow check - @description Adding a value to a pointer to check if it overflows relies on undefined behavior and may lead to memory corruption. - @kind problem - @problem.severity error - @security-severity 2.1 - @precision high - @id cpp/pointer-overflow-check - @tags reliability - security - external/cwe/cwe-758 3. cpp/potential-buffer-overflow - CWE: https://cwe.mitre.org/data/definitions/676.html - @name Potential buffer overflow - @description Using a library function that does not check buffer bounds requires the surrounding program to be very carefully written to avoid buffer overflows. - @kind problem - @id cpp/potential-buffer-overflow - @problem.severity warning - @security-severity 10.0 - @tags reliability - security - external/cwe/cwe-676 - @deprecated This query is deprecated, use Potentially overrunning write (`cpp/overrunning-write`) and Potentially overrunning write with float to string conversion (`cpp/overrunning-write-with-float`) instead. Note that cpp/potential-buffer-overflow is deprecated. This query will be updated to the succeeding queries in the next commit. The query is used in this commit to show that we considered and tested the query in history. Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Signed-off-by: Michael Kubacki Reviewed-by: Michael D Kinney --- .github/codeql/edk2.qls | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/codeql/edk2.qls b/.github/codeql/edk2.qls index ef9aae790f5f..dc2d87764e93 100644 --- a/.github/codeql/edk2.qls +++ b/.github/codeql/edk2.qls @@ -8,7 +8,14 @@ =20 # Enable individual queries below. =20 +- include: + id: cpp/conditionallyuninitializedvariable - include: id: cpp/infinite-loop-with-unsatisfiable-exit-condition - include: id: cpp/overflow-buffer +- include: + id: cpp/pointer-overflow-check +- include: + id: cpp/potential-buffer-overflow + --=20 2.40.0.windows.1 -=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 (#101835): https://edk2.groups.io/g/devel/message/101835 Mute This Topic: https://groups.io/mt/97832913/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- From nobody Wed Apr 24 14:12:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101836+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101836+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1679691019; cv=none; d=zohomail.com; s=zohoarc; b=OPsOtN5v9YhytgARPCfjnTpGXg0Yj+BsWITzwXipWgE1gEhCVi7FafXxLkbqQ7MVphQ7jwqtqUrpOXe6clL5CPgJ0DDZcg0lGFP/hvCqsII1EAk+XQQPMZ3oJUdih+KZPQuvuQY7pgGd8kMtypBNDysTT1/L3YkP5S8395lAmWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679691019; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=lgFuWTyUg1jwcNOvgAxNZH7eDWa+djX7KREMKle+rlU=; b=nf9wzI/yJzbUGZELfyN6UqxQ0SAxlzVwA2XGKuwikyhmbcKVkFzrRJ5/pia3qfqJDhqrHhxk7SZ0iMFWgJ6LSO9RviJd0I0IvTnDYNCJU/8FDkHEvLyACJ0xX/3cYGt/smAn35kB3+Ijg4byQ40QQtnwUQfPiMXQuvn8BP9zLCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101836+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679691019612665.2532204141337; Fri, 24 Mar 2023 13:50:19 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ur53YY1788612xu5g8w1jC3T; Fri, 24 Mar 2023 13:50:19 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.8342.1679691016690080771 for ; Fri, 24 Mar 2023 13:50:16 -0700 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id C668520FC455; Fri, 24 Mar 2023 13:50:15 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C668520FC455 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Sean Brogan , Michael Kubacki , Michael D Kinney Subject: [edk2-devel] [PATCH v6 12/12] .github/codeql/edk2.qls: Enable CWE 120, 787, and 805 queries Date: Fri, 24 Mar 2023 16:48:38 -0400 Message-Id: <20230324204838.1485-13-mikuback@linux.microsoft.com> In-Reply-To: <20230324204838.1485-1-mikuback@linux.microsoft.com> References: <20230324204838.1485-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mikuback@linux.microsoft.com X-Gm-Message-State: h3ncU9zhEe22EHzeMKSrP9uCx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679691019; bh=kSen3wqS6JJWSJBmNelpOAp7/eOJ3HnZGARNwWZC3VY=; h=Cc:Date:From:Reply-To:Subject:To; b=ANhodw8+7OEd1TWv361v1Fm+HpIjCJDl3Vbk0Z2KwPwCnYhC9YWlsXoUpssnGrQ+byS VgqyQO8rB7fj0ugCWR44QY2pLbnRQUsMzGDPiWs4kS79mXX+iw4BBDozTWUryC2MgafG2 xrV68YWXnjiKq7TifQGmFarOmMPyMraGtpo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679691021677100005 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki As recommended by CodeQL this change replaces cpp/potential-buffer-overflow with cpp/overrunning-write-with-float and cpp/overrunning-write. Enables: 1. cpp/overrunning-write - @name Likely overrunning write - @description Buffer write operations that do not control the length data written may overflow - @kind problem - @problem.severity error - @security-severity 9.3 - @precision high - @id cpp/very-likely-overrunning-write - @tags reliability - security - external/cwe/cwe-120 - external/cwe/cwe-787 - external/cwe/cwe-805 2. cpp/overrunning-write-with-float - @name Potentially overrunning write with float to string conversion - @description Buffer write operations that do not control the length of data written may overflow when floating point inputs take extreme values. - @kind problem - @problem.severity error - @security-severity 9.3 - @precision medium - @id cpp/overrunning-write-with-float - @tags reliability - security - external/cwe/cwe-120 - external/cwe/cwe-787 - external/cwe/cwe-805 3. cpp/very-likely-overrunning-write - @name Likely overrunning write - @description Buffer write operations that do not control the length of data written may overflow - @kind problem - @problem.severity error - @security-severity 9.3 - @precision high - @id cpp/very-likely-overrunning-write - @tags reliability - security - external/cwe/cwe-120 - external/cwe/cwe-787 - external/cwe/cwe-805 - CWEs: - https://cwe.mitre.org/data/definitions/120.html - https://cwe.mitre.org/data/definitions/787.html - https://cwe.mitre.org/data/definitions/805.html Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Signed-off-by: Michael Kubacki Reviewed-by: Michael D Kinney --- .github/codeql/edk2.qls | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/codeql/edk2.qls b/.github/codeql/edk2.qls index dc2d87764e93..9bea9ba01f24 100644 --- a/.github/codeql/edk2.qls +++ b/.github/codeql/edk2.qls @@ -14,8 +14,11 @@ id: cpp/infinite-loop-with-unsatisfiable-exit-condition - include: id: cpp/overflow-buffer +- include: + id: cpp/overrunning-write +- include: + id: cpp/overrunning-write-with-float - include: id: cpp/pointer-overflow-check - include: - id: cpp/potential-buffer-overflow - + id: cpp/very-likely-overrunning-write --=20 2.40.0.windows.1 -=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 (#101836): https://edk2.groups.io/g/devel/message/101836 Mute This Topic: https://groups.io/mt/97832914/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-