From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x92b.google.com (mail-ua1-x92b.google.com [IPv6:2607:f8b0:4864:20::92b]) by sourceware.org (Postfix) with ESMTPS id 963403858C27 for ; Wed, 13 Oct 2021 15:12:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 963403858C27 Received: by mail-ua1-x92b.google.com with SMTP id h19so5153202uax.5 for ; Wed, 13 Oct 2021 08:12:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=oYFPc6A4aHpUuxjuMpqdcPtF+PkM4q/aEfWb8p4A58U=; b=xiKCJrpmzVhsyww8CkbicPOCw199xSZuWOkA3c8FO0kepDymvqseejqywRu9apkAHW zrIARAq/ErUlMr7FuQFQp8l0Fx8oLWmN1/tCt4IvzS3To/OmM03VqINJMko+29VC4DN/ V37Uooj/3kiuVQcVsikPGi/awB7SocHPyHICB9jiQiZSkTRYqtISdv982yCBdV20Um03 ITTE4Fa/sDRyI3oBYLzYNqkUp5BG+O90jYWhLXJqEuTIlxHiUXus6DNHoSBVJyFVkHbE 2UORzgyngYvdPcTfEA7yWc06lZ87cSYtmvk3T1T9U3TgzjiTuh0PprcS18iqZ4aQmVfO f/Lg== X-Gm-Message-State: AOAM531kKG9YVvWU/asffQokwqE1jfGa+/6rDBCHhEdCdbLqnrhUWvvA S7TiVTrhwfHZQ7WrLokx675lLg== X-Google-Smtp-Source: ABdhPJx/IQR24A4es6RMbA2pOsSDgDe00DovG0MHJ7RivJ/pU9D1RpPfHVwKxtJBwJD3nxaoFjweOA== X-Received: by 2002:ab0:5b89:: with SMTP id y9mr29759490uae.47.1634137963049; Wed, 13 Oct 2021 08:12:43 -0700 (PDT) Received: from ?IPv6:2804:431:c7ca:c6c7:4188:d67:fac:8f63? ([2804:431:c7ca:c6c7:4188:d67:fac:8f63]) by smtp.gmail.com with ESMTPSA id p8sm6271469vke.11.2021.10.13.08.12.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Oct 2021 08:12:42 -0700 (PDT) Subject: Re: segfaults in _dl_fixup since 4af6982 To: Manuel Lauss Cc: Szabolcs Nagy , libc-alpha@sourceware.org, Fangrui Song References: <20211013091845.GP2700@arm.com> From: Adhemerval Zanella Message-ID: <874b006a-ca68-3fca-1ea7-d30c0bd41248@linaro.org> Date: Wed, 13 Oct 2021 12:12:40 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Wed, 13 Oct 2021 15:12:45 -0000 On 13/10/2021 11:51, Manuel Lauss wrote: > This patch works on x64_64 now, the 32bit x86 build breaks. Thanks for checking it, I know what I got wrong in first place. The 32-bit break is expected, I added only x86_64 support. I will prepare a patch to work on all architectures and run make check on the architecture I have available. > > Manuel > > On Wed, Oct 13, 2021 at 4:41 PM Adhemerval Zanella > wrote: >> >> >> >> On 13/10/2021 10:55, Manuel Lauss wrote: >>> Applied this patch on top of git head, still same error. >>> >>> Manuel >> >> Sigh, it seems I got the elf_get_dynamic_info() sideways. Could you check >> this slight modified patch? It is x86_64 only for now. >> >> And I am puzzled why I am not seeing any issues in the environments I am >> checking... >> >>> >>> On Wed, Oct 13, 2021 at 3:47 PM Adhemerval Zanella >>> wrote: >>>> >>>> >>>> >>>> On 13/10/2021 08:56, Adhemerval Zanella wrote: >>>>> >>>>> >>>>> On 13/10/2021 08:44, Adhemerval Zanella wrote: >>>>>> >>>>>> >>>>>> On 13/10/2021 07:58, Adhemerval Zanella wrote: >>>>>>> >>>>>>> >>>>>>>> On 13 Oct 2021, at 06:19, Szabolcs Nagy wrote: >>>>>>>> >>>>>>>> The 10/13/2021 08:42, Manuel Lauss via Libc-alpha wrote: >>>>>>>>> [resend with libc-alpha] >>>>>>>>> Hi Adhemerval, >>>>>>>>> >>>>>>>>> Your recent commit 4af6982e4c9fc465ffb7a54b794aaaa134241f05 ("elf: Fix >>>>>>>>> elf_get_dynamic_info definition") causes a lot (but not all) of my >>>>>>>>> applications >>>>>>>>> to segfault: >>>>>>>>> >>>>>>>>> Program received signal SIGSEGV, Segmentation fault. >>>>>>>>> _dl_fixup (l=, reloc_arg=) at dl-runtime.c:146 >>>>>>>>> 146 return elf_machine_fixup_plt (l, result, refsym, sym, reloc, >>>>>>>>> rel_addr, value); >>>>>>>>> (gdb) bt >>>>>>>>> #0 _dl_fixup (l=, reloc_arg=) at dl-runtime.c:146 >>>>>>>>> #1 0x00007ffff7fe251a in _dl_runtime_resolve_xsavec () at >>>>>>>>> ../sysdeps/x86_64/dl-trampoline.h:126 >>>>>>>>> #2 0x000055555555634e in main (argc=1, argv=0x7fffffffd568) at >>>>>>>>> iconvconfig.c:288 >>>>>>>>> >>>>>>>>> Reverting the commit fixes the problem. Gcc, python, etc seem to be >>>>>>>>> not affected, while for example iconvconfig and openssh are. >>>>>>>> >>>>>>>> on aarch64 buildbot i see >>>>>>>> >>>>>>>> FAIL: nptl/test-cond-printers >>>>>>>> FAIL: nptl/test-condattr-printers >>>>>>>> FAIL: nptl/test-mutex-printers >>>>>>>> FAIL: nptl/test-mutexattr-printers >>>>>>>> FAIL: nptl/test-rwlock-printers >>>>>>>> FAIL: nptl/test-rwlockattr-printers >>>>>>>> >>>>>>>> and >>>>>>>> >>>>>>>> $ cat nptl/test-cond-printers.out >>>>>>>> Error: Response does not match the expected pattern. >>>>>>>> Command: start >>>>>>>> Expected pattern: main >>>>>>>> Response: Temporary breakpoint 1 at 0xac4: file test-cond-printers.c, line 36. >>>>>>>> Starting program: /work/glibc-aarch64-linux/build/build/nptl/test-cond-printers >>>>>>>> >>>>>>>> Program received signal SIGSEGV, Segmentation fault. >>>>>>>> _dl_fixup (l=, reloc_arg=) at dl-runtime.c:146 >>>>>>>> 146 return elf_machine_fixup_plt (l, result, refsym, sym, reloc, rel_addr, value); >>>>>>>> (gdb) >>>>>>>> >>>>>>>> >>>>>>>> it seems to be a bind-now pie where PLT relocs are not yet >>>>>>>> processed when __libc_start_main is called but PLTGOT is >>>>>>>> already marked readonly so _dl_fixup crashes. >>>>>>> >>>>>>> I will check this out. >>>>>>> >>>>>> >>>>>> I am trying to reproduce it on aarch64-linux-gnu without much success (using >>>>>> gcc 11.1.1 20210702 and ld 2.36.1.20210702). Neither ssh or iconvconfig fails >>>>>> when running through the built glibc (using ubuntu 21.04 one). >>>>>> >>>>>> Any idea on how to reproduce it? >>>>>> >>>>> >>>>> Sigh... I think this is another fallback of RTLD_BOOTSTRAP. I fixed the >>>>> elf_get_dynamic_info(), but there are lot of more usage that changes >>>>> the semantic of the nested functions (specifically on elf/do-rel.h >>>>> and dl-machine.h). >>>>> >>>>> I will try to fix, I think we should define RTLD_BOOTSTRAP before the >>>>> fist dynamic-link.h in rtld. >>>>> >>>> >>>> Could you check if the attached patch fixes it? The rtld.c now should get >>>> all the required function with the expected semantic (RTLD_BOOTSTRAP defined).