From aad50fcd791e009961621ddfbe3d4c245fd689a3 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 16 Apr 2021 10:20:46 -0400 Subject: fix regression in dl_iterate_phdr reporting of modules with no TLS __tls_get_addr should not be called with an invalid TLS module id of 0. in practice it probably "works", returning the DTV length as if it were a pointer, and the callback should probably not inspect dlpi_tls_data in this case, but it's likely that some real-world callbacks use a check on dlpi_tls_data being non-null, rather than on dlpi_tls_modid being nonzero, to conclude that the module has TLS. --- ldso/dynlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ldso/dynlink.c b/ldso/dynlink.c index b66ad53..8b67ef5 100644 --- a/ldso/dynlink.c +++ b/ldso/dynlink.c @@ -2331,7 +2331,8 @@ int dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void info.dlpi_adds = gencnt; info.dlpi_subs = 0; info.dlpi_tls_modid = current->tls_id; - info.dlpi_tls_data = __tls_get_addr((tls_mod_off_t[]){current->tls_id,0}); + info.dlpi_tls_data = !current->tls_id ? 0 : + __tls_get_addr((tls_mod_off_t[]){current->tls_id,0}); ret = (callback)(&info, sizeof (info), data); -- cgit v1.1