From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by sourceware.org (Postfix) with ESMTPS id 453B23858D39 for ; Mon, 15 Nov 2021 14:20:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 453B23858D39 Received: by mail-qt1-x82c.google.com with SMTP id 8so6031633qtx.5 for ; Mon, 15 Nov 2021 06:20:18 -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=C6Rdd8ybbaAfeE46QN8UYQiuB17lGFtM9XeVz09BEpY=; b=jzos+sCaAfHXqtPxX4b1ffUTngEbN05V+2dTgebb6/vDvlgzidSh6c15E5aIjL47g9 xi7GcZjWs89KThsVovu1EGdoWvsGI0Um4ivaXsh8tRfLrDOitpmdfTMwEoT1fUox7qWO r1N9LTOC91j7exvfUVd0hXnnyHurbv7/SEw4ECIJ8FuCLRBjH1WjSIhcPqzGgvIdH0k0 ffTZh3baDk7Gn6cq/swmsdeqX3nxfLu6GLkv1kybkB5Q+e1MBrXYhDcU59/AWZrVmFas 031FekCv/KSTO9qxmRYhAQFaWhaQgNpIX7DTWvZI5QRtJjPtdcZUrFpqCqeKmlQLMHYC G3Jg== X-Gm-Message-State: AOAM532zLuQxjezKENHU16wutHE89VbI8mJtWGtfWFA6iPzWmSeSLLxY 5FaM4HwGTZNrtYrEBlIpiFl8Vg== X-Google-Smtp-Source: ABdhPJzsfXgsSKxXAmav55Yx8mYGebLfJopiP1twOY/PB36h5gzPpBWgWxybTsmuhvMLva/FioqYRQ== X-Received: by 2002:ac8:7d46:: with SMTP id h6mr25903704qtb.379.1636986016502; Mon, 15 Nov 2021 06:20:16 -0800 (PST) Received: from ?IPV6:2804:431:c7ca:66dc:13f5:e2fb:5a0d:90? ([2804:431:c7ca:66dc:13f5:e2fb:5a0d:90]) by smtp.gmail.com with ESMTPSA id p16sm7826719qtx.92.2021.11.15.06.20.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Nov 2021 06:20:16 -0800 (PST) Message-ID: <0ab5764e-1d94-64e9-ea9f-87539bbb1245@linaro.org> Date: Mon, 15 Nov 2021 11:20:13 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH v5 18/22] elf: Issue la_symbind() for bind-now (BZ #23734) Content-Language: en-US To: Florian Weimer Cc: libc-alpha@sourceware.org, John Mellor-Crummey , Ben Woodard References: <20211109183347.2943786-1-adhemerval.zanella@linaro.org> <20211109183347.2943786-19-adhemerval.zanella@linaro.org> <87czn6wq02.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella In-Reply-To: <87czn6wq02.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Mon, 15 Nov 2021 14:20:19 -0000 On 11/11/2021 14:39, Florian Weimer wrote: > * Adhemerval Zanella: > >> The audit callback is not called for binaries built with -Wl,-z,now or >> when LD_BIND_NOW=1 is used. The PLT tracking callbacks are still not >> issue for such case, since this will would change the expected program >> semantic (where no PTL is expected) and also yield performance >> implications (such as for BZ#15533). >> >> To handle powerpc64 ELFv1 function descriptor, _dl_audit_symbind() >> requires to know whether bind-now is used so the symbol value is >> updated to function text segment instead of the ODP (for lazy binding >> this is done by PPC64_LOAD_FUNCPTR on _dl_runtime_resolve). > > Typo: OPD (I think) > Ack. > This needs updates to sysdeps/hppa/dl-lookupcfg.h and > sysdeps/ia64/dl-lookupcfg.h as well. Presently these two targets fail > to build. I have fixed and also tested on ia64 (which leads to some fixed on other new audit tests). I am still figuring out why hppa fails. > >> diff --git a/elf/dl-audit.c b/elf/dl-audit.c >> index c3569cb357..4540d93913 100644 >> --- a/elf/dl-audit.c >> +++ b/elf/dl-audit.c >> @@ -190,7 +190,7 @@ rtld_hidden_def (_dl_audit_symbind_alt) >> void >> _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result, >> const ElfW(Sym) *defsym, DL_FIXUP_VALUE_TYPE *value, >> - lookup_t result) >> + lookup_t result, bool bindnow) >> { >> reloc_result->bound = result; >> /* Compute index of the symbol entry in the symbol table of the DSO with the >> @@ -238,7 +238,8 @@ _dl_audit_symbind (struct link_map *l, struct reloc_result *reloc_result, >> if (new_value != (uintptr_t) sym.st_value) >> { >> flags |= LA_SYMB_ALTVALUE; >> - sym.st_value = new_value; >> + sym.st_value = bindnow >> + ? DL_FIXUP_BINDNOW_ADDR_VALUE (new_value) : new_value; >> } >> } > > I think if PLT enter/exit hooks are not available, we should set > LA_SYMB_NOPLTENTER | LA_SYMB_NOPLTEXIT in flags before calling the > symbind callback. It does make sense indeed. > > I find DL_FIXUP_BINDNOW_ADDR_VALUE very confusing. Why is it safe to > extract just the code address from the function descriptor? That's my understanding because at this point st.st_value points to code address, not OPD address. > > In the future, I want to call symbind for all symbol bindings. > Basically, I want to remove > >> + if (ELFW(R_TYPE) (r->r_info) == ELF_MACHINE_JMP_SLOT > > eventually, and add symbind callbacks for dlsym lookups. Hopefully we > can make these changes compatible. I think we will need still handle powerpc64 ELFv1 OPD, but I think it should be feasible.