From nobody Mon Sep 16 19:43:30 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+101021+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+101021+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1678473906; cv=none; d=zohomail.com; s=zohoarc; b=dE4rNsvFDwJvbkj9WyShYKLepzmL8+nHD201b3kEcdjEJY40fNoucAzVvR0szdMeBZfjktKC2UYkYIrwQP3VfdhIWKz5Yf0PqZcO0a6xzVirlpP6K3DEMpJP92Wv648pg7hXBdyH6krFp6BwjslpZn8Zim9BvHwTTKLGERnTF4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678473906; 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=khY+XN+65/d0GRjmRefSGbxSDfuTkka8t6hTDIbfjJ0=; b=Hz03tX9Tu0V3+vNhV2dT1uXG3Qyt7eeBuNM5kUdXyMTmT9W+VsQgCqzlIpcHxKbktHdQLpIHcUbAJeNPXYbKhPYrHxroK5LegBDwErnhd7e78WCrbZCw17YIry8V+Q5tc6vRNkQ9yPA4+hQ7pt/ErvCxP34IlVfLOGmXveOy3wc= 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+101021+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 1678473906518396.1229648775467; Fri, 10 Mar 2023 10:45:06 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id swVHYY1788612xzIDGi3Hzyj; Fri, 10 Mar 2023 10:45:06 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.27801.1678473905694120874 for ; Fri, 10 Mar 2023 10:45:05 -0800 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 236D42057658; Fri, 10 Mar 2023 10:45:04 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 236D42057658 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 v4 01/12] MdeModulePkg/SmbiosDxe: Fix pointer and buffer overflow CodeQL alerts Date: Fri, 10 Mar 2023 13:42:27 -0500 Message-Id: <20230310184238.2999-2-mikuback@linux.microsoft.com> In-Reply-To: <20230310184238.2999-1-mikuback@linux.microsoft.com> References: <20230310184238.2999-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: ZwrceyN26b57z8DGxWepGfLVx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678473906; bh=eCEvO8sXInixiPEckRgj88lu5egq+vV8SS4zdYepo2Q=; h=Cc:Date:From:Reply-To:Subject:To; b=r1i0+4OePs2U/IIUbl96J2VeK9DSXhwD27j8h9Sv8adpt3IeC4caRIPWT22e9Auyrzn 1AjN+WBb9KZmgEJPh2bMIJ6M+dO423kiD9+6BBS5ihNxKhH35dbOU7tJwliqqmc8iTi2J 7lXRGwQPQQb6f0W1P6MdJmIlK6FLyj52+74= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678473907841100006 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.39.2.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 (#101021): https://edk2.groups.io/g/devel/message/101021 Mute This Topic: https://groups.io/mt/97526776/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-