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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 8BAED396ECBC for ; Wed, 7 Jul 2021 20:07:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8BAED396ECBC Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-U7Dt9ugMPaC6LDFpbGFidQ-1; Wed, 07 Jul 2021 16:07:18 -0400 X-MC-Unique: U7Dt9ugMPaC6LDFpbGFidQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA4F28030B0; Wed, 7 Jul 2021 20:07:16 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-5.ams2.redhat.com [10.36.115.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFC61189C7; Wed, 7 Jul 2021 20:07:15 +0000 (UTC) From: Florian Weimer To: Andreas Schwab Cc: Adhemerval Zanella via Libc-alpha , John Mellor-Crummey Subject: Re: [PATCH 1/5] elf: Fix audit regression References: <20210707182610.3940620-1-adhemerval.zanella@linaro.org> <20210707182610.3940620-2-adhemerval.zanella@linaro.org> <87k0m1j41u.fsf@igel.home> <87fswp28qc.fsf@oldenburg.str.redhat.com> Date: Wed, 07 Jul 2021 22:07:13 +0200 In-Reply-To: <87fswp28qc.fsf@oldenburg.str.redhat.com> (Florian Weimer's message of "Wed, 07 Jul 2021 22:02:19 +0200") Message-ID: <87a6mx28i6.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.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: Wed, 07 Jul 2021 20:07:20 -0000 * Florian Weimer: > * Andreas Schwab: > >> On Jul 07 2021, Adhemerval Zanella via Libc-alpha wrote: >> >>> @@ -771,7 +771,7 @@ dl_open_worker (void *a) >>> { >>> struct link_map *libc_map =3D GL(dl_ns)[args->nsid].libc_map; >>> #ifdef SHARED >>> - bool initial =3D libc_map->l_ns =3D=3D LM_ID_BASE; >>> + bool initial =3D libc_map !=3D NULL ? libc_map->l_ns =3D=3D LM_I= D_BASE : false; >> >> bool initial =3D libc_map !=3D NULL && libc_map->l_ns =3D=3D LM= _ID_BASE; > > True =E2=80=A6 but: > > This is only used by dlopen/dlmopen, right? And even if dlmopen is > called from an auditor (to load another libc), it is *never* the initial > libc in the base namespace. > > The actual base namespace libc is handled in elf/rtld.c:dl_main: > > /* Relocation is complete. Perform early libc initialization. This > is the initial libc, even if audit modules have been loaded with > other libcs. */ > _dl_call_libc_early_init (GL(dl_ns)[LM_ID_BASE].libc_map, true); > > And I think the dl_open_worker should mirror that and just do: > > if (!args->libc_already_loaded) > /* This is never the initial libc because it has been loaded via > dlmopen. */ > _dl_call_libc_early_init (libc_map, false); Eh, or rather: if (!args->libc_already_loaded) { struct link_map *libc_map =3D GL(dl_ns)[args->nsid].libc_map; /* This is never the initial libc because it has been loaded via dlmopen. */ _dl_call_libc_early_init (libc_map, false); } (_dl_call_libc_early_init checks for a null link map.) Thanks, Florian