Skip to main content

compute_load_bounds

Function compute_load_bounds 

Source
fn compute_load_bounds(phdrs: &[Elf64Phdr]) -> Result<(u64, u64), &'static str>
Expand description

Compute total mapped bounds for all PT_LOAD segments.

Validates each PT_LOAD individually (alignment, size, address range) and additionally enforces, in the spirit of the FreeBSD post-CVE-2018-6924 hardening and the Linux loader, that :

  • PT_LOAD p_vaddr values appear in strictly non-decreasing order across the program header table;
  • PT_LOAD segments do not overlap in virtual memory after page-alignment (overlapping segments would alias user pages and produce undefined behaviour when one is later relaxed via RELRO/mprotect).

Returns the page-aligned (min_vaddr, max_vaddr) of the image.