From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 004893955C80 for ; Tue, 3 May 2022 17:00:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 004893955C80 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-475-d3_A05WWMhm42s29RJ2zvg-1; Tue, 03 May 2022 13:01:07 -0400 X-MC-Unique: d3_A05WWMhm42s29RJ2zvg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5B0A13C025BA; Tue, 3 May 2022 17:00:45 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.113]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 809B0400DE5E; Tue, 3 May 2022 17:00:44 +0000 (UTC) From: Florian Weimer To: Szabolcs Nagy Cc: Szabolcs Nagy via Libc-alpha Subject: Re: [PATCH v3 1/2] aarch64: Use generic argv adjustment in ld.so [BZ #23293] References: <4a157fa95462503bd1b6c3218644a0334ae52325.1649854695.git.szabolcs.nagy@arm.com> <875ymmx26o.fsf@oldenburg.str.redhat.com> Date: Tue, 03 May 2022 19:00:42 +0200 In-Reply-To: (Szabolcs Nagy's message of "Tue, 3 May 2022 17:53:39 +0100") Message-ID: <878rrift51.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.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Tue, 03 May 2022 17:01:00 -0000 * Szabolcs Nagy: > The 05/03/2022 13:53, Florian Weimer via Libc-alpha wrote: >> * Szabolcs Nagy via Libc-alpha: >> >> > When an executable is invoked as >> > >> > ./ld.so [ld.so-args] ./exe [exe-args] >> > >> > then the argv is adujusted in ld.so before calling the entry point of >> > the executable so ld.so args are not visible to it. On most targets >> > this requires moving argv, env and auxv on the stack to ensure correct >> > stack alignment at the entry point. This had several issues: >> > >> > - The code for this adjustment on the stack is written in asm as part >> > of the target specific ld.so _start code which is hard to maintain. >> > >> > - The adjustment is done after _dl_start returns, where it's too late >> > to update GLRO(dl_auxv), as it is already readonly, so it points to >> > memory that was clobbered by the adjustment. This is bug 23293. >> > >> > - _environ is also wrong in ld.so after the adjustment, but it is >> > likely not used after _dl_start returns so this is not user visible. >> > >> > - _dl_argv was updated, but for this it was moved out of relro, which >> > changes security properties across targets unnecessarily. >> > >> > This patch introduces a generic _dl_start_args_adjust function that >> > handles the argument adjustments after ld.so processed its own args >> > and before relro protection is applied. It sets _dl_skip_args to 0 so >> > the existing adjustment in asm is not invoked. Each target has to >> > opt-in to use this new adjustment since some targets don't need it. >> > Once all targets are updated, _dl_argv declaration can be simplified. >> > >> > A new _dl_start_argptr was introduced because the original sp is not >> > passed to dl_main which now has to do the adjustments. >> > >> > -- >> > v2: >> > - use p != NULL, and a_type != AT_NULL >> > - remove the confusing paragraph from the commit message. >> >> Looks good to me. >> >> Reviewed-by: Florian Weimer > > thanks, meanwhile i started working on v4. > > that always does the new adjustment (even on targets that don't > require it) since ld.so invocation does not have to be optimal > but it's better to have consistent behaviour. > > then the bug is fixed everywhere (not just opt-in). > > is that an acceptable approach? Sorry, I would have to see the patch. But I generally appreciate consistency. Thanks, Florian