Blame SOURCES/0010-pe-Fix-image-section-entry-point-validation.patch

9de34f
From 17f02339ed1be9e90738603fe3c95ae7dc300061 Mon Sep 17 00:00:00 2001
9de34f
From: Ilya Okomin <ilya.okomin@oracle.com>
9de34f
Date: Fri, 7 Oct 2022 16:52:08 -0400
9de34f
Subject: [PATCH 10/13] pe: Fix image section entry-point validation
9de34f
9de34f
Seen mokmanager image load failure '2 sections contain entry point'
9de34f
for shim built on Oracle Linux 9 aarch64. found_entry_point counter in
9de34f
handle_image() uses SizeOfRawData to calculate section boundary.
9de34f
PE spec defines VirtualSize for the total size of the section when loaded
9de34f
into memory. SizeOfRawData is the size of the section (for object files)
9de34f
or the size of the initialized data on disk.
9de34f
9de34f
Fix this issue by updating section in-memory size limit to VirtualSize.
9de34f
9de34f
Resolves: #517
9de34f
Signed-off-by: Ilya Okomin <ilya.okomin@oracle.com>
9de34f
---
9de34f
 pe.c | 2 +-
9de34f
 1 file changed, 1 insertion(+), 1 deletion(-)
9de34f
9de34f
diff --git a/pe.c b/pe.c
9de34f
index f94530a20c0..9a3679e16a1 100644
9de34f
--- a/pe.c
9de34f
+++ b/pe.c
9de34f
@@ -1259,7 +1259,7 @@ handle_image (void *data, unsigned int datasize,
9de34f
 		}
9de34f
 
9de34f
 		if (Section->VirtualAddress <= context.EntryPoint &&
9de34f
-		    (Section->VirtualAddress + Section->SizeOfRawData - 1)
9de34f
+		    (Section->VirtualAddress + Section->Misc.VirtualSize - 1)
9de34f
 		    > context.EntryPoint)
9de34f
 			found_entry_point++;
9de34f
 
9de34f
-- 
9de34f
2.37.1
9de34f