mirror of
https://github.com/systemd/systemd.git
synced 2026-08-12 22:17:19 +00:00
boot: bound PE section VirtualSize before zeroing the inner kernel
The inner-kernel section loader checks VirtualAddress + SizeOfRawData against kernel_size_in_memory (for the memcpy), but the memzero right after it clears up to VirtualAddress + VirtualSize, and VirtualSize is only constrained to be >= SizeOfRawData. Reject a VirtualAddress + VirtualSize that overflows or exceeds kernel_size_in_memory, mirroring the existing SizeOfRawData checks. Follow-up forcab9c7b5a4(cherry picked from commitfeeba8fa3b) (cherry picked from commit0f3dd7ab02) (cherry picked from commit2889746af2)
This commit is contained in:
@@ -289,6 +289,10 @@ EFI_STATUS linux_exec(
|
||||
return log_error_status(EFI_LOAD_ERROR, "Section would write outside of memory");
|
||||
if (h->SizeOfRawData > h->VirtualSize)
|
||||
return log_error_status(EFI_LOAD_ERROR, "Invalid PE section, raw data size is greater than virtual size");
|
||||
if (UINT32_MAX - h->VirtualAddress < h->VirtualSize)
|
||||
return log_error_status(EFI_LOAD_ERROR, "Invalid PE section, VirtualSize + VirtualAddress overflows");
|
||||
if (h->VirtualAddress + h->VirtualSize > kernel_size_in_memory)
|
||||
return log_error_status(EFI_LOAD_ERROR, "Section virtual size would write outside of memory");
|
||||
if (UINT32_MAX - h->PointerToRawData < h->SizeOfRawData)
|
||||
return log_error_status(EFI_LOAD_ERROR, "Invalid PE section, PointerToRawData + SizeOfRawData overflows");
|
||||
if (h->PointerToRawData + h->SizeOfRawData > kernel->iov_len)
|
||||
|
||||
Reference in New Issue
Block a user