Bug 254286 - usage of initial-exec prevents dlopen of the libwebkit shared object outside of GLIBC on linux
Summary: usage of initial-exec prevents dlopen of the libwebkit shared object outside ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-22 14:13 PDT by alice
Modified: 2023-09-06 14:49 PDT (History)
2 users (show)

See Also:


Attachments
a fix for this issue (1.84 KB, patch)
2023-03-22 14:13 PDT, alice
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description alice 2023-03-22 14:13:37 PDT
Created attachment 465547 [details]
a fix for this issue

usage of initial-exec prevents valid dlopen of the library later. this works on glibc, because glibc reserves some memory for initial-exec variables in dlopen'd objects.

on other libcs, this doesn't work. for instance:

$ cat main.c 
#include <dlfcn.h>
#include <stdio.h>

int main() {
  void *h = dlopen("libwebkit2gtk-4.0.so.37", 0);

  if(!h) {
    fprintf(stderr, "%s\n", dlerror());
    return 1;
  }

  return 0;
}
$ gcc main.c 
$ ./a.out 
Error relocating /usr/lib/libwebkit2gtk-4.0.so.37: lroundf: initial-exec TLS resolves to dynamic definition in /usr/lib/libwebkit2gtk-4.0.so.37
$ ldd --version
musl libc (x86_64)
Version 1.2.3
Dynamic Program Loader
Usage: /lib/ld-musl-x86_64.so.1 [options] [--] pathname

utilising initial-exec only when __GLIBC__ is defined fixes this.
Comment 1 alice 2023-03-23 13:43:18 PDT
the patch of course has a typo in it- it's #endif not #fi
Comment 2 Michael Catanzaro 2023-09-06 14:45:20 PDT
Closing since TLS_MODEL_INITIAL_EXEC is no longer used anywhere in WebKit. The entire file that you patched was deleted at some point between then and now.
Comment 3 alice 2023-09-06 14:49:03 PDT
looks to have been https://github.com/WebKit/WebKit/commit/b30a03a4c8a229deacb72a6e4fa46f6469df634f, seems fine to me. thanks for following up :)