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 C3E54AC0AB3 for ; Thu, 28 Sep 2023 07:46:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=WbkJ8M1fkfo/sbPm/lPT560v+9vH2l4sQ/7o2Vw8+Tw=; 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=1695887213; v=1; b=w3MXoEwskHFLwcLyH75VQj5TUc+GR0I6grM9PwHymSdIBXyjCGHzVWiJ0j0hZ2iCa6Zk1dRK ZNGzaNqLpNGcENYjzGgatV6i0kw6eUQka/UvY45PO0g7iPKm4hbaBbbR4PS6/3paUIkC5vm5gYz TO1+KYC+YWlluN5cLhLjSR+k= X-Received: by 127.0.0.2 with SMTP id QThcYY7687511x65biq59UW2; Thu, 28 Sep 2023 00:46:53 -0700 X-Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) by mx.groups.io with SMTP id smtpd.web10.9043.1695887212628450120 for ; Thu, 28 Sep 2023 00:46:52 -0700 X-Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-3512c09355fso30549215ab.0 for ; Thu, 28 Sep 2023 00:46:52 -0700 (PDT) X-Gm-Message-State: v1eTd5CreHZSs69HnHaz93JNx7686176AA= X-Google-Smtp-Source: AGHT+IF8JBQbHVNtAG4s34rRAQG1xLwz32BghLfUXTnsG3KGKjVyE3t67/W4GqrfAz/Vug2bQYQdxA== X-Received: by 2002:a05:6e02:130f:b0:34c:e6e6:80d5 with SMTP id g15-20020a056e02130f00b0034ce6e680d5mr365958ilr.26.1695887211732; Thu, 28 Sep 2023 00:46:51 -0700 (PDT) X-Received: from user-Latitude-5420.dc1.ventanamicro.com ([2401:4900:1cbc:99f:6dc7:3128:6646:ac3f]) by smtp.gmail.com with ESMTPSA id y13-20020a02ce8d000000b0043a1f6dc8d4sm4342751jaq.4.2023.09.28.00.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 00:46:51 -0700 (PDT) From: "Ranbir Singh" To: devel@edk2.groups.io, rsingh@ventanamicro.com Cc: Ray Ni , Veeresh Sangolli Subject: [edk2-devel] [PATCH v1 2/2] FatPkg/EnhancedFatDxe: Fix OVERFLOW_BEFORE_WIDEN Coverity issue Date: Thu, 28 Sep 2023 13:16:39 +0530 Message-Id: <20230928074639.561998-3-rsingh@ventanamicro.com> In-Reply-To: <20230928074639.561998-1-rsingh@ventanamicro.com> References: <20230928074639.561998-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=w3MXoEws; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 (#109140): https://edk2.groups.io/g/devel/message/109140 Mute This Topic: https://groups.io/mt/101633789/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-