From nobody Mon Dec 15 18:18:49 2025 X-Original-To: dev-commits-src-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 4dVSxQ03pbz6L7KF for ; Mon, 15 Dec 2025 18:18: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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dVSxP4jg5z4Lcc for ; Mon, 15 Dec 2025 18:18:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765822729; 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=aA8ZSGtTVaumKxm3iCoazNvv7v4SM/KFK/QMX9lU9zo=; b=p4O3gpRxQdD4ktpggrGx7ZYMgwn/VkrBh+hvf4hew4WiiBDdgztJ0uHo5vCByUOq0Fwzdx roH6pI76cew2t763oBuZHxV8IaprlwZaKIBM3053LB5muIX2kuhutgMhNZ8OBkSaU3QPLt Xa6WKgpez0CzBxb/8TLB7QisRPW/CAU55kW2coC09xbwz9PbEw7aF91ZQCw2YGxZe4UWWT J6kCfF95/xuAM8jXlBolSJvno+osS5JQ9X3Y56VaMA/q8qVSOj7lkmvh5kP96Mo5Ud/iPh InAeQP6jgZdEx+uC78W41rtumwJh4L5zWCxdF4/VPw7jIpR4VKe3kzCJnHLy8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765822729; 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=aA8ZSGtTVaumKxm3iCoazNvv7v4SM/KFK/QMX9lU9zo=; b=G/Iwy/eA57dNmeveYQCM02+VusErV7+/EUZREE3I36Jf8oGD+nbo+AJbwmpRgA9exdJZkv ZOWHU/kShSMLyHUMBz4DZtmbFqR2BOW7s/7H+V6bQkMXQaXXq4OAz8n02e2QtjaQ6kViFK kr7cAJ8XVRXyNc3Gaz4b7VTP5vMJBeVDz9LodeWBQ9/DYFW6dwy4F/A3koSmOxofbXJ9jA +jXHGAtNnUEsy30NP8Yc/QMVk2af5QOxbKwWOq+V7d9IbOzgj3fMb6HGOAybidQBqrE+S/ wbGh5Zd3TKVpTG6iGL0TBQuMiEal9WvJQZgNh1HtJCuh0OKWe0dQ44XNNmij7Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1765822729; a=rsa-sha256; cv=none; b=gak3JwfHBRzaHHp9wcmv3/nvRSeNPsAX0wI07M+M0pfBFEQ+js9Ft9OlXef2HGx6ug6/DE WP97v9/5+wTiUEJTsWyWDWjyJJzRZZ8954eePLAPNnM2PFWvryYQ1VS6iUle8O47JCbObO 2svvaptyqptxQTSLpCngulkwCSb6aHbnkqRdCZiYyIf7WO/qTfIZ7RS5Vw9lXvc+O9g6NJ nFkRO5fjfu4gIgVzjjZkJ77poJg2YNAT+CU3+vTRe624m8DAdREGwKwqU77178Eldn+8BK MoiuCMbHiIxBh1tqNNl2zQDU9d+mR5FF7zn8599hMPlroAk3uYe94P9K5i24Rw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dVSxP493ZzWdt for ; Mon, 15 Dec 2025 18:18:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2553c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 15 Dec 2025 18:18:49 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jessica Clarke Subject: git: 03d5ae50dc7f - stable/13 - libc: Fix dl_iterate_phdr's dlpi_tls_data for PowerPC and RISC-V List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 03d5ae50dc7f2c12427c937d374a679901eaf9dc Auto-Submitted: auto-generated Date: Mon, 15 Dec 2025 18:18:49 +0000 Message-Id: <69405109.2553c.2c5e2c77@gitrepo.freebsd.org> The branch stable/13 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=03d5ae50dc7f2c12427c937d374a679901eaf9dc commit 03d5ae50dc7f2c12427c937d374a679901eaf9dc Author: Jessica Clarke AuthorDate: 2025-05-06 22:14:50 +0000 Commit: Jessica Clarke CommitDate: 2025-12-15 17:56:36 +0000 libc: Fix dl_iterate_phdr's dlpi_tls_data for PowerPC and RISC-V The implementation of dl_iterate_phdr for statically-linked binaries abuses __tls_get_addr to get to the start of the TLS block. For most architectures, tls_index's ti_offset (relocated by DTPOFF/DTPREL for GOT entries) is just the offset within that module's TLS block. However, for PowerPC and RISC-V, which have a non-zero TLS_DTV_OFFSET and thus are designed assuming DTV entries are biased by that value, ti_offset normally has TLS_DTV_OFFSET pre-subtracted. By using an offset of zero here we end up getting a pointer TLS_DTV_OFFSET past what __tls_get_addr would return for the first TLS variable. Fix this by using -TLS_DTV_OFFSET to mirror what the General Dynamic GOT entry for the first TLS variable would be. (Note this also applies to MIPS on stable/13) Reviewed by: kib Fixes: dbd2053026a6 ("libc dl_iterate_phdr(): dlpi_tls_data is wrong") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D50182 (cherry picked from commit 78b99f369f75f5df49b506ae750659b07ab34362) --- lib/libc/gen/dlfcn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c index b6dab041bac3..c554deb0e5fc 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -226,7 +226,7 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused, return (1); _once(&dl_phdr_info_once, dl_init_phdr_info); ti.ti_module = 1; - ti.ti_offset = 0; + ti.ti_offset = -TLS_DTV_OFFSET; mutex_lock(&dl_phdr_info_lock); phdr_info.dlpi_tls_data = __tls_get_addr(&ti); ret = callback(&phdr_info, sizeof(phdr_info), data);