From nobody Mon Dec 23 13:47:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1516938599714931.5886854203204; Thu, 25 Jan 2018 19:49:59 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6EF6F2238B59C; Thu, 25 Jan 2018 19:44:27 -0800 (PST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 417E42238B581 for ; Thu, 25 Jan 2018 19:44:26 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2018 19:49:56 -0800 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by fmsmga005.fm.intel.com with ESMTP; 25 Jan 2018 19:49:55 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,414,1511856000"; d="scan'208";a="198771445" From: Star Zeng To: edk2-devel@lists.01.org Date: Fri, 26 Jan 2018 11:49:51 +0800 Message-Id: <1516938591-9856-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [edk2] [PATCH] IntelSiliconPkg MicrocodeUpdateDxe: TotalSize must be multiples of 1KB X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiewen Yao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TotalSize must be multiples of 1024 bytes (1 KBytes) according to SDM. Also enhance the debug message for DataSize that must be multiples of DWORDs. Cc: Jiewen Yao Cc: Rangasai V Chaganty Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Jiewen.yao@intel.com --- .../Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c | 19 +++++++++++++++= ---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUp= date.c b/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate= .c index 11a51106fdd2..46b55088285f 100644 --- a/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c +++ b/IntelSiliconPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.c @@ -8,7 +8,7 @@ =20 MicrocodeWrite() and VerifyMicrocode() will receive untrusted input and = do basic validation. =20 - Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -421,7 +421,7 @@ VerifyMicrocode ( return EFI_INCOMPATIBLE_VERSION; } // - // Check Size + // Check TotalSize // if (MicrocodeEntryPoint->DataSize =3D=3D 0) { TotalSize =3D 2048; @@ -436,6 +436,14 @@ VerifyMicrocode ( } return EFI_VOLUME_CORRUPTED; } + if ((TotalSize & (SIZE_1KB - 1)) !=3D 0) { + DEBUG((DEBUG_ERROR, "VerifyMicrocode - TotalSize is not multiples of 1= 024 bytes (1 KBytes)\n")); + *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; + if (AbortReason !=3D NULL) { + *AbortReason =3D AllocateCopyPool(sizeof(L"InvalidTotalSize"), L"Inv= alidTotalSize"); + } + return EFI_VOLUME_CORRUPTED; + } if (TotalSize !=3D ImageSize) { DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on TotalSize\n")); *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; @@ -445,7 +453,7 @@ VerifyMicrocode ( return EFI_VOLUME_CORRUPTED; } // - // Check CheckSum32 + // Check DataSize // if (MicrocodeEntryPoint->DataSize =3D=3D 0) { DataSize =3D 2048 - sizeof(CPU_MICROCODE_HEADER); @@ -461,13 +469,16 @@ VerifyMicrocode ( return EFI_VOLUME_CORRUPTED; } if ((DataSize & 0x3) !=3D 0) { - DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize not aligned\n")); + DEBUG((DEBUG_ERROR, "VerifyMicrocode - DataSize is not multiples of DW= ORDs\n")); *LastAttemptStatus =3D LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT; if (AbortReason !=3D NULL) { *AbortReason =3D AllocateCopyPool(sizeof(L"InvalidDataSize"), L"Inva= lidDataSize"); } return EFI_VOLUME_CORRUPTED; } + // + // Check CheckSum32 + // CheckSum32 =3D CalculateSum32((UINT32 *)MicrocodeEntryPoint, DataSize + = sizeof(CPU_MICROCODE_HEADER)); if (CheckSum32 !=3D 0) { DEBUG((DEBUG_ERROR, "VerifyMicrocode - fail on CheckSum32\n")); --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel