From nobody Mon May 6 10:54:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+46670+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+46670+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1567427696; cv=none; d=zoho.com; s=zohoarc; b=NQIwv789pH0Mf/LulkoThuO9z4HG+pDymx8QgQGNvu/orbW0JWLO2/NQ0Q2q7GhNSVNMK1MHl3Q6LFK165phexp3WGjH2qd4CeqXmRLS0KXBLYybO4KWJUHCIzA0TWe35v2KbGiG6et7wHnJVgUErXeGTd5sCfnwWjR9vH0Jn2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567427696; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=a/+CFOYsV8t246ZnYtUxn9Zh2KFgwZ0YKVNA4FIDMYc=; b=RSaNt5ixgNhlBowXTFz2/gdItUeiuPZOmIH/4iVxNCd6kogxgCV4KhnvBOqNH2QRo1NrMyz4LtPm639625mJf+Gqgc6ZhpMFCAOJS1HKHolULWNBnBOgp1wKC0kiq4pUDScamAuOPKcNX1DA4jIv9OUMk8S3FWWKOw1NN5iuDo0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+46670+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1567427696784998.8192434521116; Mon, 2 Sep 2019 05:34:56 -0700 (PDT) Return-Path: X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by groups.io with SMTP; Mon, 02 Sep 2019 05:34:56 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Sep 2019 05:34:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,459,1559545200"; d="scan'208";a="186990338" X-Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 02 Sep 2019 05:34:53 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Michael Kubacki , Chasel Chiu , Nate DeSimone , Liming Gao Subject: [edk2-devel] [PATCH] MinPlatformPkg/SecFspWrapperPlatformSecLib: Change TopOfTemporaryRam type Date: Mon, 2 Sep 2019 20:34:49 +0800 Message-Id: <20190902123452.27716-1-shenglei.zhang@intel.com> Precedence: Bulk List-Unsubscribe: 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,shenglei.zhang@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1567427696; bh=leAEc9aoiRKsPi0mvba8i5RBegK12uyYp18x2wxwSt0=; h=Cc:Date:From:Reply-To:Subject:To; b=Djp9TdhT1Tw1aYlpDU3qAu2qR7KNDZnK3iIYZVrOb48CLv8upaYlQKv+mOD6Wfsr84B Q5SWX//OyLWvST81QLTHwqVjohIvFrLDfqgXI73++uvh1EjDaYgqJT8INHWAN8AMJAOrM 8es922RstAFOjaYf3gwuQ8TgaR1bycXW6zM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cast TopOfTemporaryRam's from UINT32 to UINTN in the expression. The original code (TopOfTemporaryRam - sizeof (UINT32)) may cause overflow. As a result the operation under 64-bit OS environment, (UINT)(...= ), may cast a overflowed 4-byte result to 8-byte one. Cc: Michael Kubacki Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Signed-off-by: Shenglei Zhang --- .../Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c | 2 +- .../SecFspWrapperPlatformSecLib/SecPlatformInformation.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecGetPerformance.c b/Platform/Intel/MinPlatformPkg/FspWrapp= er/Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c index c4eeb2b1..0cc42f96 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecGetPerformance.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecGetPerformance.c @@ -79,7 +79,7 @@ SecGetPerformance ( // TopOfTemporaryRam =3D (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof(UINT3= 2); TopOfTemporaryRam -=3D sizeof(UINT32) * 2; - Count =3D *(UINT32 *) (UINTN) (TopOfTemporaryRam - sizeof (U= INT32)); + Count =3D *(UINT32 *)((UINTN)TopOfTemporaryRam - sizeof (UIN= T32)); Size =3D Count * sizeof (UINT32); =20 Ticker =3D *(UINT64 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32) - Si= ze - sizeof (UINT32) * 2); diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapper= PlatformSecLib/SecPlatformInformation.c b/Platform/Intel/MinPlatformPkg/Fsp= Wrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c index 5b94ed2b..1bcee5f4 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecPlatformInformation.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatfor= mSecLib/SecPlatformInformation.c @@ -61,7 +61,7 @@ SecPlatformInformation ( // TopOfTemporaryRam =3D (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof (UINT= 32); TopOfTemporaryRam -=3D sizeof(UINT32) * 2; - Count =3D *((UINT32 *)(UINTN) (TopOfTemporaryRam - sizeof (U= INT32))); + Count =3D *((UINT32 *)((UINTN)TopOfTemporaryRam - sizeof (UI= NT32))); Size =3D Count * sizeof (IA32_HANDOFF_STATUS); =20 if ((*StructureSize) < (UINT64) Size) { --=20 2.18.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 (#46670): https://edk2.groups.io/g/devel/message/46670 Mute This Topic: https://groups.io/mt/33110619/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-