From owner-svn-src-stable-12@freebsd.org Thu Aug 27 00:32:12 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 66A533C24C1; Thu, 27 Aug 2020 00:32:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BcNwD27NNz3fhw; Thu, 27 Aug 2020 00:32:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C8BE1B751; Thu, 27 Aug 2020 00:32:12 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 07R0WCc5004100; Thu, 27 Aug 2020 00:32:12 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07R0WCiY004099; Thu, 27 Aug 2020 00:32:12 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202008270032.07R0WCiY004099@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 27 Aug 2020 00:32:12 +0000 (UTC) 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 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/lib/libc/gen X-SVN-Commit-Revision: 364852 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2020 00:32:12 -0000 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 #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