From patchwork Fri Aug 9 21:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 95611 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42B6A385E45C for ; Fri, 9 Aug 2024 21:45:05 +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 0713C385DDD5 for ; Fri, 9 Aug 2024 21:44:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0713C385DDD5 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 0713C385DDD5 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=1723239874; cv=none; b=Gv110CcmbgC1BMoMZ69a4cbFHMho91cmEBXv8q1IP6WCByeAx1INvahKMTiQ+wYupFPeShTTtqWnR7Czm6+Tw34tlZd/ayYi2MULS7Tacec5/X0r4ixsM+MiPOuibigcyZwE2FEBy78u74UmMPYsKCKc7drl2qVpAmWZxOn0HFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723239874; c=relaxed/simple; bh=XVIEHfbLIaePOVU9INUcRj3jd04Ov4xWtEOH/T7H/Js=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=Btfr3qMuBaRpyjMZr71kJz/esGQKVS4iC0v+yMouWUdZesgbeJ/pYgREdB9NKsWbl/mxlb0me6mQ+kIuIUgoQwxL98vHPfmeCsM0TxH2OjHPfaKcVLjWTLDbUu7MWhQPdzxN8HXl1bpYFQupCKvPA5aBanBvgiyPcsHx3lUyN4s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723239872; 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=FQ4mQHeqd3CZiD8P8TfAtX1VUDyzU4kpIw2zCmcaE+k=; b=W4PjLJeNMmmErv8CHnfIjI/d85f3MAxcxmXJWFLEe9AFL+mNS4+yirXGBsfWX4TzS4oliR jh71wgqLWymqEv6fSNIyl0LOglLBBEQRtCAgqYxH3yHRBnhl41/3VCBHAQ3ePX62waF30e u/D1U7iw5yi71uudWehI3aMt2/KSs7k= Received: from mx-prod-mc-02.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-196-UlbQ3JFoPWGiXzWbgPZT6w-1; Fri, 09 Aug 2024 17:44:30 -0400 X-MC-Unique: UlbQ3JFoPWGiXzWbgPZT6w-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 537A71955D5D for ; Fri, 9 Aug 2024 21:44:29 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.5]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 448DD1955F2C for ; Fri, 9 Aug 2024 21:44:27 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 2/3] elf: Call la_objclose for proxy link maps in _dl_fini (bug 32065) In-Reply-To: Message-ID: <987ab81cd241e6dd4d82bcd5ba68f1504ec89d85.1723239322.git.fweimer@redhat.com> References: X-From-Line: 987ab81cd241e6dd4d82bcd5ba68f1504ec89d85 Mon Sep 17 00:00:00 2001 Date: Fri, 09 Aug 2024 23:44:25 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 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, SPF_HELO_NONE, SPF_NONE, TXREP 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~patchwork=sourceware.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 8b3a09a7e1..09318981e3 100644 --- a/elf/tst-audit23.c +++ b/elf/tst-audit23.c @@ -225,13 +225,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