From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 2CE88385151D; Thu, 27 Oct 2022 13:55:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CE88385151D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666878915; bh=tU32As32zi7Rltdcpv/dZt1ABlgVyDmC5YZL73ycJgI=; h=From:To:Subject:Date:From; b=iJE7tthSFh1fsHJ7wXXJSbFmn6WaRGVInqSe9HlNb1t3d9PZx4IlvnlF6e+Jm/abM Qbo2rxEv84FGRfGgqSEaXmD643MQs4Da/uZ8tpqSfphFQileDsXAtxHlMQYPhfFXHA Ejg9WlN8uV63omaml5NlnGr+POe6n+tqBTAoEpvQ= 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: add an RW capability to link_map X-Act-Checkin: glibc X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/arm/morello/main X-Git-Oldrev: 15458dd00f538c02becb3ec01192adf0e4a58a9d X-Git-Newrev: c511eea647f5f4ccf65a817da746bb10f4bbc2cf Message-Id: <20221027135515.2CE88385151D@sourceware.org> Date: Thu, 27 Oct 2022 13:55:14 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c511eea647f5f4ccf65a817da746bb10f4bbc2cf commit c511eea647f5f4ccf65a817da746bb10f4bbc2cf Author: Szabolcs Nagy Date: Mon Aug 8 09:22:44 2022 +0100 cheri: elf: add an RW capability to link_map For each module keep an RX and an RW root capability. Use the existing l_map_start for RX (covering all load segments) and add l_rw_start for RW (covering all writable load segments). For relocation processing, we also need individual RW ranges to decide which objects need to be derived from RW and RX capabilities. In practice most modules have exactly one RW segment and it's unlikely that any module needs more than four distinct ranges to tightly cover the RW mappings. Only added on CHERI targets so always has to be used behind ifdef. Diff: --- include/link.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/link.h b/include/link.h index 7632ae33d3..79c8a57690 100644 --- a/include/link.h +++ b/include/link.h @@ -256,6 +256,18 @@ struct link_map ElfW(Addr) l_map_end; /* End of the executable part of the mapping. */ ElfW(Addr) l_text_end; +#ifdef __CHERI_PURE_CAPABILITY__ + /* Writable part of the mapping (may have non-writable holes). */ + elfptr_t l_rw_start; +# define DL_MAX_RW_COUNT 4 + /* Writable ranges: objects are writable in these ranges. */ + int l_rw_count; + struct rw_range + { + ElfW(Addr) start; + ElfW(Addr) end; + } l_rw_range[DL_MAX_RW_COUNT]; +#endif /* Default array for 'l_scope'. */ struct r_scope_elem *l_scope_mem[4];