From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 89AD0384D1AE; Wed, 12 Oct 2022 14:18:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89AD0384D1AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665584317; bh=94jDV1dYGAhGTHTVLF5qui027ZE97FqSboU8akD4Ykg=; h=From:To:Subject:Date:From; b=Ewnj3GH+mE7NAj1Sj1mNdEUOY1FLhjJTcXQTN3rUUxbUFPfyT4PmIjC20xiZ8ChkY loPD4QXsH2PonDy2bTdBPjLxcsKoAZ6KP/rbf8bypmlXBVZr6isnSb5QRRO9zp2hZ4 NOCqxdaxpxD9m8N0HaDkVWMA+ZVrX+hwVwWaR8IE= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Szabolcs Nagy To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] cheri: elf: make sure dlpi_phdr covers the load segments X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 0648dbf3a02cf39029c206d7e6003bb2ec1dce0c X-Git-Newrev: c0a839639b6a9baeaafe5dad8f7739e6176a2c62 Message-Id: <20221012141837.89AD0384D1AE@sourceware.org> Date: Wed, 12 Oct 2022 14:18:37 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c0a839639b6a9baeaafe5dad8f7739e6176a2c62 commit c0a839639b6a9baeaafe5dad8f7739e6176a2c62 Author: Szabolcs Nagy Date: Wed Sep 14 14:04:18 2022 +0100 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: --- elf/dl-iteratephdr.c | 5 +++++ 1 file changed, 5 insertions(+) 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;