From: Szabolcs Nagy Date: Wed, 14 Sep 2022 13:04:18 +0000 (+0100) Subject: cheri: elf: make sure dlpi_phdr covers the load segments X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac41cba6b4853b22ce09697dfcfcd901b69f717a;p=thirdparty%2Fglibc.git 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. --- diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c index 146850b88a7..bd2588fae84 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;