From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 6B5A63857C60 for ; Tue, 18 Jan 2022 13:33:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6B5A63857C60 Received: by mail-ot1-x329.google.com with SMTP id z25-20020a0568301db900b005946f536d85so15159517oti.9 for ; Tue, 18 Jan 2022 05:33:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=GcQUsGqkXSK9lwBAaMtzXYsLGYqHJwFsprYBEC0yYNk=; b=LQtscjV0HvEPVKJBUEorIh9KyBFb+pSN2l4HKcb06sTiY2nJUZW4V6zzmJnlWVKUB7 QodhnVkCeJAtLk9/0j/yIK90Us+uWitbfN7iigArMfL08Ab92Sc0+ld/KkGV1oKgw2gf PbeN3GataEEoNU32CMYPN6XZFepLoJvjJnF51u2tv7YlwhCxlOlfQQSLCAtnwxxhk5Kh iSONnvKw0npyd69lil/k7P7IhPUC7QSvM5yNtChwcdov2LD/BsuwKZBr8npm5tL9uErm ta38zjT1p9viETZU88wydPoHIc1k2Qx0OQikjEFyBLI/3w6z7sYl+UDfTSd1GeXrgJ/r c0Xw== X-Gm-Message-State: AOAM533UA4rdYsDNAdA6/fBkIXB69AgKWdUcI42TEPCl3PWFhFA0VkFX ZUDS6r7lBsXh/QgeF0Upt42xsA== X-Google-Smtp-Source: ABdhPJwelkcys/rYGkTGI1Zkz4+iu43bgygZapgGkdEA+yCpppTaS1EYTwVemHa+2rAPbCV/25ADgQ== X-Received: by 2002:a9d:1b46:: with SMTP id l64mr20281925otl.215.1642512821757; Tue, 18 Jan 2022 05:33:41 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:989a:d7f1:4df2:e2ef:5281? ([2804:431:c7cb:989a:d7f1:4df2:e2ef:5281]) by smtp.gmail.com with ESMTPSA id r25sm5959378ota.59.2022.01.18.05.33.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jan 2022 05:33:41 -0800 (PST) Message-ID: Date: Tue, 18 Jan 2022 10:33:38 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v10 2/4] elf: Fix initial-exec TLS access on audit modules (BZ #28096) Content-Language: en-US To: Florian Weimer Cc: Adhemerval Zanella via Libc-alpha , jma14 , Carlos O'Donell , John Mellor-Crummey 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> <87wnixi33d.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella In-Reply-To: <87wnixi33d.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=no 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:33:43 -0000 On 18/01/2022 10:29, Florian Weimer wrote: > * 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? Hum, 'if (map->l_ns != LM_ID_BASE && !init_tls)' seems correct indeed. Let me run a full make check to certify it.