From nobody Fri Apr 12 20:21:42 2024 X-Original-To: dev-commits-ports-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VGSdf3Rc3z5G3C3; Fri, 12 Apr 2024 20:21:42 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VGSdf313Xz4cgp; Fri, 12 Apr 2024 20:21:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712953302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tWX3PeeTk3rVUDv3JMiEyJOn2/XdThJLQe0MLPG3Aas=; b=j2Y/+7844HyzrX1zfZzAT/dzfVsqG4GLY3H+K6qGgB3XxweOQBEYZl0u0RZtWq3sqiT556 u8cXFKS4MC+AtxZlPBmoVGoSumHOjge0Ijn6lHSusdHxiFBYLNl3x/ckd7neytRd/isLeB J2KNrkjilZLCEVYLgLeqlWfNYLGNLY67QQqTXbiidTvwuoV+3wN2jCpAWyaBTL1xH/iBVR lp63gqvqwvu2o9LfZCen8RmZuu9Xia6b5ClmwjWnwMwvu2Y3q0UxEHdsHWkTHZE+YDPTWS 2KslTKkVt7lHieS77vFDgLW/1InI3yaX7ZfvEYCprYyK+ms02AIrRMk4BvrWIw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712953302; a=rsa-sha256; cv=none; b=WYEpdnSO/oRgylqM7UxTSXrHFkShkgjQ+giHkgMWQ8RIS7DkdvPnY6YKkfuhJpKWNsWbnC tn14Kz9CCILKxrkcGreZ+eoiy2xORReveHTA7ZwRbCMRksh0rqL5rvRz9X7WeJztWbm/2A KqHeNu9H8f68dF4pGF2wMHuEpipMoPeftkXAd9TVm0MnJJClXeW8z65MRx041xZMbZ/1CS Wcpu0CopjYvUUf2+0FEYpM3gDF2irN+dRgzvZrjKcSTgC0NC+WcwMlPWkKzTRpDUcTMbmN +R+yqw2IYxjacacMyoJlAYKdQGUmRPBUF+Iaad46p4w14QX46BI6l2gUF5aoaw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712953302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tWX3PeeTk3rVUDv3JMiEyJOn2/XdThJLQe0MLPG3Aas=; b=EYI3Qvn7J6K3M91VoOFva/TrufsmPHV9cEprUBNMIhEik2Wqc+KdEKloBmD5l31kO/H0Nr fXLmvJlg3lYl+Quos9xcuv70vwlhmTWS56LAfs1fGhonavpYPxaHuTb22G0aV2Slm/qFG1 ZsnNYTyx6k2DhczFA4ju4BPmdJIp6CXUsjdl6a99nqQeGt2HgLNrDepfv1wmzbC8aMTjtL 2cE/SgBHyvYuVo+ObQ1hcU8QZUcEt4abK5qLO0fRglzKkIlCDvpwF+p0/WLG73DCEXiZoJ 0DYHG8aawuIFn3+YJXtIuplsKJ0ZnmtmPjUZIkehepQ4LdYNI1NiA56EAS69cA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VGSdf2dH5z13jm; Fri, 12 Apr 2024 20:21:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43CKLge6095875; Fri, 12 Apr 2024 20:21:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43CKLgB5095872; Fri, 12 Apr 2024 20:21:42 GMT (envelope-from git) Date: Fri, 12 Apr 2024 20:21:42 GMT Message-Id: <202404122021.43CKLgB5095872@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org From: Tijl Coosemans Subject: git: 5842d08c97cd - 2024Q2 - security/gnutls: initialise libpthread List-Id: Commits to the quarterly branches of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tijl X-Git-Repository: ports X-Git-Refname: refs/heads/2024Q2 X-Git-Reftype: branch X-Git-Commit: 5842d08c97cdecf1e3f8e2c536adb0aac3191574 Auto-Submitted: auto-generated The branch 2024Q2 has been updated by tijl: URL: https://cgit.FreeBSD.org/ports/commit/?id=5842d08c97cdecf1e3f8e2c536adb0aac3191574 commit 5842d08c97cdecf1e3f8e2c536adb0aac3191574 Author: Tijl Coosemans AuthorDate: 2024-04-12 19:03:35 +0000 Commit: Tijl Coosemans CommitDate: 2024-04-12 20:20:49 +0000 security/gnutls: initialise libpthread To ensure thread-safety libgnutls calls libpthread functions but to avoid the overhead for single-threaded programs it does not link with libpthread. It only calls libpthread if the executable or another library links to it. Since 3.8.0 libgnutls calls pthread_key_create from its init function but because it does not link with libpthread libpthread might not have been initialised yet. Patch the libgnutls init function so it initialises libpthread. PR: 278076 (cherry picked from commit 9ffc65e659a32a4eb293afd5c4d03be553a61570) --- security/gnutls/Makefile | 1 + security/gnutls/files/patch-lib_global.c | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/security/gnutls/Makefile b/security/gnutls/Makefile index f72a03894fb0..d7d190bce6f5 100644 --- a/security/gnutls/Makefile +++ b/security/gnutls/Makefile @@ -1,5 +1,6 @@ PORTNAME= gnutls DISTVERSION= 3.8.5 +PORTREVISION= 1 CATEGORIES= security net MASTER_SITES= GNUPG/${PORTNAME}/v${DISTVERSION:R} diff --git a/security/gnutls/files/patch-lib_global.c b/security/gnutls/files/patch-lib_global.c new file mode 100644 index 000000000000..967aa49a5877 --- /dev/null +++ b/security/gnutls/files/patch-lib_global.c @@ -0,0 +1,43 @@ +--- lib/global.c.orig 2024-04-11 15:36:24 UTC ++++ lib/global.c +@@ -29,6 +29,13 @@ + #include "random.h" + #include + ++#if __FreeBSD__ ++#include ++#if __FreeBSD_version >= 1400094 ++#include ++#endif ++#endif ++ + #include "hello_ext.h" /* for _gnutls_hello_ext_init */ + #include "supplemental.h" /* for _gnutls_supplemental_deinit */ + #include "locks.h" +@@ -520,6 +527,26 @@ static void _CONSTRUCTOR lib_init(void) + if (ret == 1) + return; + } ++ ++#if __FreeBSD__ ++#if __FreeBSD_version >= 1400094 ++ /* This dlopen call initialises libpthread if it is present. Normally ++ this is handled by linking to libpthread but libgnutls does not link ++ with libpthread to avoid the overhead for non-threaded programs. */ ++ (void) dlopen("libpthread.so", RTLD_LAZY | RTLD_GLOBAL | RTLD_NOLOAD); ++#else ++ /* The dlopen call above does not work correctly on older versions of ++ FreeBSD. Call pthread_mutex_timedlock instead. It initialises ++ libpthread and there's no libc stub that can preempt it. */ ++#pragma weak pthread_mutex_timedlock ++ if (pthread_mutex_timedlock != NULL) { ++ pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; ++ pthread_mutex_timedlock(&lock, NULL); ++ pthread_mutex_unlock(&lock); ++ pthread_mutex_destroy(&lock); ++ } ++#endif ++#endif + + ret = _gnutls_global_init(1); + if (ret < 0) {