Kernel: Fix rounding of PT_LOAD mappings in sys$execve()
We were not rounding the mappings down/up correctly, which could lead to executables missing the last 4 KB of text and/or data.
This commit is contained in:
parent
4c7f486f39
commit
423ed53396
Notes:
sideshowbarker
2024-07-18 21:28:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/423ed533965
1 changed files with 5 additions and 1 deletions
|
@ -340,7 +340,11 @@ static KResultOr<LoadResult> load_elf_object(NonnullOwnPtr<Space> new_space, Fil
|
|||
if (program_header.is_writable())
|
||||
prot |= PROT_WRITE;
|
||||
auto region_name = String::formatted("{} (data-{}{})", elf_name, program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : "");
|
||||
auto range = new_space->allocate_range(program_header.vaddr().offset(load_offset), program_header.size_in_memory());
|
||||
|
||||
auto range_base = VirtualAddress { page_round_down(program_header.vaddr().offset(load_offset).get()) };
|
||||
auto range_end = VirtualAddress { page_round_up(program_header.vaddr().offset(load_offset).offset(program_header.size_in_memory()).get()) };
|
||||
|
||||
auto range = new_space->allocate_range(range_base, range_end.get() - range_base.get());
|
||||
if (!range.has_value()) {
|
||||
ph_load_result = ENOMEM;
|
||||
return IterationDecision::Break;
|
||||
|
|
Loading…
Add table
Reference in a new issue