diff options
author | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-09-14 14:04:18 +0100 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-10-12 14:22:03 +0100 |
commit | c0a839639b6a9baeaafe5dad8f7739e6176a2c62 (patch) | |
tree | 96cc93e15c427e41c6a2a2f52a293d8a6c38816c | |
parent | 0648dbf3a02cf39029c206d7e6003bb2ec1dce0c (diff) | |
download | glibc-c0a839639b6a9baeaafe5dad8f7739e6176a2c62.zip glibc-c0a839639b6a9baeaafe5dad8f7739e6176a2c62.tar.gz glibc-c0a839639b6a9baeaafe5dad8f7739e6176a2c62.tar.bz2 |
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.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c index 146850b..bd2588f 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; |