Skip to content

Commit

Permalink
Fix calculation of segment end
Browse files Browse the repository at this point in the history
ELF segment end computation was using the page-aligned start, not the virtual address start (which may not be page-aligned). This was resulting in not protecting the BSS section.
  • Loading branch information
rinon committed Oct 4, 2024
1 parent b3a74d7 commit 4472c76
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion runtime/libia2/ia2.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ int protect_pages(struct dl_phdr_info *info, size_t size, void *data) {
int access_flags = segment_flags_to_access_flags(phdr.p_flags);

Elf64_Addr start = (info->dlpi_addr + phdr.p_vaddr) & ~0xFFFUL;
Elf64_Addr seg_end = (start + phdr.p_memsz + 0xFFFUL) & ~0xFFFUL;
Elf64_Addr seg_end = (info->dlpi_addr + phdr.p_vaddr + phdr.p_memsz + 0xFFFUL) & ~0xFFFUL;
while (start < seg_end) {
Elf64_Addr cur_end = seg_end;

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if (NOT LIBIA2_AARCH64)
add_subdirectory(two_shared_ranges)
# TODO(#413): Fix these tests
add_subdirectory(heap_two_keys)
# add_subdirectory(three_keys_minimal)
add_subdirectory(three_keys_minimal)

# strange bug with indirect calls
add_subdirectory(read_config)
Expand Down

0 comments on commit 4472c76

Please sign in to comment.