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 D85233844079 for ; Fri, 27 May 2022 16:59:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D85233844079 Received: by mail-oi1-x22a.google.com with SMTP id k186so6377565oia.2 for ; Fri, 27 May 2022 09:59:46 -0700 (PDT) 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=KqG/ZNn0B7Iidy1rUhyLzsjpMpHYsp04xlRkF6V+ctU=; b=6F7UWsQRORzH89Y6oQfmMD4BqsH+iyfYQzZeV0NKTNcpFk7iSl4cSJDJWTzTtJFl0g /qDXH5kkjxbwBGGecREDqu0ohBGkocnrTRBeGVHAlKOC/EMEClIkyZwxNoYFA5aAFeQK 0zQoD7taRdvNfU944tZE1SuJKQKwuMFzRQ403nSSepNjdHwYopTXG/vAVVWS1X5Ap8eU WyVQySU+52pM0yPVc+/rqcHOQe+b2xRfAbu+lw0mQghw0kUzaomYgBAJbDVyYsRvxm2W vcHimmRN9aAHdjBlirVNPppePx+aNscyYDfesHcz/rBLU2BlgKxwg3EoZh0rxGHJ9v7v 5JNA== X-Gm-Message-State: AOAM531osNo7gmmheMhBCGQRD5/LeekuA3lkMTDqx79PcTvI5LBaNWlK 8fjUVxokGXWOERvouxYgcLKcXwMv9ALTIQ== X-Google-Smtp-Source: ABdhPJxBlNBGjzOwcxgI8nhDNLX3FjEvrT6ObtfCRHGI284mBSJtFTEz8F5n80rrF4hkWABNe4Mqvw== X-Received: by 2002:aca:448a:0:b0:32b:44a0:cb4a with SMTP id r132-20020aca448a000000b0032b44a0cb4amr4500164oia.272.1653670786099; Fri, 27 May 2022 09:59:46 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:9f85:b770:666d:a956:2e6a? ([2804:431:c7cb:9f85:b770:666d:a956:2e6a]) by smtp.gmail.com with ESMTPSA id t26-20020a9d729a000000b005b22a0d826csm2018648otj.1.2022.05.27.09.59.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 May 2022 09:59:45 -0700 (PDT) Message-ID: <49ca6122-ca7a-d384-79e3-9bdc02879a94@linaro.org> Date: Fri, 27 May 2022 13:59:43 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] dlsym: Make RTLD_NEXT prefer default version definition [#BZ #14932] Content-Language: en-US To: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= , Florian Weimer Cc: Adhemerval Zanella via Libc-alpha References: <20220520083507.2368165-1-maskray@google.com> <87y1yw2sir.fsf@mid.deneb.enyo.de> From: Adhemerval Zanella In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Fri, 27 May 2022 16:59:48 -0000 On 22/05/2022 15:54, Fāng-ruì Sòng wrote: > On Fri, May 20, 2022 at 7:22 AM Florian Weimer wrote: >> >> * Adhemerval Zanella via Libc-alpha: >> >>> On 20/05/2022 05:35, Fangrui Song via Libc-alpha wrote: >>>> When the first object providing foo defines both foo@v1 and foo@@v2, >>>> dlsym(RTLD_NEXT, "foo") returns foo@v1 while dlsym(RTLD_DEFAULT, "foo") >>>> returns foo@@v2. The issue is that RTLD_DEFAULT use the >>>> DL_LOOKUP_RETURN_NEWEST flag while RTLD_NEXT doesn't. Fix the RTLD_NEXT >>>> branch to use DL_LOOKUP_RETURN_NEWEST. >>> >>> I am afraid we will need to add a compat dlsym for this change. >> >> My working theory is dlsym with RTLD_NEXT with a versioned symbol is >> so buggy that this is not needed. I want to understand the nature of >> the bug, and plan to post a write-up. > > Ok, thanks. > > FWIW: I have verified that on FreeBSD 13.1, both dlsym(RTLD_NEXT, > "foo") and dlsym(RTLD_DEFAULT, "foo") resolve to the default version > definition, like what this patch does. Right, I agree this is the most reasonable way to handle RTLD_NEXT with versioned symbols specially because current semantic is to return the *oldest* version with not apparent reason. I guess that if caller wants an old version it can use dlvsym with the appropriated version. LGTM as well with Florian's remarks fixed. Reviewed-by: Adhemerval Zanella