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.133.124]) by sourceware.org (Postfix) with ESMTPS id 73E153857C5E for ; Tue, 18 Jan 2022 13:30:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 73E153857C5E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-450-aRfuWxvJNqKRxNfuuYG54g-1; Tue, 18 Jan 2022 08:30:15 -0500 X-MC-Unique: aRfuWxvJNqKRxNfuuYG54g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D502384BA43; Tue, 18 Jan 2022 13:30:13 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.198]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3ADCE2B5BD; Tue, 18 Jan 2022 13:29:59 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: Adhemerval Zanella via Libc-alpha , jma14 , Carlos O'Donell , John Mellor-Crummey Subject: Re: [PATCH v10 2/4] elf: Fix initial-exec TLS access on audit modules (BZ #28096) References: <20220117213136.1327053-1-adhemerval.zanella@linaro.org> <20220117213136.1327053-3-adhemerval.zanella@linaro.org> <87r195jn1p.fsf@oldenburg.str.redhat.com> <875yqhjiy4.fsf@oldenburg.str.redhat.com> <45c1d187-3ce8-975d-7d78-644be2f505d5@linaro.org> Date: Tue, 18 Jan 2022 14:29:58 +0100 In-Reply-To: <45c1d187-3ce8-975d-7d78-644be2f505d5@linaro.org> (Adhemerval Zanella's message of "Tue, 18 Jan 2022 10:26:26 -0300") Message-ID: <87wnixi33d.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.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-5.8 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, URIBL_BLACK 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, 18 Jan 2022 13:30:19 -0000 * Adhemerval Zanella: >>> So we need to avoid initialization only for the libc.so loading by >>> audit libraries, the default one should still be initialized (marked >>> as [INIT]). Later when new threads are created we need to initialized >>> everything. >> >> That's what I tried to express with the LM_ID_BASE check. > > The problem is 'map->l_ns == LM_ID_BASE && !init_tls' will not initilize > the required libc.so for main application during audit module loading. > With tst-audit21: > > 1593586: [rtld.c:965] load_audit_module > 1593586: [rtld.c:972] load_audit_module > 1593586: [rtld.c:2464] dl_main > 1593586: [../elf/dl-tls.c:605] map->l_name= map->l_ns=0 map->l_auditing=0 init_tls=0 > 1593586: [../elf/dl-tls.c:610] map->l_name=[...]/elf/tst-auditmod21a.so map->l_ns=1 map->l_auditing=1 init_tls=0 [INIT] > 1593586: [../elf/dl-tls.c:610] map->l_name=[...]/libc.so.6 map->l_ns=1 map->l_auditing=1 init_tls=0 [INIT] > 1593586: [../elf/dl-tls.c:605] map->l_name=[...]/libc.so.6 map->l_ns=0 map->l_auditing=0 init_tls=0 > 1593586: [../elf/dl-tls.c:627] > 1593586: [rtld.c:2466] dl_main > Segmentation fault (core dumped) Looks like the condition is simply reversed? [INIT] should only appear for map->l_ns == 0, right? Thanks, Florian