From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0B5AA3857C40; Mon, 12 Oct 2020 15:25:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B5AA3857C40 From: "bugdal at aerifal dot cx" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/21050] Prevent tailcall optimizations of libdl functions Date: Mon, 12 Oct 2020 15:25:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bugdal at aerifal dot cx X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Oct 2020 15:25:50 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D21050 --- Comment #3 from Rich Felker --- The suggestion in comment 2 is a spec violation; it has a static identifier dlsym in place of the required extern one, and also breaks the identity of function pointers (different pointer per translation unit). You have to use function-like macros to do this kind of thing in a conforming way, and the macro still does not cover the case where the caller undefines the macro or directly calls the function via its address. I believe the right solution is to deprecate the old constant value of RTLD_NEXT and instead define RTLD_NEXT to expand to the address of a static anchor object inside the translation unit. The dynamic linker can then use = that anchor object, rather than the return address, to identify the DSO from whi= ch it was called. This also fixes a lot of other usage patterns, e.g. where library A calls dlsym_wrapper(RTLD_NEXT, "foo") and dlsym_wrapper is define= d in library B. --=20 You are receiving this mail because: You are on the CC list for the bug.=