From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id 4ACC53857C4A for ; Tue, 18 Jan 2022 13:47:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4ACC53857C4A Received: by mail-oi1-x22e.google.com with SMTP id s127so28502150oig.2 for ; Tue, 18 Jan 2022 05:47:27 -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=iXxn6l/N6SxRZ6TpklaQkXlSCg8QIGG+kKb1vlp24ac=; b=p5WNZDv/an2BkU77JszMHJjSZFllBPcKauc3lw7lWZj2BfzIbBtjU1wZ0d2gEnI/hP PdYsyv/dozDtjTGYI4DIdwDEZbw8YhZvbxZBcM+Q4s5ayVc+PZGt2CpF287i/BYIH+GV P+RheI9fR1PLDYaWnG2kUFFlelnhrg6OuKf/1cVtp8aLqp9mL9UgT3iOkBDvJXvEoxwU yfNty1LXoDCvjd4KvsrRgb8f7KF40+8Z9/qZuDC6+avP3qy/brirPfQyjrfpQCuPMD1I rxRA3v6PER2W8CRQRDS5sHxBzhkZd6W29IANL1ntrhx3q27DYTAr3519yq68gNDzkR/u N5dA== X-Gm-Message-State: AOAM532gEAbPRURywjGuFRzuanM1EBwNhe1ogGooPJ8x0Y0a0eD3DGNU JZ9vIkJX7fYrOLZU/EBOODkB0w== X-Google-Smtp-Source: ABdhPJz2oLm5NQ/5fmqaBPDJacN1qrKMrtkYYV2j8JwXtcAUxtUQ7j0eL2QX4RchhGWIDend+9l2rA== X-Received: by 2002:a05:6808:1248:: with SMTP id o8mr21980579oiv.157.1642513645857; Tue, 18 Jan 2022 05:47:25 -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 n34sm6901768ooi.7.2022.01.18.05.47.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jan 2022 05:47:25 -0800 (PST) Message-ID: Date: Tue, 18 Jan 2022 10:47:23 -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> <4e8dd46d-541b-7878-016f-6c7445d75abd@linaro.org> In-Reply-To: <4e8dd46d-541b-7878-016f-6c7445d75abd@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 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:47:28 -0000 On 18/01/2022 10:46, Adhemerval Zanella wrote: > > > 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. Oops, the 'l_auditing' usage I meant.