From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 0F43B3858C2B for ; Mon, 22 May 2023 09:09:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0F43B3858C2B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684746592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tL5vlvzY5Rn2Jboq4kKVXVFU2lI3NFFnonny+dxaE5o=; b=OqEFBuUyC1TBN41FofPKvjgrhcqoZl8k7mht/mA5Y8RH3AnkydnNy8RBOOsk0iuNqG9gX6 9GtB408mRTFxmsMKIJZoiuy/XCpas8nCuJri1u49A5xjj4/t4vfU72/VTLFOBFlQgKBwN6 RAVpBE0UD0IrUEe4m9wvILnoiKSMr6g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-120-c0aHVaO8OmWumMx82OV8vQ-1; Mon, 22 May 2023 05:09:51 -0400 X-MC-Unique: c0aHVaO8OmWumMx82OV8vQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E42F4800B2A; Mon, 22 May 2023 09:09:50 +0000 (UTC) Received: from oldenburg3.str.redhat.com (unknown [10.39.195.128]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1833A7AF5; Mon, 22 May 2023 09:09:49 +0000 (UTC) From: Florian Weimer To: Andreas Schwab Cc: Florian Weimer via Libc-alpha Subject: Re: [PATCH] elf: Make more functions available for binding during dlclose (bug 30425) In-Reply-To: (Andreas Schwab's message of "Mon, 22 May 2023 10:33:40 +0200") References: <87zg5w6g0i.fsf@oldenburg3.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Date: Mon, 22 May 2023 11:09:48 +0200 Message-ID: <87ttw468bn.fsf@oldenburg3.str.redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.4 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_H2,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 List-Id: * Andreas Schwab: > On Mai 22 2023, Florian Weimer via Libc-alpha wrote: > >> diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c >> index 05f36a2507..c709ac4d33 100644 >> --- a/elf/dl-lookup.c >> +++ b/elf/dl-lookup.c >> @@ -366,8 +366,13 @@ do_lookup_x (const char *undef_name, unsigned int new_hash, >> if ((type_class & ELF_RTYPE_CLASS_COPY) && map->l_type == lt_executable) >> continue; >> >> - /* Do not look into objects which are going to be removed. */ >> - if (map->l_removed) >> + /* Do not look into objects which are going to be removed, >> + except when the referencing object itself is being removed. >> + The second part covers the situation when an object lazily >> + binds to another object while running its destructor, but the >> + destructor of the other object has already run, so that >> + dlclose has already set l_removed. */ > > But if the destructor has been run already, it is no longer safe to call > functions from that object. The library author can take steps to make this work. Escaping from the l_removed check is not so easy in general. The change makes the lazy and BIND_NOW cases more similar (with BIND_NOW, the call is successful, despite the already-called destructor), and also aligns with the constructor scenario: we already allow binding to symbols of objects whose constructors have not run. Thanks, Florian