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 5344B3858C33 for ; Wed, 24 Aug 2022 19:43:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5344B3858C33 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=1661370189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=H2e37mHejkoReKGCurjJ2tJZedrKZssZItTyFfWoL7k=; b=fdftebAZvq0EUFb5lNP6iceU43jwfNxQxh2AtT5709OKBZuc6Ue8wozc3TZwPSeZ3N3Rmm MaOkL5QrLJxt9rNEZ0JuovoTfnz1lvePuEQRoUmRbjUTjUk9tGFQIhc7OIWLow82fayRXu Wn6ZBE9s+1H5VpVAWRTEMOhECIMqu08= 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-480-yhCmIXqKPtatd0Q4V2fFbg-1; Wed, 24 Aug 2022 15:43:08 -0400 X-MC-Unique: yhCmIXqKPtatd0Q4V2fFbg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC6B0811E87 for ; Wed, 24 Aug 2022 19:43:07 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.78]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5FC41492C3B for ; Wed, 24 Aug 2022 19:43:07 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] elf: Initialize libc_map to NULL on namespace creation Date: Wed, 24 Aug 2022 21:43:05 +0200 Message-ID: <87mtbt5sxi.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.7 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,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: It seems that a stale libc_map value will be used (and not overwritten) by a dlmopen after a dlclose that has deallocated the namespace. This may not be visible easily because the libc link map can be allocated at the same address. Fixes commit ec935dea6332cb22f9881cd1162bad156173f4b0 ("elf: Implement __libc_early_init"). --- elf/dl-open.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/elf/dl-open.c b/elf/dl-open.c index dcc24130fe..582095a7fa 100644 --- a/elf/dl-open.c +++ b/elf/dl-open.c @@ -850,6 +850,10 @@ no more namespaces available for dlmopen()")); ++GL(dl_nns); } + /* Clear any potential dangling libc link map references. */ + GL(dl_ns)[nsid].libc_map = NULL; + GL(dl_ns)[nsid].libc_map_early_init = NULL; + _dl_debug_update (nsid)->r_state = RT_CONSISTENT; } /* Never allow loading a DSO in a namespace which is empty. Such base-commit: 6f85dbf102ad7982409ba0fe96886caeb6389fef