From nobody Fri Oct 18 06:14:07 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+101137+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+101137+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1678727945; cv=none; d=zohomail.com; s=zohoarc; b=F2LcLMekchRWdcnPXr5lzR9A9JmIWqtuyRGlQFH5Qt9sXsznFNKVMJ4w1QPotQGIiRvqijiajasvTQeGvwEXRTAtuw9tJ2q9mPKW/Ozaq9Zt4kWVUgvRqGbLDNhz4k2qqvFU6xhoFVhuZzVeMjtB8z4z0aZ4CJQO9dmQ37qaBAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678727945; 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=bP+YQUUiydvmHKzufp84VWZogFZ+jot1M9dtNUTEP+0=; b=J9pglkEwWr42ZagvJKbNV37maSaajSVCREyKkYLO4bc9ZORQrPiIXM/ezlEavadtQyKZ1Sg/IjOHR2LWBs63y+F6BcGubkQN9oV9DqBwaxAOFwY2tl82l6hKepKVgxkFwOFBNJ31ID5qDA0NPLWpWutt0LiDscq4pJd5/zUYQss= 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+101137+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 167872794527285.2121678816103; Mon, 13 Mar 2023 10:19:05 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id g8f1YY1788612xX98gWu7Qe6; Mon, 13 Mar 2023 10:19:04 -0700 X-Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web10.25831.1678727943638246589 for ; Mon, 13 Mar 2023 10:19:04 -0700 X-Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 22D52B811AC; Mon, 13 Mar 2023 17:19:02 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96351C4339E; Mon, 13 Mar 2023 17:18:58 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar , Taylor Beebe Subject: [edk2-devel] [PATCH v5 33/38] MdeModulePkg/DxeCore: Disregard runtime alignment for image protection Date: Mon, 13 Mar 2023 18:17:09 +0100 Message-Id: <20230313171714.3866151-34-ardb@kernel.org> In-Reply-To: <20230313171714.3866151-1-ardb@kernel.org> References: <20230313171714.3866151-1-ardb@kernel.org> 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,ardb@kernel.org X-Gm-Message-State: ww74Tc5f42nvgX0kG6OmNRsqx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678727944; bh=YJNtim0+vZ7yD/R2dtSudkHD3vEJpBwSzRu4qHTd1Ig=; h=Cc:Date:From:Reply-To:Subject:To; b=Lw9WxlW9OD0ubsIl9mpHqVKyaURrrTqIi3Di6ehkVb3k3KZQzmgDqqvUTF/NPCDyUXB 5nNfD8Tv4703yaIwKSJWeMvMbdtYNRCL5eOTfg66iwkpOhG++aZDqxci6o2uKZokNtT3N 8qKKT9zJWkF0jC39Gd99ZqsMLQXyoxFhW9Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678727946478100014 Content-Type: text/plain; charset="utf-8" Image protection in DXE pertains to the memory permission attributes used at boot time, when the page size is guaranteed to be 4k. Whether or not the minimum section alignment is even higher when running under the OS is not relevant here, so just use the EFI page size as the minimum section alignment directly. Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 49 +------------------- 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/C= ore/Dxe/Misc/MemoryProtection.c index 85c5a6a7c758..045e2f391bc0 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c @@ -304,51 +304,6 @@ SetUefiImageProtectionAttributes ( return; } =20 -/** - Return if the PE image section is aligned. - - @param[in] SectionAlignment PE/COFF section alignment - @param[in] MemoryType PE/COFF image memory type - - @retval TRUE The PE image section is aligned. - @retval FALSE The PE image section is not aligned. -**/ -BOOLEAN -IsMemoryProtectionSectionAligned ( - IN UINT32 SectionAlignment, - IN EFI_MEMORY_TYPE MemoryType - ) -{ - UINT32 PageAlignment; - - switch (MemoryType) { - case EfiRuntimeServicesCode: - case EfiACPIMemoryNVS: - PageAlignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; - break; - case EfiRuntimeServicesData: - case EfiACPIReclaimMemory: - ASSERT (FALSE); - PageAlignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; - break; - case EfiBootServicesCode: - case EfiLoaderCode: - case EfiReservedMemoryType: - PageAlignment =3D EFI_PAGE_SIZE; - break; - default: - ASSERT (FALSE); - PageAlignment =3D EFI_PAGE_SIZE; - break; - } - - if ((SectionAlignment & (PageAlignment - 1)) !=3D 0) { - return FALSE; - } else { - return TRUE; - } -} - /** Free Image record. =20 @@ -404,7 +359,6 @@ ProtectUefiImage ( IMAGE_PROPERTIES_RECORD *ImageRecord; CHAR8 *PdbPointer; IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection; - BOOLEAN IsAligned; UINT32 ProtectionPolicy; =20 DEBUG ((DEBUG_INFO, "ProtectUefiImageCommon - 0x%x\n", LoadedImage)); @@ -470,8 +424,7 @@ ProtectUefiImage ( SectionAlignment =3D Hdr.Pe32Plus->OptionalHeader.SectionAlignment; } =20 - IsAligned =3D IsMemoryProtectionSectionAligned (SectionAlignment, Loaded= Image->ImageCodeType); - if (!IsAligned) { + if (SectionAlignment >=3D EFI_PAGE_SIZE) { DEBUG (( DEBUG_VERBOSE, "!!!!!!!! ProtectUefiImageCommon - Section Alignment(0x%x) is incor= rect !!!!!!!!\n", --=20 2.39.2 -=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 (#101137): https://edk2.groups.io/g/devel/message/101137 Mute This Topic: https://groups.io/mt/97586054/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-