From nobody Mon Sep 16 19:37:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101630+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101630+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679557274; cv=none; d=zohomail.com; s=zohoarc; b=h8PX3BSOBsDhFdEa0u5X2dVeK3YLSqDjq1EU+Kp9WhwXjQ6+YAXMGpFObvLSBOtrrKSI1Z+stQFKpWPdsd6UCs34suuGAmYIILnMHYQ2XE/u4e8siaBp2ZnKNNGp+MOtCrRXLUhnLmarWDLa4V/2KvkzLOQ4a5qgz6ck/4XSlSI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679557274; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=2FURtc8ZkL2VVZUdQRGC4EVoL/8nIqJE2DiiRN7ZlEs=; b=PN77JG4xpZCmLi567F4TtdXsVGtJt54uNA+DNfhJJ6wFugPcIhRQXM+R0Vm3WC36In/Csqo/v4VO0Pi46GXVwtKWG4h1DbkoIPrEMBzQZaUpVtoR+a3iDLnTtfXZ7op0gzS3B5i/icW3IilsGAhat1VxrFkEeyxW/ZrPfni9J4g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101630+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679557274438190.89269593523738; Thu, 23 Mar 2023 00:41:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id gjhSYY1788612xsmVPDPUpz1; Thu, 23 Mar 2023 00:41:14 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.67098.1679557268568440146 for ; Thu, 23 Mar 2023 00:41:13 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="425699490" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="425699490" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 00:41:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="684616809" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="684616809" X-Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.92]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 00:41:11 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [Patch V4 02/21] UefiCpuPkg/CpuPageTableLib: Add check for input Length Date: Thu, 23 Mar 2023 15:40:38 +0800 Message-Id: <20230323074057.549-3-dun.tan@intel.com> In-Reply-To: <20230323074057.549-1-dun.tan@intel.com> References: <20230323074057.549-1-dun.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,dun.tan@intel.com X-Gm-Message-State: mvuAIMcpRpXaOuaV7b7WIHLdx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679557274; bh=Rt7yXJ134d7PUJPyfWrdRcM/OjA3MoK0MWP/E4J1Sz0=; h=Cc:Date:From:Reply-To:Subject:To; b=bYe/TEQrIQYsqzgfeurvwxk49Lu4WJVcf+TVkp6TpDw+CeLG/3qXUpav/QTl2j2lNEA aCbbvtuJKQ9rg/N+wKBsKGioJg6i8LuKDpIbzH+Q5dxZcGHsGGU0yD4vO4iD3UDFiSqjK nu0ncOivkEZgjyYsrPeLdDHfNqYSf62yASA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679557276236100002 Content-Type: text/plain; charset="utf-8" Add check for input Length in PageTableMap (). Return RETURN_SUCCESS when input Length is 0. Signed-off-by: Dun Tan Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Reviewed-by: Ray Ni --- UefiCpuPkg/Include/Library/CpuPageTableLib.h | 4 ++-- UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/Include/Library/CpuPageTableLib.h b/UefiCpuPkg/Incl= ude/Library/CpuPageTableLib.h index 2dc9b7d18e..5f44ece548 100644 --- a/UefiCpuPkg/Include/Library/CpuPageTableLib.h +++ b/UefiCpuPkg/Include/Library/CpuPageTableLib.h @@ -1,7 +1,7 @@ /** @file Public include file for PageTableLib library. =20 - Copyright (c) 2022, Intel Corporation. All rights reserved.
+ Copyright (c) 2022 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -81,7 +81,7 @@ typedef enum { @retval RETURN_BUFFER_TOO_SMALL The buffer is too small for page table= creation/updating. BufferSize is updated to indicate the = expected buffer size. Caller may still get RETURN_BUFFER_TOO= _SMALL with the new BufferSize. - @retval RETURN_SUCCESS PageTable is created/updated successfu= lly. + @retval RETURN_SUCCESS PageTable is created/updated successfu= lly or the input Length is 0. **/ RETURN_STATUS EFIAPI diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c b/UefiCpu= Pkg/Library/CpuPageTableLib/CpuPageTableMap.c index 52535e5a8d..218068a3e1 100644 --- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c +++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c @@ -544,7 +544,7 @@ PageTableLibMapInLevel ( @retval RETURN_BUFFER_TOO_SMALL The buffer is too small for page table= creation/updating. BufferSize is updated to indicate the = expected buffer size. Caller may still get RETURN_BUFFER_TOO= _SMALL with the new BufferSize. - @retval RETURN_SUCCESS PageTable is created/updated successfu= lly. + @retval RETURN_SUCCESS PageTable is created/updated successfu= lly or the input Length is 0. **/ RETURN_STATUS EFIAPI @@ -567,6 +567,10 @@ PageTableMap ( IA32_PAGE_LEVEL MaxLeafLevel; IA32_MAP_ATTRIBUTE ParentAttribute; =20 + if (Length =3D=3D 0) { + return RETURN_SUCCESS; + } + if ((PagingMode =3D=3D Paging32bit) || (PagingMode =3D=3D PagingPae) || = (PagingMode >=3D PagingModeMax)) { // // 32bit paging is never supported. --=20 2.31.1.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 (#101630): https://edk2.groups.io/g/devel/message/101630 Mute This Topic: https://groups.io/mt/97796375/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-