From nobody Tue Feb 13 15:38:35 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 4TZ58D1s37z594bJ; Tue, 13 Feb 2024 15:38:36 +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 4TZ58D1BF7z4fjb; Tue, 13 Feb 2024 15:38:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707838716; 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=o2GIeu+3Vnd9i0fOh8h60YSGrXjOgUl2+wXkcatWTXs=; b=InWij+rGbAXtYnBImlH1uZjmn+JzkyzzTTHsI94f6Ighe6FreMFpINdUth8iGFbatkvLHe C/KwYCN9ptE4c4rDxeukgNIDuq4sb9aObqh70JZF/jtlnHx6FQo9ByfYaNeiBGESC7Ldxt Irp0VvXi4XypTeg9RBjjzV1f1jABgjL1VgBvHtGd6AtShXhQV6ZngFzhct7y/cArwXYSQb +WyehEWGHHYoc8+r9SxUD4G8H+6wfP307i6xC1zMSAPXaJauopDXS3vd5pJglgbvOPC0j6 kpczoauZ57G42ponQq6irqUtl96PpFlv5yT/TEJVFkz8HMPTTnsm5z7xN38WKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707838716; a=rsa-sha256; cv=none; b=lnIMPvHNnzBM8j9P1YPNPGNuygr5PbyLKEZkj/ffkrPfiUzNHk5t/X3oib5WNlBFdk7Pfb xGt78yM19PVs2qgPdS36xntF51ZlDPkaDZMkzAU7vv+d7tZmKn4kp49no0AKn7s12o3YiK 54kTG349GpjNYMOEzIKdy2piQhXl4v7PFV4SwYJkhGzwLvCDm4yPHkFKDHDxVtnET7f1wh 4Sp53NxKsIedE95qvM2760LAUmMiU3hyDD7QsooC1ZDQbTKupdHmBPm4ICz8yu6hWDcHmV uIcu+zXefMpB//UgBslusLrime0l2VS/EBx8M3js22fHP9ScuVwyJLuH/Nx5dg== 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=1707838716; 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=o2GIeu+3Vnd9i0fOh8h60YSGrXjOgUl2+wXkcatWTXs=; b=yB6YEBk/2gCegb3UlYgdWFZtY0s3D5gVePrasjiTL/bXUT6ssq4pkXb9eVImqwNAH2lVbg Y8UMxnSenHe6TEINhUpnlVfhbhruhomMHKpHCyZqkWxtO4Up5F332/3F3ZiEo51/pCq4MQ QaOcuJNpHkcIasfjczkukZirlKoOTys2ThS6DOkeAheBSYdkceL79TtmJxSdCGzN6oTsNw vK3GWrg9SYzC7wvd5Ln5xQnJnkqnidezf3hp0eb3eSHfDYEA1WOb6asXT3dvUm0BQs5xPo 8iELBkEmX5ej1j4udYF/oXrMpV2aPF2+Xy01OxCSkQR0iYBv5wSFuwk9GDTG/Q== 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 4TZ58D04BgzLFk; Tue, 13 Feb 2024 15:38:36 +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 41DFcZAB018984; Tue, 13 Feb 2024 15:38:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41DFcZcR018981; Tue, 13 Feb 2024 15:38:35 GMT (envelope-from git) Date: Tue, 13 Feb 2024 15:38:35 GMT Message-Id: <202402131538.41DFcZcR018981@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: c5796f1572c8 - main - 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/main X-Git-Reftype: branch X-Git-Commit: c5796f1572c82b88e8b6a2810c92f30e5ac3e118 Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=c5796f1572c82b88e8b6a2810c92f30e5ac3e118 commit c5796f1572c82b88e8b6a2810c92f30e5ac3e118 Author: Kyle Evans AuthorDate: 2024-02-13 15:38:02 +0000 Commit: Kyle Evans CommitDate: 2024-02-13 15:38:02 +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 Differential Revision: https://reviews.freebsd.org/D43859 --- 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(); +}