about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2022-09-14 14:04:18 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-11-22 14:31:25 +0000
commit3e833b93fd62b42d02b65c51d081b10afc23e389 (patch)
tree084c0e8fafe65fc6a6ba971f6c9d7ed9ede2f803
parent9d6a71514dee3ec6bdc6977339de5d31cbef8c4c (diff)
downloadglibc-3e833b93fd62b42d02b65c51d081b10afc23e389.tar.gz
glibc-3e833b93fd62b42d02b65c51d081b10afc23e389.tar.xz
glibc-3e833b93fd62b42d02b65c51d081b10afc23e389.zip
cheri: elf: make sure dlpi_phdr covers the load segments
In dl_iterate_phdr phdr is the only capability passed to the callback
that may be used to derive pointers of the elf module, so ensure it
has wide bounds.
-rw-r--r--elf/dl-iteratephdr.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c
index 146850b88a..bd2588fae8 100644
--- a/elf/dl-iteratephdr.c
+++ b/elf/dl-iteratephdr.c
@@ -69,7 +69,12 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
       info.dlpi_addr = l->l_real->l_addr;
 #endif
       info.dlpi_name = l->l_real->l_name;
+#ifdef __CHERI_PURE_CAPABILITY__
+      ElfW(Addr) phdr = (ElfW(Addr)) l->l_real->l_phdr - l->l_real->l_addr;
+      info.dlpi_phdr = (const void *) dl_rx_ptr (l->l_real, phdr);
+#else
       info.dlpi_phdr = l->l_real->l_phdr;
+#endif
       info.dlpi_phnum = l->l_real->l_phnum;
       info.dlpi_adds = GL(dl_load_adds);
       info.dlpi_subs = GL(dl_load_adds) - nloaded;