From nobody Mon Dec 15 17:00:22 2025 X-Original-To: dev-commits-src-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 4dVRBt3jqCz6L1bY for ; Mon, 15 Dec 2025 17:00:22 +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 4dVRBt1yVLz3pj9 for ; Mon, 15 Dec 2025 17:00:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765818022; 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=gfc0snAt61es37fw0TsPaiGbKPlTtzaOcACdvJEdoA8=; b=tuOJf0xOQEIKjh9MHO2clmTz73QFJveVVdZ/qfLEVm3Vq5YSn9NuNeoe+4JsSuxgqnoaLv 5/LlJSjuWLqTGMH/xNm2UlBTNUE3AYfBYU76X4x2pBW2ybrg3lcdaaH2Q9CVwjAfbmY6ot 99z6fKfaLlLFOaVPHNcU8ciumxDaH6UyHQLzJ8/tCiMzcxgH1NL8pe4Dp/kEYsTL+NElv2 SCUUd6fkXYay9N06BHMudVlrA92aku1I7uO4y/0crESW9yCa05kovJpwoxWTNk/AFGZqmF PJsGqkCTEsk2s2/eYv2gLB7c8CyJ5oXPC+GEFpspJzo0ZS6GrOLMF/WHJ7N26w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1765818022; 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=gfc0snAt61es37fw0TsPaiGbKPlTtzaOcACdvJEdoA8=; b=KDeNw1JYlmn4hznoUCz9TB7ZPvDziPPrlOMJa5AFohNxUsCdxhFrdsHxKtfLGBdpAD71eH m9mU6PWgPnz+eH7WCxbBl8ShIk+3QR25i9ej4TrOHWwjhqRM0ytR1A06crM8KiY/WrrIic eXh5ujbQ+6q0NXiGrjpJKaJNX/gUetGjPV5ugp06i7BcCVM+WmqLYzhdB2hYPrh2806Sgu ihP/E4UPrK8+Mi+IFWNhFzlRIvQyHsC34CMcftx7pW0cyRCAQwymauc8SNBjf3lOn5nj8X XYXTi9rwGGChAvu6/G9TjwLkXeX5DqX4hDa7RDpRVmsLDpBfsX2h+1AZhP34cQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1765818022; a=rsa-sha256; cv=none; b=IVbcbFoY0JHpGR/0Kb+8LFna3qnevNCJbH0pjc5lpFunlgAbtHaQ7qxPma/vXwvsEm+F9w SDHrFliT3puj9eS1JgpS0VP0DEVOa9ZFW9AANrO6SewPrkY5YjAHQRqOD09kZnDOntpyoJ H/vxXL+A1gUsZnvy5kR9RH2wTEKefO4KeQD81kbx5bZV4YQdt4J+8ByrqkVfoXhoUQVLFf oSAoC78Uu46tmtmlqBqm5piw9gAIUkGhNjuWe/IIaP0n4+Fm2oFkYykGbNwMftLq4BRe0M tmmtDNLZ4RCIdi2qLM65XNOjUyG7OGI2P78981g8UwrnVg3Ttf4xHJFZfYcbKQ== 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 4dVRBt0nTlzCWD for ; Mon, 15 Dec 2025 17:00:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id de21 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 15 Dec 2025 17:00:22 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jessica Clarke Subject: git: 11d41989cc62 - stable/14 - libc: Fix dl_iterate_phdr's dlpi_tls_data for PowerPC and RISC-V List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: 11d41989cc62c8812c5f6140d1c1877575f09aad Auto-Submitted: auto-generated Date: Mon, 15 Dec 2025 17:00:22 +0000 Message-Id: <69403ea6.de21.2b71f604@gitrepo.freebsd.org> The branch stable/14 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=11d41989cc62c8812c5f6140d1c1877575f09aad commit 11d41989cc62c8812c5f6140d1c1877575f09aad Author: Jessica Clarke AuthorDate: 2025-05-06 22:14:50 +0000 Commit: Jessica Clarke CommitDate: 2025-12-15 16:58:44 +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 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);