From nobody Fri Apr 12 20:16:49 2024 X-Original-To: dev-commits-ports-all@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 4VGSX23jS1z5G37W; Fri, 12 Apr 2024 20:16:50 +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 4VGSX210Wjz4cTY; Fri, 12 Apr 2024 20:16:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712953010; 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=EkEBaKafsL+TX1bh7g+YJDHEgT2dIUO7aX6AC5Fpubg=; b=kBUHz1LTHoXZgvdg30AInAgeNMDgp4FC5n2+J7GqsYXp+LclXp+ertc4Mt/I0dcKJ8vAFf eUVqrr54vgRk8NdSIDtSbq6+s/b2FU+0A9cHIfW4E+Xb/qpIpXLnaPgMbD6TRLvMPeYDXg dZ4bdh/RcZwgLIeu6j5XvZ4TVSxiNxnQ6avAIDjhY+1I/5uEvfjxIKe2D8gq8AkHMBA55p eohC0BbpyM1ZJ2u1hXQAZEuOtBKzc2Tn04vUeNIOW7cqDKhIWcSnw6J2BiAKiOeu623eIe mdOqWZaylsef4hpd5xxveDMOJcf4vBZ72SAHMnMSY5q3J9T9Nw/u/Aa2dI2Czw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712953010; a=rsa-sha256; cv=none; b=L2lcsSsY5Y7E6pQ+wvV1VZXbk8bZ3ofuf1bJa9pQQKU5uo5CrSv1HESmT8oeYRQMQUQecE XTCIDhXeg+Nhi7ow5GfnQjbMGLIxLvbRgH/23rn9r6Yfj/IEvnb8wqlx4MRzFJv+L7Zi+Y YCFfe+MfHdCLj8o0MueGffkPUtG01iZ/NztwupmBUHKrHzTdAw6QkBgzsT3ZwiaJuY0U1h 18sDwv3tPz0GnikAURCOiCN5EdjjXrbJxp8qEFTWIIW4+FIxpLfDskCOYw6F2LZ6GgLAcj d5EP/cG81Y1vgk1Gkl6FU/MGR3yWYmW87WGeKEC22PpqjYeSbj4dJEDmDWxMow== 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=1712953010; 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=EkEBaKafsL+TX1bh7g+YJDHEgT2dIUO7aX6AC5Fpubg=; b=MKjzOX9uNY8ud6D0FiGZjDb+k3TmwsAQHXIC20lmdjkfg2LEX6KfcUXfwlqTqGtKbxD6Ia 01A18/jxBvt7PnC3UWZdVQ/HlSMhXdVbTHkY1CRvLJXxvAEn8gsw47EdQR6ZYx3WmJOymz 4hdiZr38UnYnHKF1uvyRXngxdCX3IGLDvoH5dRqgjnzUXKrpU0aoPgSbeRUX5azaS9h1y9 +VyitsOj3jc0dJs/REDzkzd9Jbx5LDzqoUCbhyZtfbLjP1MSXmg12e0la0AGJE5OyKiaLi ozDQz4oEG7mbrLUI2x864Fh4QButF45mXyELeMlDbG9OI8A+r52i5lXhRUvIgw== 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 4VGSX20V0qz12xx; Fri, 12 Apr 2024 20:16:50 +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 43CKGnxO081203; Fri, 12 Apr 2024 20:16:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43CKGnv8081200; Fri, 12 Apr 2024 20:16:49 GMT (envelope-from git) Date: Fri, 12 Apr 2024 20:16:49 GMT Message-Id: <202404122016.43CKGnv8081200@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Tijl Coosemans Subject: git: 9ffc65e659a3 - main - security/gnutls: initialise libpthread List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-all@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/main X-Git-Reftype: branch X-Git-Commit: 9ffc65e659a32a4eb293afd5c4d03be553a61570 Auto-Submitted: auto-generated The branch main has been updated by tijl: URL: https://cgit.FreeBSD.org/ports/commit/?id=9ffc65e659a32a4eb293afd5c4d03be553a61570 commit 9ffc65e659a32a4eb293afd5c4d03be553a61570 Author: Tijl Coosemans AuthorDate: 2024-04-12 19:03:35 +0000 Commit: Tijl Coosemans CommitDate: 2024-04-12 20:15:31 +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 --- 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) {