From nobody Fri Jun 26 10:26:42 2026 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 4gmsKh1zSnz6jGtB for ; Fri, 26 Jun 2026 10:26:48 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gmsKg6K8lz3yf2 for ; Fri, 26 Jun 2026 10:26:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782469607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UloS225M8vCaQe3Iwhghw4C4a21RT+wOwXkWvJabtnQ=; b=MRzL6F1uWxa3zPwLPqT19Wc3d7u+2gcYdyeq4BgR3jqCzOSq/Z6Kty0eW8e8Y+eOUMpZ6e Os3IgklVIrD6Cu2mwhR4Prk9/3Yz0Gey33DckCe/1oi2c+4UUM3PnJbK6H9SzMmYy5fVXp 5o+dpA1LOZ2GtLQYNZ1SLx6PXa8ARla6iMbQ3/bTzm6TELl4Z6EJN48gO+yGveVm2WDr9I hHWoaFh/7KY+KXdkCe2SfiXJV6+jgY2RctW81DZFrQJfvMIVrjjGY4lGrzT+kG/jO83BJo L0Mq/1gkAQYw/9i6RoiBIDa1PQibsneiRcPo/wlUKLuGhRS4mINbJbNBwozqVg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782469607; a=rsa-sha256; cv=none; b=RIquXMQ5qXrg6OxjNQtFG+3bEpns61OC0YbKTI0+pMeEJ4QwFrXYhHhz/KX2+JEW3B6Mbz SnsFGr3IBvszFzIbQf81lSdez1bb68LoEEg2V+O2G30rLx9ouWLAOTuGbiy7kppVj+sGIX K90sOGA6MQX1ePCMeuMfPvBTlxScNBK+JJ77Q4OErGKfIicY/vynEWK+sUlHjN7IMBfqLZ PF0JDVHJQ+ndA83mA2zYZblBsf8Cwz9RDuCtQ2T32f2q7XQ/Yk7cdiUnEHfu8Pl9IeWd+4 syDQ0o2mNOmlgjSeESM63VsYGuUjOCvbiEJ7UC+FdRNArA+enfNncUdTZ8UB+A== 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=1782469607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UloS225M8vCaQe3Iwhghw4C4a21RT+wOwXkWvJabtnQ=; b=Qgw9TMrs6Mief6K5DVNxyPdJhrFvj1EGz99dfyAaHLnLmmUnqSmmMnRSQDocjsUhUPDpLn yx/AQ2C40Ts8fqpudeCf5rxJUhO2LDvDvt+s0MXzX1uwhMJmjgwHlu7OsCR9bCXd67HPLk N+q+CLm8nIogN5RxkYETTm5P5W6yHIUQTUWMvaTr3LJjBGnkLJF5P432xKOM7s+ytVPQiN ED2bfxbWQDtgZrRxac4cg/2awAm48Xd0siaYMcN4eQf9sW4D48ll+8mtyNVUDM97mGFmIJ QmlSKQU9C26mR5oh7NcM8m2SGM3txCfsCc48gKYjo7A4et0F/wD6Rkr3AdBLCA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gmsKg4YNtzZJF for ; Fri, 26 Jun 2026 10:26:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 33614 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 26 Jun 2026 10:26:42 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Daniel Levin From: Pouria Mousavizadeh Tehrani Subject: git: 77cf9e791b93 - stable/15 - rtld: Check for -1 as an-end-of-section marker 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pouria X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 77cf9e791b93ace59422df8c123b11a535d7beec Auto-Submitted: auto-generated Date: Fri, 26 Jun 2026 10:26:42 +0000 Message-Id: <6a3e53e2.33614.417b947e@gitrepo.freebsd.org> The branch stable/15 has been updated by pouria: URL: https://cgit.FreeBSD.org/src/commit/?id=77cf9e791b93ace59422df8c123b11a535d7beec commit 77cf9e791b93ace59422df8c123b11a535d7beec Author: Daniel Levin AuthorDate: 2026-06-08 14:42:03 +0000 Commit: Pouria Mousavizadeh Tehrani CommitDate: 2026-06-26 10:20:55 +0000 rtld: Check for -1 as an-end-of-section marker rtld calls functions in the .init_array section one at a time, until it finds a distinguished sentinel value. The C runtime does the same thing (in crtend.c). However, that checks for the sentinel -1 and not 1. If one is using a linker that unifies .ctors and .init_array, then rtld will miss the sentinel value. I believe the author of this code intended to write -1 instead of 1. Indeed, changing the code to also check for -1 prevents rtld from attempting to call a non-existent function. The same is true of .dtors and .fini_array. Signed-off-by: Daniel Levin Reviewed by: kib MFC after: 3 days Pull Request: https://github.com/freebsd/freebsd-src/pull/2270 (cherry picked from commit 45a0cb52d3d62f8caae420b93e4b8c76ae3bc766) --- libexec/rtld-elf/rtld.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index a72726684f0f..2a05afe66902 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3159,7 +3159,8 @@ objlist_call_fini(Objlist *list, Obj_Entry *root, RtldLockState *lockstate) for (index = elm->obj->fini_array_num - 1; index >= 0; index--) { if (fini_addr[index] != 0 && - fini_addr[index] != 1) { + fini_addr[index] != 1 && + fini_addr[index] != (Elf_Addr)-1) { dbg("calling fini function for %s at %p", elm->obj->path, (void *)fini_addr[index]); @@ -3265,7 +3266,8 @@ objlist_call_init(Objlist *list, RtldLockState *lockstate) for (index = 0; index < elm->obj->init_array_num; index++) { if (init_addr[index] != 0 && - init_addr[index] != 1) { + init_addr[index] != 1 && + init_addr[index] != (Elf_Addr)-1) { dbg("calling init function for %s at %p", elm->obj->path, (void *)init_addr[index]);