From nobody Sat Feb 7 07:10:11 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+99141+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+99141+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1674811795; cv=none; d=zohomail.com; s=zohoarc; b=gY+PAkegGPTzxdUd3tu6mftOFKwI9OE85VbVpYIEtyW9S/Rgw7PY4jfISs2JP/60FsdNmdRxz2juPU9WKu0C8ZDibuJxWJAmpUb3EplZmU3zD5cnQggBFv9hiKMzydtKEHxpI2K16D6xNTnJNt3NAp1GRynm+BfVRzdjfVK4hVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674811795; h=Content-Type: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=Iebp8oXyP4MffAYPrznmjDtPw0INSBseYYTqX1Rliwg=; b=ZbiY5OmwhRiMjXBk37nW8oNVs2tC9FJRlY1gWv+ZspqBSNNxitOWGtX+dFA11ZNda2tM6FwL4BbI5ZvPauVFpXvXN9a+bTZqjBektdXBikkPLpBZ7fN7AqaCIha5yBw5YejW2/59OVQD9yo6gOUGF1MWL8CjqhmKgAP/C2BK4vs= 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+99141+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 1674811795068379.70818028859856; Fri, 27 Jan 2023 01:29:55 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id uiJSYY1788612x7qO7nBOR4j; Fri, 27 Jan 2023 01:29:54 -0800 X-Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by mx.groups.io with SMTP id smtpd.web11.98570.1674811791892615145 for ; Fri, 27 Jan 2023 01:29:54 -0800 X-Received: by mail-lf1-f51.google.com with SMTP id o20so7236438lfk.5 for ; Fri, 27 Jan 2023 01:29:53 -0800 (PST) X-Gm-Message-State: PghygozbskK2kAAxes3Ablsax1787277AA= X-Google-Smtp-Source: AMrXdXsBgCJ5shgEXYr/lKJLL/LJ83cFuK1U7kNQoEaBP1CexF2jA9sIeg7zKL6lJwnRfu6jizN+3w== X-Received: by 2002:ac2:4473:0:b0:4ca:f97f:4a21 with SMTP id y19-20020ac24473000000b004caf97f4a21mr10105563lfl.37.1674811792783; Fri, 27 Jan 2023 01:29:52 -0800 (PST) X-Received: from localhost.localdomain ([176.62.67.29]) by smtp.gmail.com with ESMTPSA id t11-20020a056512068b00b004cc8196a308sm229071lfe.98.2023.01.27.01.29.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Jan 2023 01:29:52 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-devel] [edk2-platforms][PATCH v3 06/11] Ext4Pkg: Corrects integer overflow check logic in DiskUtil Date: Fri, 27 Jan 2023 15:29:40 +0600 Message-Id: <20230127092945.94389-7-savvamtr@gmail.com> In-Reply-To: <20230127092945.94389-1-savvamtr@gmail.com> References: <20230127092945.94389-1-savvamtr@gmail.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,savvamtr@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1674811794; bh=BR5Ayh3q9eQXkW5Xg7PgC4Hk27UIkRxLlKchwIFOaa4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=esopnXck7DFEmbLSXPwCv1PGb0Ii1fqXTob7MMh22jSTyBlFV3hYj1WTUO9Zwf3gCNG BFUgHIBRsd0CE1nEJnj4EEtxFfreV0DpFF4pie/n1EoD2sqQMaBdXzDIBKEPyc1vCJbem vStcLUmeWHld4PTA1N4GeTB5c5JAYrhYUZU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1674811796646100021 Content-Type: text/plain; charset="utf-8" Corrects multiplication overflow check code Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: d9ceedca6c8f ("Ext4Pkg: Add Ext4Dxe driver.") Signed-off-by: Savva Mitrofanov Reviewed-by: Pedro Falcato --- Features/Ext4Pkg/Ext4Pkg.dsc | 2 +- Features/Ext4Pkg/Ext4Dxe/DiskUtil.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Pkg.dsc b/Features/Ext4Pkg/Ext4Pkg.dsc index 59bc327ebf6e..621c63eaf92d 100644 --- a/Features/Ext4Pkg/Ext4Pkg.dsc +++ b/Features/Ext4Pkg/Ext4Pkg.dsc @@ -46,7 +46,7 @@ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib= /BaseOrderedCollectionRedBlackTreeLib.inf BaseUcs2Utf8Lib|RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.inf - =20 + # # Required for stack protector support # diff --git a/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c b/Features/Ext4Pkg/Ext4Dxe= /DiskUtil.c index 32da35f7d9f5..c4af956da926 100644 --- a/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c +++ b/Features/Ext4Pkg/Ext4Dxe/DiskUtil.c @@ -60,11 +60,11 @@ Ext4ReadBlocks ( // Check for overflow on the block -> byte conversions. // Partition->BlockSize is never 0, so we don't need to check for that. =20 - if (Offset > DivU64x32 ((UINT64)-1, Partition->BlockSize)) { + if ((NumberBlocks !=3D 0) && (DivU64x64Remainder (Offset, BlockNumber, N= ULL) !=3D Partition->BlockSize)) { return EFI_INVALID_PARAMETER; } =20 - if (Length > (UINTN)-1/Partition->BlockSize) { + if ((NumberBlocks !=3D 0) && (Length / NumberBlocks !=3D Partition->Bloc= kSize)) { return EFI_INVALID_PARAMETER; } =20 @@ -94,12 +94,12 @@ Ext4AllocAndReadBlocks ( =20 Length =3D NumberBlocks * Partition->BlockSize; =20 - if (Length > (UINTN)-1/Partition->BlockSize) { + // Check for integer overflow + if ((NumberBlocks !=3D 0) && (Length / NumberBlocks !=3D Partition->Bloc= kSize)) { return NULL; } =20 Buf =3D AllocatePool (Length); - if (Buf =3D=3D NULL) { return NULL; } --=20 2.39.0 -=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 (#99141): https://edk2.groups.io/g/devel/message/99141 Mute This Topic: https://groups.io/mt/96562694/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-