mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
dl_iterate_phdr(3): do not return garbage for objects not using TLS
For objects without a TLS segment, tlsindex is zero. tls_get_addr_slow()
then reads dtv_slots[-1], which is dtv_size, and returns it as the TLS
address. Set dlpi_tls_data to NULL for such objects instead.
Fixes: d36d681615 ("rtld dl_iterate_phdr(): dlpi_tls_data is wrong")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
This commit is contained in:
1 parent
e2979f4cbb
commit
175595ba6c
1 file changed
+6
-2
@@ -4436,8 +4436,12 @@ rtld_fill_dl_phdr_info(const Obj_Entry *obj, struct dl_phdr_info *phdr_info)
|
||||
phdr_info->dlpi_phdr = obj->phdr;
|
||||
phdr_info->dlpi_phnum = obj->phnum;
|
||||
phdr_info->dlpi_tls_modid = obj->tlsindex;
|
||||
phdr_info->dlpi_tls_data = (char *)tls_get_addr_slow(_tcb_get(),
|
||||
obj->tlsindex, 0, true);
|
||||
if (obj->tlsindex != 0) {
|
||||
phdr_info->dlpi_tls_data = tls_get_addr_slow(_tcb_get(),
|
||||
obj->tlsindex, 0, true);
|
||||
} else {
|
||||
phdr_info->dlpi_tls_data = NULL;
|
||||
}
|
||||
phdr_info->dlpi_adds = obj_loads;
|
||||
phdr_info->dlpi_subs = obj_loads - obj_count;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user