From nobody Tue Feb 13 14:24:41 2024 X-Original-To: dev-commits-src-main@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 4TZ3Vx4gMRz5BPvl; Tue, 13 Feb 2024 14:24:41 +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 4TZ3Vx2ZtYz4QbD; Tue, 13 Feb 2024 14:24:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707834281; 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=kjy/7WesmPH2LLgkmYgeq3pJJWbm6gmrLTrKzYD9Wjw=; b=iUGzDxyidAoi152KGAUHQIdqoPOElzpOVpcB0SWc5YcEzv5ZgqX8VQotNUtIW2CEjdGn2e zdfsYFGPKr6BADKPvHhW7hdeIjMoRQcNfhzqy6UgyXUzmUilU2fnP6IKpb8O4XY6JrZySp kchJ2gFmkjuHehDhGSGj2ZLXfb+TaO8tZyV+3Th0yp0XsRCPuUM1zzoPKe6ERvDJuk3oyZ qUOnAoH1P72IsNW0rnB1V38Htx3l9DwKKW430uMfyAiYnk+mWU8TrqEdAqH4Tn4D++bPu1 SQvTP3q/E1IpRmZI6YYP2PFw/JvwrSplfzRmSyhrf8mjkbCpTbsUlqhIGobFCQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707834281; a=rsa-sha256; cv=none; b=eMkV+v2fZuPzL14u0tE4/XrWcXx55jHytG/f3J5x0dnTayFF4THVjKZjBGTcqx0j/3Ftuw rE6WmTyvWeX5eJ9OOCW3bXgkwQpSVbaTMOhxD9TYENQQtTkLNXIZesFEM/E6YRt66AmusV C1MhteYMmrf0vTpZA1/BZAv6IRCGVx34L9+6qVUDgveDhlx6N67EFsIuUPcreEJ+QLzTQY zeuq6CRcVvKMFcJlfU+uUqO2uHaUqB1Ykis5HqTGMFwHpQH7KxreortbQDuagJWprRs5WP X3VlRepPJFBDlqJH7jSEGaUFT58VlC+Sy4sKLwOIRIGyca7O7KDmyCSRFqIoEQ== 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=1707834281; 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=kjy/7WesmPH2LLgkmYgeq3pJJWbm6gmrLTrKzYD9Wjw=; b=ncO/y1/6h/kYdEHQdCNlLy+cjCK8QLUEPuIyd9kgwe3dRJNgGAQ9K3dphnanRoFI22b4+t ZZ+bx1RImOtHfMgugWiVWBlaqZ//kwHcOTQiCaEEykP/tZ4V6tN9tb4Ompko08CEc0+uVD g9weAoUeHZO0S0vnF3PGoaXbfnfYwzVU2F05hhHgJG0D2C47xVOyTpqNHShL7hMGN6TLFU cllJhnglylxbytLfUxoKzFo5ed6D5z1rxEWl/TIkbwXdqGgHwHxs0gnuz9Qe880iv0I1u4 G3bk1txyiK+Mi3D3sC98uP6L9KdBOpF6mbNX+KWiZaPN6R9Rq3GoYHZeozUKlw== 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 4TZ3Vx1PCRzJX9; Tue, 13 Feb 2024 14:24:41 +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 41DEOfuS001391; Tue, 13 Feb 2024 14:24:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41DEOfTj001389; Tue, 13 Feb 2024 14:24:41 GMT (envelope-from git) Date: Tue, 13 Feb 2024 14:24:41 GMT Message-Id: <202402131424.41DEOfTj001389@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 968a18975adc - main - rtld: ignore load_filtees() calls if we already loading filtees for the obj List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 968a18975adc9c2a619bb52aa2f009de99fc9e24 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=968a18975adc9c2a619bb52aa2f009de99fc9e24 commit 968a18975adc9c2a619bb52aa2f009de99fc9e24 Author: Konstantin Belousov AuthorDate: 2024-02-13 01:09:03 +0000 Commit: Konstantin Belousov CommitDate: 2024-02-13 14:24:01 +0000 rtld: ignore load_filtees() calls if we already loading filtees for the obj in addition to avoiding it for already loaded filtees. Issue is that during load, rtld needs to resolve some special ABI symbols, like executable stack fixer and static TLS initializer, which might trigger recursion. Example is libthr which is filter for libsys, and which exports __pthread_distribute_static_tls. Tested by: kevans, krion Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D43858 --- libexec/rtld-elf/rtld.c | 4 +++- libexec/rtld-elf/rtld.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index dfd9e74407ed..7d6b8ae52703 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2582,12 +2582,14 @@ load_filtee1(Obj_Entry *obj, Needed_Entry *needed, int flags, static void load_filtees(Obj_Entry *obj, int flags, RtldLockState *lockstate) { - if (obj->filtees_loaded) + if (obj->filtees_loaded || obj->filtees_loading) return; lock_restart_for_upgrade(lockstate); + obj->filtees_loading = true; load_filtee1(obj, obj->needed_filtees, flags, lockstate); load_filtee1(obj, obj->needed_aux_filtees, flags, lockstate); obj->filtees_loaded = true; + obj->filtees_loading = false; } static int diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index e8b15095812b..6311b3e6cc7f 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -263,6 +263,7 @@ typedef struct Struct_Obj_Entry { bool on_fini_list: 1; /* Object is already on fini list. */ bool dag_inited : 1; /* Object has its DAG initialized. */ bool filtees_loaded : 1; /* Filtees loaded */ + bool filtees_loading : 1; /* In process of filtees loading */ bool irelative : 1; /* Object has R_MACHDEP_IRELATIVE relocs */ bool irelative_nonplt : 1; /* Object has R_MACHDEP_IRELATIVE non-plt relocs */ bool gnu_ifunc : 1; /* Object has references to STT_GNU_IFUNC */