[Bug 286502] RTLD deadlocks during IFUNC resolution

[email protected] Thu, 01 May 2025 13:55:36 +0000
Newsgroups gmane.os.freebsd.devel.threading
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D286502

            Bug ID: 286502
           Summary: RTLD deadlocks during IFUNC resolution
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: threads
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Steps to reproduce the problem:
1. _rtld_bind upgrades to a wlock to load filtees.
2. Call an ifunc resolver.
3. ifunc resolver re-enters _rtld_bind, causing deadlock.

Notes:
1. libthr must be linked to reproduce this.
2. RTLD's own single-threaded locks fail silently under this situation, whi=
ch
is probably also a bug.

Commands to run:
cc filter.c -shared -o filter.so
cc foo.c filter.so -shared -Wl,--auxiliary=3Dfilter.so -o foo.so -Wl,-rpath=
=3D.
cc main.c foo.so -lthr -o main -Wl,-rpath=3D.
./main

Reproducer:
$ cat main.c
void foo();

int main() {
        foo();
}

$ cat foo.c
static void foo_impl() {
}

static void *foo_resolver() {
        bar();
        return &foo_impl;
}

void foo() __attribute__((ifunc("foo_resolver")));

$ cat filter.c
void bar() {
}

--=20
You are receiving this mail because:
You are the assignee for the bug.=