[Bug 286502] RTLD deadlocks during IFUNC resolution

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 01 May 2025 13:55:36 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=286502

            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: threads@FreeBSD.org
          Reporter: dapeng.gao@cl.cam.ac.uk
                CC: kib@FreeBSD.org

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, which
is probably also a bug.

Commands to run:
cc filter.c -shared -o filter.so
cc foo.c filter.so -shared -Wl,--auxiliary=filter.so -o foo.so -Wl,-rpath=.
cc main.c foo.so -lthr -o main -Wl,-rpath=.
./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() {
}

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