From nobody Mon Mar 18 15:53:18 2024 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 4TyzsW2gXjz5Dyk4; Mon, 18 Mar 2024 15:53:19 +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 4TyzsV6zWVz4cf8; Mon, 18 Mar 2024 15:53:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710777199; 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=N9qcZuR7pH+P0BN3IlxzHT2ZjGZqBCHQKefzugKaloI=; b=xYY+rXXg0jfQl58BAacT+jM+Mx/a/kVnk2PStx8qvBP5fjEO+VOy2zMgOpXAcD2pa0ONBi 6XMbx5VZvZb0PR6NTwYCKvWvL4EiEgeCi9glLX4ib+jhVlwPF4hhGA6od6nc6i4Oz0eUR4 RUC1AJi+GP0p2G1zPQsKkEXilDqLiuUK7BEngy/HEhRFgNexgzCIYbjam/s7m8epwB2H8D sVti99Nrcqvu+kWVxXIFfhe5IQpOl6fwMbkvNN+f/VD1MvKeKgY04iqZfFxOje2f/UOHBk UdHaEdVSPetmPz5SsQb+UBG0stGcDMkX73vxUiTxqKqsWHCsi02fdC8TzTN/aw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710777199; a=rsa-sha256; cv=none; b=gTZxzUa4jH4xeWBJXg3gZ+ksiqsrZu4aUdL8epms47Gf3fcG5nqYM9Lyg3lexS1HJ/4QYp 3TUt9atPyyvXkKAhcxu+vWZMw9FvvuCVfDuQdNnFesXCSDxSqu2yet6s0y5CyZLKk+J1gD R2jxZbKai6X3z371mtaM9GxLIWVfR4rnNQICHc9+9NxT9NcT0dAgDy12GipVgKFOJUEoT5 MSHWan4S2DntY1OEJIoOeIbytTKtFVlYgVq1u0tb2uCV1zP62W1CRr/aUMrBlIKhaKbDzY vD53rTV7iHYQyb0KyUwGYMRx3/ruj3y1miiDKkuE9faecmGpVw7+bu7GhRPMRA== 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=1710777199; 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=N9qcZuR7pH+P0BN3IlxzHT2ZjGZqBCHQKefzugKaloI=; b=e5h/2JO43uaNg11YIsk/TcqXJG5YHp74DmBl8jLZ4dEISC0AKtENbQcgNM5lAHGpqFe18L dQ6bgURhQLSP+JI5gmzdJFyD0dwmpjwWRf1nZcsETSRrN1feSYiUIzsKldB2KWuIFh3ZVx K+ZLebh9Uf3h2HcWpJ3s0RyBbpJVLUygDg4XwXYZQIhRJwPMru0Bcy/7V1KbP7HMAsOYg0 Er+m0Zy3wmEi4xnlfNHevZif7iZwbcCZcOs9ExRyekS3gIWrq+c/qeapWwbU2DqwvjAUMy ZyJ2Lb837EhBGnVVbAjYMguXWQIwrRDIZseAyAwKqm9djrbouO+l97+xhShPUg== 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 4TyzsV5JXlzTr2; Mon, 18 Mar 2024 15:53:18 +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 42IFrIfr001184; Mon, 18 Mar 2024 15:53:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42IFrI16001181; Mon, 18 Mar 2024 15:53:18 GMT (envelope-from git) Date: Mon, 18 Mar 2024 15:53:18 GMT Message-Id: <202403181553.42IFrI16001181@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: a7b90458a293 - stable/14 - rtld: add some dlopen tests 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: a7b90458a2931366faa24deee914c3fb75f8ed1b Auto-Submitted: auto-generated The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=a7b90458a2931366faa24deee914c3fb75f8ed1b commit a7b90458a2931366faa24deee914c3fb75f8ed1b Author: Kyle Evans AuthorDate: 2024-02-13 15:38:02 +0000 Commit: Kyle Evans CommitDate: 2024-03-18 15:52:57 +0000 rtld: add some dlopen tests dlopen_basic just tests that libthr.so can be dlopen()ed, which will just serve as a sanity check that "libthr.so" is a thing that can be dlopened in case we get a weird failure in dlopen_recursing. dlopen_recursing tests a regression reported after the libsys split, where some dlopen() may cause infinite recursion and a resulting crash. This case is inspired by bdrewery's description of what seemed to be causing his issue. The corresponding fix landed in commit 968a18975ad ("rtld: ignore load_filtees() calls if we already [...]") Reviewed by: kib (cherry picked from commit c5796f1572c82b88e8b6a2810c92f30e5ac3e118) --- libexec/rtld-elf/tests/Makefile | 2 ++ libexec/rtld-elf/tests/dlopen_test.c | 52 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/libexec/rtld-elf/tests/Makefile b/libexec/rtld-elf/tests/Makefile index 06e143a441a1..e380e9850fc1 100644 --- a/libexec/rtld-elf/tests/Makefile +++ b/libexec/rtld-elf/tests/Makefile @@ -13,6 +13,8 @@ ATF_TESTS_C+= ld_preload_fds SRCS.$t= $t.c common.c .endfor +ATF_TESTS_C+= dlopen_test + WARNS?= 3 .include diff --git a/libexec/rtld-elf/tests/dlopen_test.c b/libexec/rtld-elf/tests/dlopen_test.c new file mode 100644 index 000000000000..ab1e8da1cb41 --- /dev/null +++ b/libexec/rtld-elf/tests/dlopen_test.c @@ -0,0 +1,52 @@ +/*- + * + * Copyright (C) 2024 Kyle Evans + * + * SPDX-License-Identifier: BSD-2-Clause + * + */ + +#include + +#include + +ATF_TC_WITHOUT_HEAD(dlopen_basic); +ATF_TC_BODY(dlopen_basic, tc) +{ + void *hdl, *sym; + + hdl = dlopen("libthr.so", RTLD_NOW); + ATF_REQUIRE(hdl != NULL); + + sym = dlsym(hdl, "pthread_create"); + ATF_REQUIRE(sym != NULL); + + dlclose(hdl); + + sym = dlsym(hdl, "pthread_create"); + ATF_REQUIRE(sym == NULL); +} + +ATF_TC_WITHOUT_HEAD(dlopen_recursing); +ATF_TC_BODY(dlopen_recursing, tc) +{ + void *hdl; + + /* + * If this doesn't crash, we're OK; a regression at one point caused + * some infinite recursion here. + */ + hdl = dlopen("libthr.so", RTLD_NOW | RTLD_GLOBAL); + ATF_REQUIRE(hdl != NULL); + + dlclose(hdl); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, dlopen_basic); + ATF_TP_ADD_TC(tp, dlopen_recursing); + + return atf_no_error(); +}