From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: shenglei.zhang@intel.com) 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 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" 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: [PATCH] MinPlatformPkg/SecFspWrapperPlatformSecLib: Change TopOfTemporaryRam type Date: Mon, 2 Sep 2019 20:34:49 +0800 Message-Id: <20190902123452.27716-1-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 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/SecFspWrapperPlatformSecLib/SecGetPerformance.c b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c index c4eeb2b1..0cc42f96 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecGetPerformance.c @@ -79,7 +79,7 @@ SecGetPerformance ( // TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof(UINT32); TopOfTemporaryRam -= sizeof(UINT32) * 2; - Count = *(UINT32 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32)); + Count = *(UINT32 *)((UINTN)TopOfTemporaryRam - sizeof (UINT32)); Size = Count * sizeof (UINT32); Ticker = *(UINT64 *) (UINTN) (TopOfTemporaryRam - sizeof (UINT32) - Size - sizeof (UINT32) * 2); diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c index 5b94ed2b..1bcee5f4 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecPlatformInformation.c @@ -61,7 +61,7 @@ SecPlatformInformation ( // TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof (UINT32); TopOfTemporaryRam -= sizeof(UINT32) * 2; - Count = *((UINT32 *)(UINTN) (TopOfTemporaryRam - sizeof (UINT32))); + Count = *((UINT32 *)((UINTN)TopOfTemporaryRam - sizeof (UINT32))); Size = Count * sizeof (IA32_HANDOFF_STATUS); if ((*StructureSize) < (UINT64) Size) { -- 2.18.0.windows.1