From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id DD0D5D80A38 for ; Tue, 7 Nov 2023 06:28:56 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Fxc2ApZ/5Uj9wR59rxZK3Bd6lk9oSGk7XJOkhLQpEew=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699338535; v=1; b=G8b8XbM3t521yA5Zg4H1khjSdkuLULwcBDutCXkk+GyRVMMm3EvUSmeX5WCf0qbNVic4C9pO tozUoWyvKKCxpQfdn2qvJU92BZNXXqc7LMwJoC5W8L/mWqQDkGaTkadxWcZ1IqROavl1WGhtW3x p0W9oROz8/AExRGujCddF4vk= X-Received: by 127.0.0.2 with SMTP id DcrVYY7687511x2lDSDfbsZV; Mon, 06 Nov 2023 22:28:55 -0800 X-Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by mx.groups.io with SMTP id smtpd.web10.5112.1699338535000684796 for ; Mon, 06 Nov 2023 22:28:55 -0800 X-Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-7a996357550so207751139f.2 for ; Mon, 06 Nov 2023 22:28:54 -0800 (PST) X-Gm-Message-State: G9kq4Mh4AMkzVw6RliYSXQrox7686176AA= X-Google-Smtp-Source: AGHT+IGaE+bywZI/r//TVzV8brCVl/bGoILM6L/gLJyOs5p4WmazRnTFezc+OMkMUM8DLAiogEat1g== X-Received: by 2002:a05:6e02:1909:b0:357:43a5:acf8 with SMTP id w9-20020a056e02190900b0035743a5acf8mr2690839ilu.17.1699338533965; Mon, 06 Nov 2023 22:28:53 -0800 (PST) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1f24:775d:7335:84a5:7d11:9393]) by smtp.gmail.com with ESMTPSA id c7-20020a0290c7000000b00463ff17540fsm1766626jag.78.2023.11.06.22.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 22:28:53 -0800 (PST) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v2 2/2] FatPkg/EnhancedFatDxe: Fix OVERFLOW_BEFORE_WIDEN Coverity issue Date: Tue, 7 Nov 2023 11:58:42 +0530 Message-Id: <20231107062842.116670-3-rsingh@ventanamicro.com> In-Reply-To: <20231107062842.116670-1-rsingh@ventanamicro.com> References: <20231107062842.116670-1-rsingh@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk 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,rsingh@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=G8b8XbM3; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none From: Ranbir Singh The function FatInitializeDiskCache evaluates an expression FAT_DATACACHE_GROUP_COUNT << DiskCache[CacheData].PageAlignment and assigns it to DataCacheSize which is of type UINTN. As per Coverity report, FAT_DATACACHE_GROUP_COUNT << DiskCache[CacheData].PageAlignment is a potentially overflowing expression with type "int" (32 bits, signed) evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "UINTN" (64 bits, unsigned). To avoid overflow, cast "FAT_DATACACHE_GROUP_COUNT" to type "UINTN". REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4249 Cc: Ray Ni Co-authored-by: Veeresh Sangolli Signed-off-by: Ranbir Singh Signed-off-by: Ranbir Singh --- FatPkg/EnhancedFatDxe/DiskCache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FatPkg/EnhancedFatDxe/DiskCache.c b/FatPkg/EnhancedFatDxe/Disk= Cache.c index d1a34a6a646f..d56e338586d8 100644 --- a/FatPkg/EnhancedFatDxe/DiskCache.c +++ b/FatPkg/EnhancedFatDxe/DiskCache.c @@ -477,7 +477,7 @@ FatInitializeDiskCache ( DiskCache[CacheFat].BaseAddress =3D Volume->FatPos;=0D DiskCache[CacheFat].LimitAddress =3D Volume->FatPos + Volume->FatSize;= =0D FatCacheSize =3D FatCacheGroupCount << DiskCache[Ca= cheFat].PageAlignment;=0D - DataCacheSize =3D FAT_DATACACHE_GROUP_COUNT << DiskC= ache[CacheData].PageAlignment;=0D + DataCacheSize =3D (UINTN)FAT_DATACACHE_GROUP_COUNT <= < DiskCache[CacheData].PageAlignment;=0D //=0D // Allocate the Fat Cache buffer=0D //=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110818): https://edk2.groups.io/g/devel/message/110818 Mute This Topic: https://groups.io/mt/102438365/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-