From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29071 invoked from network); 5 Jan 2022 14:01:15 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 5 Jan 2022 14:01:15 -0000 Received: (qmail 17658 invoked by uid 550); 5 Jan 2022 14:01:12 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 17638 invoked from network); 5 Jan 2022 14:01:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641391260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GD3Kw1tkNaHrx/hi3DPuGNN5g4qfwt2FwmSMb6Typg8=; b=JAYQwSvlrUjMyqa3PX9f+vfT0FIH87y5DALWv7w38UFpI1IWGvI/GzHYd2ImHoDKEWN3Iu hUV9NzF713XSvn/HTkkjDQULJF+kCOMh23eZ/KuS+T/mn+b3EQdUvSEPY9l9UBpG0leIxI S31GJvu/lIh0pgKXE5EgrRu78U5p+FY= X-MC-Unique: B0tXq4z3NGi383k9CjfEAQ-1 From: Florian Weimer To: Rich Felker Cc: Nihal Jere , musl@lists.openwall.com References: <20220104214211.GC7074@brightrain.aerifal.cx> <8735m2ftmu.fsf@oldenburg.str.redhat.com> <20220105134957.GF7074@brightrain.aerifal.cx> Date: Wed, 05 Jan 2022 15:00:53 +0100 In-Reply-To: <20220105134957.GF7074@brightrain.aerifal.cx> (Rich Felker's message of "Wed, 5 Jan 2022 08:49:58 -0500") Message-ID: <87pmp6e0yy.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=fweimer@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Subject: Re: [musl] Dynamic linker segfault * Rich Felker: > On Wed, Jan 05, 2022 at 09:56:25AM +0100, Florian Weimer wrote: >> * Rich Felker: >> >> > This is a malformed program file not compatible with the machine page >> > size (4k). Arguably it should be detected as p_align < PAGESIZE -- in >> > a sense, p_align for LOAD segments is the maximum supported page size >> > for the program file, and machines not capable of providing a page >> > size that small can't map/run it. In theory the loader could allow >> > this if all the differences between segments satisfy the right >> > congruences and have matching permissions where the maps would >> > overlap, but I'm not sure that's useful. >> >> We've been looking at this on the glibc side recently. The use case is >> supporting large data alignments (greater than the kernel page size) >> while not pessimizing multi-page-size targets such as POWER and AArch64. > > I'm not clear how it pessimizes these targets (beyond what's > fundamentally necessary) unless you're artificially aligning segment > contents on disk to a large alignment boundary to prevent over-mapping > (undermining separate-code for example). And if you're doing that, you > need the full alignment anyway to support machines with larger > hardware pagesize. Otherwise you'd get back the overmapping (and > unwanted perission exposure). Hmm. Maybe I should rephrase: With a p_align < PAGESIZE check in place, portable binaries need to use the value 65536. When running with page size 4096, the loader cannot know whether p_align was set to this value merely to satisfy the p_align < PAGESIZE check, or because there is actually some section alignment that requires 65536 byte alignment. There is no kernel interface to request 65536 byte alignment, so the loader has to do extra work to satisfy this request. And in the first case (no actual 65536 byte alignment requirement), that work is unnecessary. > In any case, do you know if this test file is somehow related to that > work, or is it just a guess? It doesn't seem to be related to me since > it's essentially a "pageless" mapping setup. The glibc test seems to be just buggy: First we verify p_align against the page size, then we use that p_align value to check the alignment of the PT_LOAD segment (mainly file offset congruency). The p_align check against the page size looks completely optional to me if we check file offset congruency directly against the run-time page size. The ELF specification explicitly describes the p_align values 0 and 1 as valid, indicating no alignment constraint. So a p_align < PAGESIZE check is buggy in that regard as well. This also conflicts with your interpretation as p_align as the maximum supported page size. Thanks, Florian