From patchwork Tue Sep 3 16:05:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1980144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=L4CJZHZj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wyr8T1H9Zz1yZ9 for ; Wed, 4 Sep 2024 02:06:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9DD37386182A for ; Tue, 3 Sep 2024 16:06:13 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 20A35384F027 for ; Tue, 3 Sep 2024 16:05:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20A35384F027 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 20A35384F027 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725379511; cv=none; b=RT7wV7bSBIt2nh1bfEMNx2CtImOm1c3cY6izBKXe5IkVRFjGAxlixWetYyklO9UInPtMgNtMtpkWg8S/4mVbAelk1HKMxy+gFGs64HSnys0T7nxBhMeF5ZmROlQMp7zwaebZUc9V1/hbBHBhPaZRWb4v7NS/OHovMIKCe6z6ljs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725379511; c=relaxed/simple; bh=+4DQeHQvGA0ztjd4r981abM8MCe08QkqHE+ZhQ3IrP4=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=xc4D2TLmDsLwh6Mv24KitwgblGKmpWJKCPEUs8Gp2G1sA7czL6Reir2oqR0ANhssGBkRJBSpcmAURnohCcY56HjCV5pyA24ZjhXJl5GbMVu7p6yGOQ3ywtv20JydCD0ADaXF2nLtCeHOWVVcYnIpJ8kBuVeMmCSFSUbbaxPxPb4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725379508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XReK8a0FTqADISTP1ULJK/LmeHMfZ9LCkjHzvoqehAw=; b=L4CJZHZjn3KU9AgXFiOudwnaW6zVG/zCnhk0ytBqNOq1/l+zjdG/3drLAH1LXAYhxfOc6W fVo5zSkvYS4CRf2QXgtedrkZ9U7uyBlp5+jPykP8uCRa7ApWi4uuuuvR/mGkuNwO7VJ4S1 LmdL2RLlbQxVDiAzviflJM5gLnPOsKg= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-RgFRgjVRPUKor53soxfVxg-1; Tue, 03 Sep 2024 12:05:07 -0400 X-MC-Unique: RgFRgjVRPUKor53soxfVxg-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD5081955BF6 for ; Tue, 3 Sep 2024 16:05:06 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.4]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DD0651955F1B for ; Tue, 3 Sep 2024 16:05:05 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v2 3/4] elf: Call la_objclose for proxy link maps in _dl_fini (bug 32065) In-Reply-To: Message-ID: <075f5d6cae8dc081de56048134dd53da6a29b605.1725379370.git.fweimer@redhat.com> References: X-From-Line: 075f5d6cae8dc081de56048134dd53da6a29b605 Mon Sep 17 00:00:00 2001 Date: Tue, 03 Sep 2024 18:05:03 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org --- elf/dl-fini.c | 9 +++++++++ elf/tst-audit23.c | 19 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/elf/dl-fini.c b/elf/dl-fini.c index db996270de..a1a4c25829 100644 --- a/elf/dl-fini.c +++ b/elf/dl-fini.c @@ -69,6 +69,7 @@ _dl_fini (void) unsigned int i; struct link_map *l; + struct link_map *proxy_link_map = NULL; assert (nloaded != 0 || GL(dl_ns)[ns]._ns_loaded == NULL); for (l = GL(dl_ns)[ns]._ns_loaded, i = 0; l != NULL; l = l->l_next) /* Do not handle ld.so in secondary namespaces. */ @@ -84,6 +85,11 @@ _dl_fini (void) are not dlclose()ed from underneath us. */ ++l->l_direct_opencount; } + else + /* Used below to call la_objclose for the ld.so proxy + link map. */ + proxy_link_map = l; + assert (ns != LM_ID_BASE || i == nloaded); assert (ns == LM_ID_BASE || i == nloaded || i == nloaded - 1); unsigned int nmaps = i; @@ -122,6 +128,9 @@ _dl_fini (void) --l->l_direct_opencount; } + if (proxy_link_map != NULL) + _dl_audit_objclose (proxy_link_map); + #ifdef SHARED _dl_audit_activity_nsid (ns, LA_ACT_CONSISTENT); #endif diff --git a/elf/tst-audit23.c b/elf/tst-audit23.c index 55929c2fd4..71adbe6942 100644 --- a/elf/tst-audit23.c +++ b/elf/tst-audit23.c @@ -241,13 +241,26 @@ do_test (int argc, char *argv[]) } } + Lmid_t lmid_other = LM_ID_NEWLM; + unsigned int other_namespace_count = 0; for (size_t i = 0; i < nobjs; i++) { - /* This subtest currently does not pass because of bug 32065. */ - if (! (endswith (objs[i].lname, LD_SO) && objs[i].lmid != LM_ID_BASE)) - TEST_COMPARE (objs[i].closed, true); + if (objs[i].lmid != LM_ID_BASE) + { + if (lmid_other == LM_ID_NEWLM) + lmid_other = objs[i].lmid; + TEST_COMPARE (objs[i].lmid, lmid_other); + ++other_namespace_count; + if (!(endswith (objs[i].lname, "/" LIBC_SO) + || endswith (objs[i].lname, "/" LD_SO))) + FAIL ("unexpected object in secondary namespace: %s", + objs[i].lname); + } + TEST_COMPARE (objs[i].closed, true); free (objs[i].lname); } + /* Both libc.so and ld.so should be present. */ + TEST_COMPARE (other_namespace_count, 2); /* la_activity(LA_ACT_CONSISTENT) should be the last callback received. Since only one link map may be not-CONSISTENT at a time, this also