From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bumble.elm.relay.mailchannels.net (bumble.elm.relay.mailchannels.net [23.83.212.25]) by sourceware.org (Postfix) with ESMTPS id D03203858D3C for ; Thu, 16 Sep 2021 06:04:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D03203858D3C X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id DAA8C225FE; Thu, 16 Sep 2021 06:04:50 +0000 (UTC) Received: from pdx1-sub0-mail-a63.g.dreamhost.com (100-96-17-248.trex-nlb.outbound.svc.cluster.local [100.96.17.248]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 16DE4226E5; Thu, 16 Sep 2021 06:04:50 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a63.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.17.248 (trex/6.4.3); Thu, 16 Sep 2021 06:04:50 +0000 X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Absorbed-Harbor: 445059aa090de6c5_1631772290411_1620606365 X-MC-Loop-Signature: 1631772290410:4288438922 X-MC-Ingress-Time: 1631772290410 Received: from pdx1-sub0-mail-a63.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a63.g.dreamhost.com (Postfix) with ESMTP id C197D88BD3; Wed, 15 Sep 2021 23:04:49 -0700 (PDT) Received: from [192.168.1.174] (unknown [1.186.224.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a63.g.dreamhost.com (Postfix) with ESMTPSA id BAB2587C0A; Wed, 15 Sep 2021 23:04:46 -0700 (PDT) Subject: Re: [PATCH] ld.so: Handle read-only dynamic section gracefully [BZ #28340] To: Florian Weimer Cc: "H.J. Lu" , GNU C Library References: <20210914190919.1728320-1-siddhesh@sourceware.org> <9d0f8dcc-35d4-d87a-b3b0-c006fdfe482f@sourceware.org> <877dfhp1lc.fsf@oldenburg.str.redhat.com> <5d9a36c7-879a-3b33-df2a-83e3c5263742@sourceware.org> <87wnnhnkcp.fsf@oldenburg.str.redhat.com> X-DH-BACKEND: pdx1-sub0-mail-a63 From: Siddhesh Poyarekar Message-ID: Date: Thu, 16 Sep 2021 11:34:41 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <87wnnhnkcp.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3489.7 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Sep 2021 06:04:56 -0000 On 9/16/21 11:16 AM, Florian Weimer wrote: > * Siddhesh Poyarekar: > >> On 9/16/21 10:18 AM, Florian Weimer wrote: >>> * H. J. Lu: >>> >>>> There is nothing wrong with read-only dynamic segment. >>> A relocated DYNAMIC array is part of the ABI for !DL_RO_DYN_SECTION. >>> ELF requires that DT_STRTAB is present. DT_STRTAB needs relocation. >>> This means that for !DL_RO_DYN_SECTION, the dynamic segment cannot be in >>> a read-ony LOAD segment for a valid ELF file. >> >> I think what H. J. means here is that we just never adjust DT_STRTAB >> and add l_addr to it every time we use it. > > I understood that. But applications expected that DT_STRTAB value has > been relocated. > > See the discussion about the setting of DL_RO_DYN_SECTION for RISC-V and > libphobos. Quoting libphobos/libdruntime/gcc/sections/elf.d: > > | if (dyn.d_tag == DT_STRTAB) > | { > | version (CRuntime_Musl) > | strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate > | else version (linux) > | { > | // This might change in future glibc releases (after 2.29) as dynamic sections > | // are not required to be read-only on RISC-V. This was copy & pasted from MIPS > | // while upstreaming RISC-V support. Otherwise MIPS is the only arch which sets > | // in glibc: #define DL_RO_DYN_SECTION 1 > | version (RISCV_Any) > | strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate > | else version (MIPS_Any) > | strtab = cast(const(char)*)(info.dlpi_addr + dyn.d_un.d_ptr); // relocate > | else > | strtab = cast(const(char)*)dyn.d_un.d_ptr; > | } Yeah you're right, basically anything that uses dl_iterate_phdr and subsequently reaches the DYNAMIC segment will be affected by this change. So if we have to support read-only DYNAMIC then we must allocate dynamically and relocate there, like we do for vdso. Siddhesh