From nobody Tue May 6 22:15:30 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 4ZsXlR11cZz5vXc2; Tue, 06 May 2025 22:15:31 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZsXlQ4FbPz3d3p; Tue, 06 May 2025 22:15:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746569730; 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=KcoHJseKh6CSQTkQaG16gnLmhyJ1IuKD0fWpUM6K6Gs=; b=OMBpWycNEkKX37cTRzF4MtBnCGZMAISWKD66HELIyeH+lH/PdOQKOjLWRqbcHHqEy/+MMk qpiwJLxaHEDnN1hbBJuuKAO3arFiGiQhBDI1ShNS+tu/rWRKBbAib8F/8VjmZovT8nO9mU z39qUqWAJgVTdnpttBZjZ9InnVm/Raun1nqcqMjNqaV7XvGs+59Z4YMRAo5bDgUx/cPRj/ CW17NkKSZQbbpAxSbw+cY3PdB+PP88jCWUUZwVxG6u1Jw2bsbPXbpHcyo4GC3wNvNkyGPn UtqqKuRRQ3bSoFNH6FMRwL6MHnkEgtp7PQ8+F6q42bYbGuna0fhD00Jqx4wBVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746569730; 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=KcoHJseKh6CSQTkQaG16gnLmhyJ1IuKD0fWpUM6K6Gs=; b=op8IcNlc2Z/zLYRZsxYVwXMpQKJ8l0MH8IJhOEUhure2LoPhCZ9UCt0mzx2Mswc5e/VzFN pLPALfsbfdHllFFIuP6tEByfrkGelmhYa2WAX2H4aFTBhz1tWlmVLVqx4uNsNsDe1chebU cjPdjgShoLB7oSiJUqgo1bXcQxxv+q05ILbJ3TXKDGvZfsgLnqBPSojPUW3qt4PNEXM2lG y/sISwzC6eb+5eT2TalzszXSlLSO1gU26kJXEZuBHaHn087gNNfwUQUAcyE6QLdv4S42k0 qO7aLZNDr0DHVa6oCb2P0UdSKR6jziGkMYndyTOWEtvr9xw6lIWMbDUrncFsPw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746569730; a=rsa-sha256; cv=none; b=LvEpaFIdWp/Z9AWrUfpHltWOgtWDlP4vCjR6ZrXXLGJVcwXN0Gh6i3fhEVPj1cgjAoINcJ XNyY/2Jce1XzJ9p58QOq7c/Q/+mOo1UBpKdCo3DZ7X2VzSA+1OELwfCCuN5+NbFptUg39d GS0iFvEqj+qRDtCp6pbMz7c3DhODbR58uW62IyZhFlYNwuzbynm6w16Ptx9poyMWpBm4HJ f4jYjkVUw4uaxKIkUXW68g0yJ96kRIblAeI7u63LN6Ew6AmfyYojq5Gdfix//BsjUxpDG1 xyaSqUQMylN10w2uuGSaBhkinH0z9d12Xf4jFPYpX6k4cCckZZE4OLuOBK+zDg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4ZsXlQ3bYkz1HKK; Tue, 06 May 2025 22:15:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 546MFUGs062934; Tue, 6 May 2025 22:15:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 546MFUWn062931; Tue, 6 May 2025 22:15:30 GMT (envelope-from git) Date: Tue, 6 May 2025 22:15:30 GMT Message-Id: <202505062215.546MFUWn062931@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 78b99f369f75 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 78b99f369f75f5df49b506ae750659b07ab34362 Auto-Submitted: auto-generated The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=78b99f369f75f5df49b506ae750659b07ab34362 commit 78b99f369f75f5df49b506ae750659b07ab34362 Author: Jessica Clarke AuthorDate: 2025-05-06 22:14:50 +0000 Commit: Jessica Clarke CommitDate: 2025-05-06 22:14:50 +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 --- 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 bffee3952e0d..ae1c8d83df19 100644 --- a/lib/libc/gen/dlfcn.c +++ b/lib/libc/gen/dlfcn.c @@ -229,7 +229,7 @@ _dl_iterate_phdr_locked( 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; phdr_info.dlpi_tls_data = __tls_get_addr(&ti); ret = callback(&phdr_info, sizeof(phdr_info), data); return (ret);