From nobody Sun Feb 8 08:43:28 2026 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+100102+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+100102+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1676303383; cv=none; d=zohomail.com; s=zohoarc; b=hR4H4KoSmZUTYblcpXF2kjrtzvXFJ0JwR79DdTDgRn8oH1poigLxs8z4h7ZS1oVAwkAPKtBQq9wZyLwdC/fpzs+NilcaOuUYUaoMAHu/T1RQGcxUGicLQAWIGbVDRaRMF77Eec83YOoUko9bknVBOf5FrkKUbrlZ+GOV3p/TMSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676303383; 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=kIr4Rf4uK0dpMRvdRJZnoJft4ig/Up0OTA0FYqWNmn8=; b=f4AVQ2yBUn1dXXEjIOyhkN8POSPs1XOHodGqI5neFYpDz4/QDGqkLEsOIHjOwqwEpycTo6kQ5d0Ca+QMiMI0MWX1JomQPZimHGHaBA4sZbk9e95gbRWGTAQDLawgdH6C/ClSNiS3lImAb86PUEZkcIcrlk9T1okcPXqZIFOuzt8= 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+100102+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 1676303383560642.120997456101; Mon, 13 Feb 2023 07:49:43 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id jXFsYY1788612xMgHjqXF9PK; Mon, 13 Feb 2023 07:49:42 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.17962.1676303382236707384 for ; Mon, 13 Feb 2023 07:49:42 -0800 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 5332720C8B73; Mon, 13 Feb 2023 07:49:40 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 5332720C8B73 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 v3 01/12] MdeModulePkg/SmbiosDxe: Fix pointer and buffer overflow CodeQL alerts Date: Mon, 13 Feb 2023 10:48:57 -0500 Message-Id: <20230213154908.1993-2-mikuback@linux.microsoft.com> In-Reply-To: <20230213154908.1993-1-mikuback@linux.microsoft.com> References: <20230213154908.1993-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: 1FBMDKR3U3lioAAxzP4qhKYyx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1676303382; bh=jYiknVXQQEe7YQeBWu6PnT7eh1qr+yXDYZRunOt8aDY=; h=Cc:Date:From:Reply-To:Subject:To; b=qeXSkoKCWFZK4zXsR9aM+MmEogv0pvJLswV5yIIjeczxuR0Gou34eG0sWIgL2li/7cF ZTbIeH73bNZiRSWMGMYkfSME8DNSfDepTfKzoW51Nb4pNOlLpmAYuk5VUYI8W8NqmpqbK hr3tg2FXFK21xDeS9x9rD7B+zPxRF8la3fA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1676303384809100002 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 | 11 ++++++++--- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Un= iversal/SmbiosDxe/SmbiosDxe.c index 1d43adc7662c..c1da2adc296b 100644 --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c @@ -8,6 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 #include "SmbiosDxe.h" +#include =20 // // Module Global: @@ -1594,6 +1595,7 @@ ParseAndAddExistingSmbiosTable ( CHAR8 *String; EFI_SMBIOS_HANDLE SmbiosHandle; SMBIOS_STRUCTURE_POINTER SmbiosEnd; + UINTN SafeIntResult; =20 mPrivateData.Smbios.MajorVersion =3D MajorVersion; mPrivateData.Smbios.MinorVersion =3D MinorVersion; @@ -1608,9 +1610,12 @@ ParseAndAddExistingSmbiosTable ( // // Make sure not to access memory beyond SmbiosEnd // - if ((Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw) || - (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw)) - { + Status =3D SafeUintnAdd ((UINTN)Smbios.Raw, sizeof (SMBIOS_STRUCTURE),= &SafeIntResult); + if (EFI_ERROR (Status)) { + return EFI_INVALID_PARAMETER; + } + + if ((SafeIntResult > (UINTN)SmbiosEnd.Raw) || (SafeIntResult < (UINTN)= Smbios.Raw)) { return EFI_INVALID_PARAMETER; } =20 diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf b/MdeModulePkg/= Universal/SmbiosDxe/SmbiosDxe.inf index c03915a6921f..8b7c74694775 100644 --- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf +++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf @@ -42,6 +42,7 @@ [LibraryClasses] DebugLib PcdLib HobLib + SafeIntLib =20 [Protocols] gEfiSmbiosProtocolGuid ## PRODUCES --=20 2.28.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 (#100102): https://edk2.groups.io/g/devel/message/100102 Mute This Topic: https://groups.io/mt/96938294/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-