Date: Thu, 27 Aug 2020 00:33:01 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r364853 - stable/11/lib/libc/gen Message-ID: <202008270033.07R0X1u2005069@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Thu Aug 27 00:33:01 2020 New Revision: 364853 URL: https://svnweb.freebsd.org/changeset/base/364853 Log: MFC r364423: dl_iterate_phdr(3): provide exclusive locking for callback when statically linked. Modified: stable/11/lib/libc/gen/dlfcn.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/dlfcn.c ============================================================================== --- stable/11/lib/libc/gen/dlfcn.c Thu Aug 27 00:32:11 2020 (r364852) +++ stable/11/lib/libc/gen/dlfcn.c Thu Aug 27 00:33:01 2020 (r364853) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include <pthread.h> #include "un-namespace.h" #include "libc_private.h" +#include "reentrant.h" static char sorry[] = "Service unavailable"; @@ -162,6 +163,7 @@ _rtld_thread_init(void *li __unused) #ifndef IN_LIBDL static pthread_once_t dl_phdr_info_once = PTHREAD_ONCE_INIT; static struct dl_phdr_info phdr_info; +static mutex_t dl_phdr_info_lock = MUTEX_INITIALIZER; static void dl_init_phdr_info(void) @@ -202,13 +204,17 @@ int dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused, void *data __unused) { - #ifndef IN_LIBDL + int ret; + __init_elf_aux_vector(); if (__elf_aux_vector == NULL) return (1); _once(&dl_phdr_info_once, dl_init_phdr_info); - return (callback(&phdr_info, sizeof(phdr_info), data)); + mutex_lock(&dl_phdr_info_lock); + ret = callback(&phdr_info, sizeof(phdr_info), data); + mutex_unlock(&dl_phdr_info_lock); + return (ret); #else return (0); #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008270033.07R0X1u2005069>