summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAsherah Connor <ashe@kivikakk.ee>2021-02-09 06:19:48 +0000
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2021-02-14 10:34:15 +0100
commit9d30a941cce5ed055da18398f4deba18830d00d6 (patch)
tree0300604aeca5a4aaf85034fc5f792a32ede1b511
parent7c82e12cc4e9e25d7c89fe15bfeec4e9b0bb2b4d (diff)
downloadu-boot-9d30a941cce5ed055da18398f4deba18830d00d6.tar.gz
u-boot-9d30a941cce5ed055da18398f4deba18830d00d6.tar.xz
u-boot-9d30a941cce5ed055da18398f4deba18830d00d6.zip
efi_loader: don't load beyond VirtualSize
PE section table entries' SizeOfRawData must be a multiple of FileAlignment, and thus may be rounded up and larger than their VirtualSize. We should not load beyond the VirtualSize, which is "the total size of the section when loaded into memory" -- we may clobber real data at the target in some other section, since we load sections in reverse order and sections are usually laid out sequentially. Signed-off-by: Asherah Connor <ashe@kivikakk.ee> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
-rw-r--r--lib/efi_loader/efi_image_loader.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index d4dd9e9433..f53ef367ec 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -843,7 +843,7 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
sec->Misc.VirtualSize);
memcpy(efi_reloc + sec->VirtualAddress,
efi + sec->PointerToRawData,
- sec->SizeOfRawData);
+ min(sec->Misc.VirtualSize, sec->SizeOfRawData));
}
/* Run through relocations */