[Bug dynamic-link/25486] RFE: Do not rely on symbol interposition from libc.so into ld.so

fw at deneb dot enyo.de sourceware-bugzilla@sourceware.org
Sun May 4 09:51:40 GMT 2025


https://sourceware.org/bugzilla/show_bug.cgi?id=25486

Florian Weimer <fw at deneb dot enyo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|fweimer at redhat dot com          |unassigned at sourceware dot org
             Status|ASSIGNED                    |NEW
                 CC|                            |fw at deneb dot enyo.de

--- Comment #17 from Florian Weimer <fw at deneb dot enyo.de> ---
I believe on Linux, the remaining problems have been fixed by this commit. It
makes the lookup of calloc etc. conditional, addressing the problem raised in
comment 16.

commit 706209867f1ba89c458033408d419e92d8055f58
Author: Florian Weimer <fweimer@redhat.com>
Date:   Tue Jan 7 09:18:07 2025 +0100

    elf: Second ld.so relocation only if libc.so has been loaded

    Commit 8f8dd904c4a2207699bb666f30acceb5209c8d3f (“elf:
    rtld_multiple_ref is always true”) removed some code that happened
    to enable compatibility with programs that do not link against
    libc.so.  Such programs cannot call dlopen or any dynamic linker
    functions (except __tls_get_addr), so this is not really useful.
    Still ld.so should not crash with a null-pointer dereference
    or undefined symbol reference in these cases.

    In the main relocation loop, call _dl_relocate_object unconditionally
    because it already checks if the object has been relocated.

    If libc.so was loaded, self-relocate ld.so against it and call
    __rtld_mutex_init and __rtld_malloc_init_real to activate the full
    implementations.  Those are available only if libc.so is there,
    so skip these initialization steps if libc.so is absent.  Without
    libc.so, the global scope can be completely empty.  This can cause
    ld.so self-relocation to fail because if it uses symbol-based
    relocations, which is why the second ld.so self-relocation is not
    performed if libc.so is missing.

    The previous concern regarding GOT updates through self-relocation
    no longer applies because function pointers are updated
    explicitly through __rtld_mutex_init and __rtld_malloc_init_real,
    and not through relocation.  However, the second ld.so self-relocation
    is still delayed, in case there are other symbols being used.

    Fixes commit 8f8dd904c4a2207699bb666f30acceb5209c8d3f (“elf:
    rtld_multiple_ref is always true”).

    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

(More commits are needed to make the new test more reliable across various
architectures.)

Hurd still uses symbol interposition, so moving back to NEW.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list