diff options
author | Rich Felker <dalias@aerifal.cx> | 2018-07-16 12:32:57 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-07-16 12:32:57 -0400 |
commit | 5c2f46a214fceeee3c3e41700c51415e0a4f1acd (patch) | |
tree | 1c22945ea0e34d9c6d44da805a3b1206bcabb483 /ldso | |
parent | 5fdccbcd8f080ca6cd2c64cca520805f17af857b (diff) | |
download | musl-5c2f46a214fceeee3c3e41700c51415e0a4f1acd.tar.gz musl-5c2f46a214fceeee3c3e41700c51415e0a4f1acd.tar.bz2 musl-5c2f46a214fceeee3c3e41700c51415e0a4f1acd.tar.xz musl-5c2f46a214fceeee3c3e41700c51415e0a4f1acd.zip |
block dlopen of libraries with initial-exec refs to dynamic TLS
previously, this operation succeeded, and the relocation results
worked for access from new threads created after dlopen, but produced
invalid accesses (and possibly clobbered other memory) from threads
that already existed.
the way the check is written, it still permits dlopen of libraries
containing initial-exec references to static TLS (TLS in the main
program or in a dynamic library loaded at startup).
Diffstat (limited to 'ldso')
-rw-r--r-- | ldso/dynlink.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ldso/dynlink.c b/ldso/dynlink.c index 8242a1d1..87281ddb 100644 --- a/ldso/dynlink.c +++ b/ldso/dynlink.c @@ -385,6 +385,14 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri sym_val = def.sym ? (size_t)laddr(def.dso, def.sym->st_value) : 0; tls_val = def.sym ? def.sym->st_value : 0; + if ((type == REL_TPOFF || type == REL_TPOFF_NEG) + && runtime && def.dso->tls_id > static_tls_cnt) { + error("Error relocating %s: %s: initial-exec TLS " + "resolves to dynamic definition in %s", + dso->name, name, def.dso->name); + longjmp(*rtld_fail, 1); + } + switch(type) { case REL_NONE: break; |