From patchwork Tue Sep 3 16:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1980142 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=NrRGevMF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4Wyr7X5H8zz1yZ9 for ; Wed, 4 Sep 2024 02:05:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D8ACA3865486 for ; Tue, 3 Sep 2024 16:05:26 +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 5AA00385EC2F for ; Tue, 3 Sep 2024 16:05:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5AA00385EC2F 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 5AA00385EC2F 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=1725379506; cv=none; b=x/VV3ieGZatiyQwJ+HDaOpVSStagwJzySXEsG1H+KA55xhc9tPDofyXV+kjr/l9Dm0a7gig2JDuaY2VsQpaR4avK4YqhFuj/euRriP0DO6P0c+z5Kxf7vhReSrJnVUL30l3UfcAb53V95YHy6wVU+67dTUCHN4xwdmKby5jKfuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725379506; c=relaxed/simple; bh=KQ3CTIhkYICLYhoyPyi0z250Q8SpvK8sL7TPEzuzbF4=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=m5AvhUSruGhx3EwMHqKLtZMicOGmQ+HU3r85vRnX7oYUZ6pvGp3o+j9+2dNal8juoxmiaN6Ssg8wRoADdRRz1oFpT9TBMcd5jJ64mcOeP10QZRU5bsFJQctey4tKYSxjQwEW6PWuzfyei5dbavaM9lbEZN/4nfnZiu+Z98hcXRA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725379504; 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=Ju1CVqbYYbv82rZJkVajrJcKT9eKcS5BAqbhs3Pcs5U=; b=NrRGevMF2ezO/PjRe711jlV/bZn/BlWQHjymM0YtjUq7/yIkJm6fyLbQxJYF6Sui+uXKYN 6ir5Jjg6nzZQ/d+Xm+CH44PG/G8lmLkh/bXi04Y91iliBMOGIw5hdBCMbS6WioVDH8ybGp nv6A2G1sO68cEGpj+XnSn5wBUw004Y8= 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-424-i3XC5pq1NhaDwOg3sZHp5g-1; Tue, 03 Sep 2024 12:05:02 -0400 X-MC-Unique: i3XC5pq1NhaDwOg3sZHp5g-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 210F91955D4C for ; Tue, 3 Sep 2024 16:05:02 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 46B991956052 for ; Tue, 3 Sep 2024 16:05:01 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v2 2/4] elf: Signal la_objopen for the proxy link map in dlmopen (bug 31985) In-Reply-To: Message-ID: References: X-From-Line: c8c06c0be4c0ae2232942db13f0bc2233390341b Mon Sep 17 00:00:00 2001 Date: Tue, 03 Sep 2024 18:04:58 +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=-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-load.c | 61 ++++++++++++++++++++++++++--------------------- elf/tst-audit23.c | 12 +++++++++- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/elf/dl-load.c b/elf/dl-load.c index 8a89b71016..54c9c4d779 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -918,6 +918,37 @@ _dl_process_pt_gnu_property (struct link_map *l, int fd, const ElfW(Phdr) *ph) } } +static void +_dl_notify_new_object (int mode, Lmid_t nsid, struct link_map *l) +{ + /* Signal that we are going to add new objects. */ + struct r_debug *r = _dl_debug_update (nsid); + if (r->r_state == RT_CONSISTENT) + { +#ifdef SHARED + /* Auditing checkpoint: we are going to add new objects. Since this + is called after _dl_add_to_namespace_list the namespace is guaranteed + to not be empty. */ + if ((mode & __RTLD_AUDIT) == 0) + _dl_audit_activity_nsid (nsid, LA_ACT_ADD); +#endif + + /* Notify the debugger we have added some objects. We need to + call _dl_debug_initialize in a static program in case dynamic + linking has not been used before. */ + r->r_state = RT_ADD; + _dl_debug_state (); + LIBC_PROBE (map_start, 2, nsid, r); + } + else + assert (r->r_state == RT_ADD); + +#ifdef SHARED + /* Auditing checkpoint: we have a new object. */ + if (!GL(dl_ns)[l->l_ns]._ns_loaded->l_auditing) + _dl_audit_objopen (l, nsid); +#endif +} /* Map in the shared object NAME, actually located in REALNAME, and already opened on FD. */ @@ -1018,6 +1049,8 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd, /* Add the map for the mirrored object to the object list. */ _dl_add_to_namespace_list (l, nsid); + _dl_notify_new_object (mode, nsid, l); + return l; } #endif @@ -1442,33 +1475,7 @@ cannot enable executable stack as shared object requires"); if (mode & __RTLD_SPROF) return l; - /* Signal that we are going to add new objects. */ - struct r_debug *r = _dl_debug_update (nsid); - if (r->r_state == RT_CONSISTENT) - { -#ifdef SHARED - /* Auditing checkpoint: we are going to add new objects. Since this - is called after _dl_add_to_namespace_list the namespace is guaranteed - to not be empty. */ - if ((mode & __RTLD_AUDIT) == 0) - _dl_audit_activity_nsid (nsid, LA_ACT_ADD); -#endif - - /* Notify the debugger we have added some objects. We need to - call _dl_debug_initialize in a static program in case dynamic - linking has not been used before. */ - r->r_state = RT_ADD; - _dl_debug_state (); - LIBC_PROBE (map_start, 2, nsid, r); - } - else - assert (r->r_state == RT_ADD); - -#ifdef SHARED - /* Auditing checkpoint: we have a new object. */ - if (!GL(dl_ns)[l->l_ns]._ns_loaded->l_auditing) - _dl_audit_objopen (l, nsid); -#endif + _dl_notify_new_object (mode, nsid, l); return l; } diff --git a/elf/tst-audit23.c b/elf/tst-audit23.c index ca4219c82b..55929c2fd4 100644 --- a/elf/tst-audit23.c +++ b/elf/tst-audit23.c @@ -52,6 +52,14 @@ startswith (const char *str, const char *pre) return lenstr >= lenpre && memcmp (pre, str, lenpre) == 0; } +static inline bool +endswith (const char *str, const char *suf) +{ + size_t lensuf = strlen (suf); + size_t lenstr = strlen (str); + return lenstr >= lensuf && memcmp (suf, str + lenstr - lensuf, lensuf) == 0; +} + static inline bool is_vdso (const char *str) { @@ -235,7 +243,9 @@ do_test (int argc, char *argv[]) for (size_t i = 0; i < nobjs; i++) { - TEST_COMPARE (objs[i].closed, true); + /* 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); free (objs[i].lname); }