From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id 6E30C3857C4A for ; Tue, 18 Jan 2022 13:46:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6E30C3857C4A Received: by mail-oi1-x22a.google.com with SMTP id s9so28424839oib.11 for ; Tue, 18 Jan 2022 05:46:25 -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:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=jeK7Ws1JVhyLgAo2HTrvRYzQo8RTfMngPxPv/bEGDjs=; b=aD/MGMYOrXM9PPnUvPhKpWAvxvgz0C4A1R8FtArE7XWz6tgfd6kIREA0zO5vhM5hsA IJG4OPWjmAII4axDU/ClbAv0e78jS10GGz6O/vm2ZQKfDSeGeoVXirbmJK5/rgoZ7RTA RnED59j8Ij/JjsIE29pQCBfGeWNZoJIKfZe+Dn8U6pkv5x79OGXkLGTXU0g0EiE4nnNJ +Z7RtaIB/y7as8ORCFeQtBlwRHMpTNNKW8LmB/zvSXMiGXqZq3YvXWSHAivDKNvUmLjo XRAZNJhde5D6/g6/OYFLQWCfx4p9jLYaZSXQYiYkgonQUtGjqfXftJy5jlAulI8bbBe8 JgcA== X-Gm-Message-State: AOAM533VA+r6DTfLbsTQa16XmmRLsUPCwxlKWIRfnCvMbEGSoaNRMXUZ tmtEVWwGq8W6SnakaRU2CDFKeWY2oqpyYg== X-Google-Smtp-Source: ABdhPJzSLSlcFZK2irWNmTBLFa1oCQnQiyK7oLvB2n+hzhYdRgK6T3VIaEgQHnLGDyPaRkOMUIKB4g== X-Received: by 2002:a54:4097:: with SMTP id i23mr15048764oii.115.1642513584825; Tue, 18 Jan 2022 05:46:24 -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 o130sm8218235oig.26.2022.01.18.05.46.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jan 2022 05:46:24 -0800 (PST) Message-ID: <4e8dd46d-541b-7878-016f-6c7445d75abd@linaro.org> Date: Tue, 18 Jan 2022 10:46:21 -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 From: Adhemerval Zanella 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> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.1 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:46:29 -0000 On 18/01/2022 10:33, Adhemerval Zanella wrote: > > > 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. Yes, it is correct. I will remove the 'l_auditing' field.