From a28114c4a885bcb96da237dc3cd6dd977c21837a Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 2 Jun 2023 18:57:00 +0000 Subject: [PATCH] ld.elf_so: Fix several bugs in thread-local storage, from joerg@. 1. For static TLS relocations, allocate a TLS offset in the object that _defines_ the symbol, not the object that is _using_ it. (This is currently done by abusing __UNCONST because too much of rtld passes around const Obj_Entry * for symbol lookups.) 2. Handle dynamic TLS relocations for a symbol defined in an object that already has static TLS relocations by just yielding a pointer into the static TLS area that works with the same dynamic TLS sequence. 3. Refuse to dlopen anything with static TLS relocations for a symbol defined in an object that already has dynamic TLS relocations. PR toolchain/50277 PR pkg/57445 XXX pullup-10 --- libexec/ld.elf_so/README.TLS | 5 ++- libexec/ld.elf_so/arch/aarch64/mdreloc.c | 6 +-- libexec/ld.elf_so/arch/alpha/alpha_reloc.c | 4 +- libexec/ld.elf_so/arch/arm/mdreloc.c | 4 +- libexec/ld.elf_so/arch/hppa/hppa_reloc.c | 3 +- libexec/ld.elf_so/arch/i386/mdreloc.c | 8 ++-- libexec/ld.elf_so/arch/m68k/mdreloc.c | 6 +-- libexec/ld.elf_so/arch/mips/mips_reloc.c | 6 +-- libexec/ld.elf_so/arch/or1k/mdreloc.c | 6 +-- libexec/ld.elf_so/arch/powerpc/ppc_reloc.c | 3 +- libexec/ld.elf_so/arch/riscv/mdreloc.c | 4 +- libexec/ld.elf_so/arch/sh3/mdreloc.c | 4 +- libexec/ld.elf_so/arch/sparc/mdreloc.c | 6 +-- libexec/ld.elf_so/arch/sparc64/mdreloc.c | 6 +-- libexec/ld.elf_so/arch/x86_64/mdreloc.c | 4 +- libexec/ld.elf_so/map_object.c | 2 +- libexec/ld.elf_so/rtld.h | 5 ++- libexec/ld.elf_so/tls.c | 30 ++++++++++---- tests/libexec/ld.elf_so/t_tls_extern.c | 46 ++++++++-------------- 19 files changed, 78 insertions(+), 80 deletions(-) diff --git a/libexec/ld.elf_so/README.TLS b/libexec/ld.elf_so/README.TLS index 56acdc6206d9..635028ec985e 100644 --- a/libexec/ld.elf_so/README.TLS +++ b/libexec/ld.elf_so/README.TLS @@ -43,9 +43,10 @@ This is normally def->st_value + rela->r_addend. (c) R_TYPE(TLS_TPOFF): Static TLS offset. The code has to check whether the static TLS offset for this module has been allocated -(defobj->tls_done) and otherwise call _rtld_tls_offset_allocate(). This +(defobj->tls_static) and otherwise call _rtld_tls_offset_allocate(). This may fail if no static space is available and the object has been pulled -in via dlopen(3). +in via dlopen(3). It can also fail if the TLS area has already been used +via a global-dynamic allocation. For TLS Variant I, this is typically: diff --git a/libexec/ld.elf_so/arch/aarch64/mdreloc.c b/libexec/ld.elf_so/arch/aarch64/mdreloc.c index 64335181bfe6..d9e16d343f17 100644 --- a/libexec/ld.elf_so/arch/aarch64/mdreloc.c +++ b/libexec/ld.elf_so/arch/aarch64/mdreloc.c @@ -157,7 +157,7 @@ _rtld_tlsdesc_fill(const Obj_Entry *obj, const Elf_Rela *rela, Elf_Addr *where, } offs += rela->r_addend; - if (defobj->tls_done) { + if (defobj->tls_static) { /* Variable is in initially allocated TLS segment */ where[0] = (Elf_Addr)_rtld_tlsdesc_static; where[1] = defobj->tlsoffset + offs + @@ -299,8 +299,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TLS_TYPE(TLS_TPREL): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where = (Elf_Addr)(def->st_value + defobj->tlsoffset + diff --git a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c index c7f2e85c2a28..83e80ff8430a 100644 --- a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c +++ b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c @@ -280,8 +280,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TPREL64): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; tmp = (Elf64_Addr)(def->st_value + diff --git a/libexec/ld.elf_so/arch/arm/mdreloc.c b/libexec/ld.elf_so/arch/arm/mdreloc.c index 79f7f2765a81..b8bff2506a6f 100644 --- a/libexec/ld.elf_so/arch/arm/mdreloc.c +++ b/libexec/ld.elf_so/arch/arm/mdreloc.c @@ -228,8 +228,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_TPOFF32): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; if (__predict_true(RELOC_ALIGNED_P(where))) diff --git a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c index dd11e536653f..49ba84ae4645 100644 --- a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c +++ b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c @@ -553,7 +553,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_TPREL32): - if (!defobj->tls_done && _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where = (Elf_Addr)(defobj->tlsoffset + def->st_value + diff --git a/libexec/ld.elf_so/arch/i386/mdreloc.c b/libexec/ld.elf_so/arch/i386/mdreloc.c index 5e3f7c959fca..d75a30ff362b 100644 --- a/libexec/ld.elf_so/arch/i386/mdreloc.c +++ b/libexec/ld.elf_so/arch/i386/mdreloc.c @@ -147,8 +147,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_TPOFF): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where += (Elf_Addr)(def->st_value - defobj->tlsoffset); @@ -159,8 +159,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_TPOFF32): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where += (Elf_Addr)(defobj->tlsoffset - def->st_value); diff --git a/libexec/ld.elf_so/arch/m68k/mdreloc.c b/libexec/ld.elf_so/arch/m68k/mdreloc.c index d327e24f2edf..6febc1ba780d 100644 --- a/libexec/ld.elf_so/arch/m68k/mdreloc.c +++ b/libexec/ld.elf_so/arch/m68k/mdreloc.c @@ -142,9 +142,6 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_DTPREL32): - if (!defobj->tls_done && _rtld_tls_offset_allocate(obj)) - return -1; - *where = (Elf_Addr)(def->st_value + rela->r_addend - TLS_DTV_OFFSET); rdbg(("DTPREL32 %s in %s --> %p in %s", @@ -153,7 +150,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_TPREL32): - if (!defobj->tls_done && _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where = (Elf_Addr)(def->st_value + rela->r_addend diff --git a/libexec/ld.elf_so/arch/mips/mips_reloc.c b/libexec/ld.elf_so/arch/mips/mips_reloc.c index 9cd5de7cab51..8613f85dee98 100644 --- a/libexec/ld.elf_so/arch/mips/mips_reloc.c +++ b/libexec/ld.elf_so/arch/mips/mips_reloc.c @@ -429,9 +429,6 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) Elf_Addr old = load_ptr(where, ELFSIZE / 8); Elf_Addr val = old; - if (!defobj->tls_done && _rtld_tls_offset_allocate(obj)) - return -1; - val += (Elf_Addr)def->st_value - TLS_DTV_OFFSET; store_ptr(where, val, ELFSIZE / 8); @@ -450,7 +447,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) Elf_Addr old = load_ptr(where, ELFSIZE / 8); Elf_Addr val = old; - if (!defobj->tls_done && _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; val += (Elf_Addr)(def->st_value + defobj->tlsoffset diff --git a/libexec/ld.elf_so/arch/or1k/mdreloc.c b/libexec/ld.elf_so/arch/or1k/mdreloc.c index 78fd17293789..e82d8add27b8 100644 --- a/libexec/ld.elf_so/arch/or1k/mdreloc.c +++ b/libexec/ld.elf_so/arch/or1k/mdreloc.c @@ -171,9 +171,6 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_DTPOFF): - if (!defobj->tls_done && _rtld_tls_offset_allocate(obj)) - return -1; - *where = (Elf_Addr)(def->st_value + rela->r_addend - TLS_DTV_OFFSET); rdbg(("DTPOFF %s in %s --> %p in %s", @@ -182,7 +179,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_TPOFF): - if (!defobj->tls_done && _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where = (Elf_Addr)(def->st_value + rela->r_addend diff --git a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c b/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c index 37ca160e6195..ee45ac0261aa 100644 --- a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c +++ b/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c @@ -321,7 +321,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TPREL): - if (!defobj->tls_done && _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where = (Elf_Addr)(def->st_value + rela->r_addend diff --git a/libexec/ld.elf_so/arch/riscv/mdreloc.c b/libexec/ld.elf_so/arch/riscv/mdreloc.c index 05cc4b81906a..ef438a39a80f 100644 --- a/libexec/ld.elf_so/arch/riscv/mdreloc.c +++ b/libexec/ld.elf_so/arch/riscv/mdreloc.c @@ -203,8 +203,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) } case R_TYPESZ(TLS_TPREL): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where = (Elf_Addr)(def->st_value + defobj->tlsoffset + diff --git a/libexec/ld.elf_so/arch/sh3/mdreloc.c b/libexec/ld.elf_so/arch/sh3/mdreloc.c index 949bd02a88a9..5383afe7269e 100644 --- a/libexec/ld.elf_so/arch/sh3/mdreloc.c +++ b/libexec/ld.elf_so/arch/sh3/mdreloc.c @@ -173,8 +173,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_TPOFF32): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where = (Elf_Addr)def->st_value + diff --git a/libexec/ld.elf_so/arch/sparc/mdreloc.c b/libexec/ld.elf_so/arch/sparc/mdreloc.c index 526c0dfa1d99..0352b88f6b70 100644 --- a/libexec/ld.elf_so/arch/sparc/mdreloc.c +++ b/libexec/ld.elf_so/arch/sparc/mdreloc.c @@ -282,9 +282,9 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_TPOFF32): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) - return -1; + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) + return -1; *where = (Elf_Addr)(def->st_value - defobj->tlsoffset + rela->r_addend); diff --git a/libexec/ld.elf_so/arch/sparc64/mdreloc.c b/libexec/ld.elf_so/arch/sparc64/mdreloc.c index e3ea5a8808e3..6ff217aa556f 100644 --- a/libexec/ld.elf_so/arch/sparc64/mdreloc.c +++ b/libexec/ld.elf_so/arch/sparc64/mdreloc.c @@ -383,9 +383,9 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TLS_TPOFF64): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) - return -1; + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) + return -1; *where = (Elf64_Addr)(def->st_value - defobj->tlsoffset + rela->r_addend); diff --git a/libexec/ld.elf_so/arch/x86_64/mdreloc.c b/libexec/ld.elf_so/arch/x86_64/mdreloc.c index a04c05ea0aa7..d451e4cd0c43 100644 --- a/libexec/ld.elf_so/arch/x86_64/mdreloc.c +++ b/libexec/ld.elf_so/arch/x86_64/mdreloc.c @@ -226,8 +226,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj) break; case R_TYPE(TPOFF64): - if (!defobj->tls_done && - _rtld_tls_offset_allocate(obj)) + if (!defobj->tls_static && + _rtld_tls_offset_allocate(__UNCONST(defobj))) return -1; *where64 = (Elf64_Addr)(def->st_value - diff --git a/libexec/ld.elf_so/map_object.c b/libexec/ld.elf_so/map_object.c index 0b682d570255..dfba54008a11 100644 --- a/libexec/ld.elf_so/map_object.c +++ b/libexec/ld.elf_so/map_object.c @@ -490,7 +490,7 @@ _rtld_obj_free(Obj_Entry *obj) Name_Entry *entry; #if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) - if (obj->tls_done) + if (obj->tls_static) _rtld_tls_offset_free(obj); #endif xfree(obj->path); diff --git a/libexec/ld.elf_so/rtld.h b/libexec/ld.elf_so/rtld.h index 0330ea964312..ac0246d0fef7 100644 --- a/libexec/ld.elf_so/rtld.h +++ b/libexec/ld.elf_so/rtld.h @@ -219,7 +219,9 @@ typedef struct Struct_Obj_Entry { phdr_loaded:1, /* Phdr is loaded and doesn't need to * be freed. */ #if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) - tls_done:1, /* True if static TLS offset + tls_static:1, /* True if static TLS offset + * has been allocated */ + tls_dynamic:1, /* True if any non-static DTV entry * has been allocated */ #endif ref_nodel:1, /* Refcount increased to prevent dlclose */ @@ -483,7 +485,6 @@ _rtld_fetch_ventry(const Obj_Entry *obj, unsigned long symnum) /* tls.c */ void *_rtld_tls_get_addr(void *, size_t, size_t); void _rtld_tls_initial_allocation(void); -void *_rtld_tls_module_allocate(size_t index); int _rtld_tls_offset_allocate(Obj_Entry *); void _rtld_tls_offset_free(Obj_Entry *); diff --git a/libexec/ld.elf_so/tls.c b/libexec/ld.elf_so/tls.c index 01d5c9f9b6d6..d49ebe22b345 100644 --- a/libexec/ld.elf_so/tls.c +++ b/libexec/ld.elf_so/tls.c @@ -43,6 +43,7 @@ __RCSID("$NetBSD: tls.c,v 1.17 2023/06/01 08:20:10 riastradh Exp $"); #if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) static struct tls_tcb *_rtld_tls_allocate_locked(void); +static void *_rtld_tls_module_allocate(struct tls_tcb *, size_t); #ifndef TLS_DTV_OFFSET #define TLS_DTV_OFFSET 0 @@ -84,7 +85,7 @@ _rtld_tls_get_addr(void *tls, size_t idx, size_t offset) } if (__predict_false(dtv[idx] == NULL)) - dtv[idx] = _rtld_tls_module_allocate(idx); + dtv[idx] = _rtld_tls_module_allocate(tcb, idx); _rtld_exclusive_exit(&mask); @@ -136,7 +137,7 @@ _rtld_tls_allocate_locked(void) SET_DTV_GENERATION(tcb->tcb_dtv, _rtld_tls_dtv_generation); for (obj = _rtld_objlist; obj != NULL; obj = obj->next) { - if (obj->tls_done) { + if (obj->tls_static) { #ifdef __HAVE_TLS_VARIANT_I q = p + obj->tlsoffset; #else @@ -195,8 +196,8 @@ _rtld_tls_free(struct tls_tcb *tcb) _rtld_exclusive_exit(&mask); } -void * -_rtld_tls_module_allocate(size_t idx) +static void * +_rtld_tls_module_allocate(struct tls_tcb *tcb, size_t idx) { Obj_Entry *obj; uint8_t *p; @@ -209,11 +210,21 @@ _rtld_tls_module_allocate(size_t idx) _rtld_error("Module for TLS index %zu missing", idx); _rtld_die(); } + if (obj->tls_static) { +#ifdef __HAVE_TLS_VARIANT_I + p = (uint8_t *)tcb + obj->tlsoffset; +#else + p = (uint8_t *)tcb - obj->tlsoffset; +#endif + return p; + } p = xmalloc(obj->tlssize); memcpy(p, obj->tlsinit, obj->tlsinitsize); memset(p + obj->tlsinitsize, 0, obj->tlssize - obj->tlsinitsize); + obj->tls_dynamic = 1; + return p; } @@ -222,11 +233,14 @@ _rtld_tls_offset_allocate(Obj_Entry *obj) { size_t offset, next_offset; - if (obj->tls_done) + if (obj->tls_dynamic) + return -1; + + if (obj->tls_static) return 0; if (obj->tlssize == 0) { obj->tlsoffset = 0; - obj->tls_done = 1; + obj->tls_static = 1; return 0; } @@ -265,7 +279,7 @@ _rtld_tls_offset_allocate(Obj_Entry *obj) dbg(("%s: static tls offset 0x%zx size %zu\n", obj->path, obj->tlsoffset, obj->tlssize)); _rtld_tls_static_offset = next_offset; - obj->tls_done = 1; + obj->tls_static = 1; return 0; } @@ -277,7 +291,7 @@ _rtld_tls_offset_free(Obj_Entry *obj) /* * XXX See above. */ - obj->tls_done = 0; + obj->tls_static = 0; return; } diff --git a/tests/libexec/ld.elf_so/t_tls_extern.c b/tests/libexec/ld.elf_so/t_tls_extern.c index 5eadd9de8d06..5b1a2fdeed95 100644 --- a/tests/libexec/ld.elf_so/t_tls_extern.c +++ b/tests/libexec/ld.elf_so/t_tls_extern.c @@ -41,8 +41,7 @@ enum order { }; static void -tls_extern(const char *libdef, const char *libuse, enum order order, - bool xfail) +tls_extern(const char *libdef, const char *libuse, enum order order) { void *def, *use; int *(*fdef)(void), *(*fuse)(void); @@ -77,10 +76,6 @@ lazy: ATF_REQUIRE_DL(fdef = dlsym(def, "fdef")); break; } - if (xfail) { - atf_tc_expect_fail("PR toolchain/50277:" - " rtld relocation bug with thread local storage"); - } ATF_CHECK_EQ_MSG(pdef, puse, "%p in defining library != %p in using library", pdef, puse); @@ -95,7 +90,7 @@ ATF_TC_HEAD(dynamic_abusedef, tc) ATF_TC_BODY(dynamic_abusedef, tc) { tls_extern("libh_def_dynamic.so", "libh_abuse_dynamic.so", - USE_DEF, /*xfail*/true); + USE_DEF); } ATF_TC(dynamic_abusedefnoload); @@ -107,7 +102,7 @@ ATF_TC_HEAD(dynamic_abusedefnoload, tc) ATF_TC_BODY(dynamic_abusedefnoload, tc) { tls_extern("libh_def_dynamic.so", "libh_abuse_dynamic.so", - USE_DEF_NOLOAD, /*xfail*/true); + USE_DEF_NOLOAD); } ATF_TC(dynamic_defabuse_eager); @@ -124,7 +119,6 @@ ATF_TC_BODY(dynamic_defabuse_eager, tc) ATF_REQUIRE_DL(def = dlopen("libh_def_dynamic.so", 0)); ATF_REQUIRE_DL(fdef = dlsym(def, "fdef")); (void)(*fdef)(); - atf_tc_expect_fail("rtld fails to detect dynamic-then-static abuse"); ATF_CHECK_EQ_MSG(NULL, dlopen("libh_abuse_dynamic.so", 0), "dlopen failed to detect static-then-dynamic abuse"); } @@ -138,7 +132,7 @@ ATF_TC_HEAD(dynamic_defabuse_lazy, tc) ATF_TC_BODY(dynamic_defabuse_lazy, tc) { tls_extern("libh_def_dynamic.so", "libh_abuse_dynamic.so", - DEF_USE_LAZY, /*xfail*/true); + DEF_USE_LAZY); } ATF_TC(dynamic_defuse_eager); @@ -150,7 +144,7 @@ ATF_TC_HEAD(dynamic_defuse_eager, tc) ATF_TC_BODY(dynamic_defuse_eager, tc) { tls_extern("libh_def_dynamic.so", "libh_use_dynamic.so", - DEF_USE_EAGER, /*xfail*/false); + DEF_USE_EAGER); } ATF_TC(dynamic_defuse_lazy); @@ -162,7 +156,7 @@ ATF_TC_HEAD(dynamic_defuse_lazy, tc) ATF_TC_BODY(dynamic_defuse_lazy, tc) { tls_extern("libh_def_dynamic.so", "libh_use_dynamic.so", - DEF_USE_LAZY, /*xfail*/false); + DEF_USE_LAZY); } ATF_TC(dynamic_usedef); @@ -174,7 +168,7 @@ ATF_TC_HEAD(dynamic_usedef, tc) ATF_TC_BODY(dynamic_usedef, tc) { tls_extern("libh_def_dynamic.so", "libh_use_dynamic.so", - USE_DEF, /*xfail*/false); + USE_DEF); } ATF_TC(dynamic_usedefnoload); @@ -186,7 +180,7 @@ ATF_TC_HEAD(dynamic_usedefnoload, tc) ATF_TC_BODY(dynamic_usedefnoload, tc) { tls_extern("libh_def_dynamic.so", "libh_use_dynamic.so", - USE_DEF_NOLOAD, /*xfail*/false); + USE_DEF_NOLOAD); } ATF_TC(static_abusedef); @@ -198,7 +192,7 @@ ATF_TC_HEAD(static_abusedef, tc) ATF_TC_BODY(static_abusedef, tc) { tls_extern("libh_def_static.so", "libh_abuse_static.so", - USE_DEF, /*xfail*/true); + USE_DEF); } ATF_TC(static_abusedefnoload); @@ -210,7 +204,7 @@ ATF_TC_HEAD(static_abusedefnoload, tc) ATF_TC_BODY(static_abusedefnoload, tc) { tls_extern("libh_def_static.so", "libh_abuse_static.so", - USE_DEF_NOLOAD, /*xfail*/true); + USE_DEF_NOLOAD); } ATF_TC(static_defabuse_eager); @@ -222,7 +216,7 @@ ATF_TC_HEAD(static_defabuse_eager, tc) ATF_TC_BODY(static_defabuse_eager, tc) { tls_extern("libh_def_static.so", "libh_abuse_static.so", - DEF_USE_EAGER, /*xfail*/true); + DEF_USE_EAGER); } ATF_TC(static_defabuse_lazy); @@ -234,7 +228,7 @@ ATF_TC_HEAD(static_defabuse_lazy, tc) ATF_TC_BODY(static_defabuse_lazy, tc) { tls_extern("libh_def_static.so", "libh_abuse_static.so", - DEF_USE_LAZY, /*xfail*/true); + DEF_USE_LAZY); } ATF_TC(static_defuse_eager); @@ -246,7 +240,7 @@ ATF_TC_HEAD(static_defuse_eager, tc) ATF_TC_BODY(static_defuse_eager, tc) { tls_extern("libh_def_static.so", "libh_use_static.so", - DEF_USE_EAGER, /*xfail*/false); + DEF_USE_EAGER); } ATF_TC(static_defuse_lazy); @@ -258,7 +252,7 @@ ATF_TC_HEAD(static_defuse_lazy, tc) ATF_TC_BODY(static_defuse_lazy, tc) { tls_extern("libh_def_static.so", "libh_use_static.so", - DEF_USE_LAZY, /*xfail*/false); + DEF_USE_LAZY); } ATF_TC(static_usedef); @@ -270,7 +264,7 @@ ATF_TC_HEAD(static_usedef, tc) ATF_TC_BODY(static_usedef, tc) { tls_extern("libh_def_static.so", "libh_use_static.so", - USE_DEF, /*xfail*/true); + USE_DEF); } ATF_TC(static_usedefnoload); @@ -282,7 +276,7 @@ ATF_TC_HEAD(static_usedefnoload, tc) ATF_TC_BODY(static_usedefnoload, tc) { tls_extern("libh_def_static.so", "libh_use_static.so", - USE_DEF_NOLOAD, /*xfail*/true); + USE_DEF_NOLOAD); } ATF_TC(onlydef_dynamic_static_ctor); @@ -296,7 +290,6 @@ ATF_TC_BODY(onlydef_dynamic_static_ctor, tc) ATF_REQUIRE_DL(dlopen("libh_onlydef.so", 0)); ATF_REQUIRE_DL(dlopen("libh_onlyctor_dynamic.so", 0)); - atf_tc_expect_fail("rtld fails to detect dynamic-then-static abuse"); ATF_CHECK_EQ_MSG(NULL, dlopen("libh_onlyuse_static.so", 0), "dlopen failed to detect dynamic-then-static abuse"); } @@ -315,7 +308,6 @@ ATF_TC_BODY(onlydef_dynamic_static_eager, tc) ATF_REQUIRE_DL(use_dynamic = dlopen("libh_onlyuse_dynamic.so", 0)); ATF_REQUIRE_DL(fdynamic = dlsym(use_dynamic, "fdynamic")); (void)(*fdynamic)(); - atf_tc_expect_fail("rtld fails to detect dynamic-then-static abuse"); ATF_CHECK_EQ_MSG(NULL, dlopen("libh_onlyuse_static.so", 0), "dlopen failed to detect dynamic-then-static abuse"); } @@ -338,8 +330,6 @@ ATF_TC_BODY(onlydef_dynamic_static_lazy, tc) ATF_REQUIRE_DL(fstatic = dlsym(use_static, "fstatic")); pdynamic = (*fdynamic)(); pstatic = (*fstatic)(); - atf_tc_expect_fail("PR toolchain/50277:" - " rtld relocation bug with thread local storage"); ATF_CHECK_EQ_MSG(pdynamic, pstatic, "%p in dynamic tls user != %p in static tls user", pdynamic, pstatic); @@ -365,8 +355,6 @@ ATF_TC_BODY(onlydef_static_dynamic_eager, tc) ATF_REQUIRE_DL(use_dynamic = dlopen("libh_onlyuse_dynamic.so", 0)); ATF_REQUIRE_DL(fdynamic = dlsym(use_dynamic, "fdynamic")); pdynamic = (*fdynamic)(); - atf_tc_expect_fail("PR toolchain/50277:" - " rtld relocation bug with thread local storage"); ATF_CHECK_EQ_MSG(pstatic, pdynamic, "%p in static tls user != %p in dynamic tls user", pstatic, pdynamic); @@ -391,8 +379,6 @@ ATF_TC_BODY(onlydef_static_dynamic_lazy, tc) ATF_REQUIRE_DL(fdynamic = dlsym(use_dynamic, "fdynamic")); pstatic = (*fstatic)(); pdynamic = (*fdynamic)(); - atf_tc_expect_fail("PR toolchain/50277:" - " rtld relocation bug with thread local storage"); ATF_CHECK_EQ_MSG(pstatic, pdynamic, "%p in static tls user != %p in dynamic tls user", pstatic, pdynamic);