From 4472c7656d33969a05ea4d150fcbe921c6cf296a Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Fri, 4 Oct 2024 15:41:22 -0700 Subject: [PATCH] Fix calculation of segment end 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. --- runtime/libia2/ia2.c | 2 +- tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/libia2/ia2.c b/runtime/libia2/ia2.c index b86e16468..45da5c89b 100644 --- a/runtime/libia2/ia2.c +++ b/runtime/libia2/ia2.c @@ -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; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 69667c2cd..346326141 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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)