Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Aug 2020 00:32:12 +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-12@freebsd.org
Subject:   svn commit: r364852 - stable/12/lib/libc/gen
Message-ID:  <202008270032.07R0WCiY004099@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Aug 27 00:32:11 2020
New Revision: 364852
URL: https://svnweb.freebsd.org/changeset/base/364852

Log:
  MFC r364423:
  dl_iterate_phdr(3): provide exclusive locking for callback when statically linked.

Modified:
  stable/12/lib/libc/gen/dlfcn.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/gen/dlfcn.c
==============================================================================
--- stable/12/lib/libc/gen/dlfcn.c	Thu Aug 27 00:28:41 2020	(r364851)
+++ stable/12/lib/libc/gen/dlfcn.c	Thu Aug 27 00:32:11 2020	(r364852)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include <pthread.h>
 #include "un-namespace.h"
 #include "libc_private.h"
+#include "reentrant.h"
 
 static char sorry[] = "Service unavailable";
 
@@ -164,6 +165,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)
@@ -204,13 +206,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?202008270032.07R0WCiY004099>