From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86ABB5028C for ; Fri, 10 Jan 2025 17:04:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736528680; cv=none; b=A9AXtd2gTNd0xG5w1gw5SNEMfXymtig7eZBsXNRIvDQEpSmWCXqi/x6TW5lfq80XKpZSpkiexsAknmjJWr5YJolHa/FKd9JUitIPlqUEzxUqc+5PJcdqaxL0qBfBcdG1Wkr9sxVno1uCicEAuPJUrEGHMTm3THx0wKAn5zrrEM4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736528680; c=relaxed/simple; bh=J4BDXZ6x639C0G4kpyYWVvitWAZ0yDkF4pGsMZYgD9k=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=SKPPbRA4logn7chZ6lNGN+LqaNKmxhlCc2Qy0OMFGDgO98ABT8Xon8aAshl7eRMQGUKgBi7j+XFPZDKNa8v3JQkY7maoZ0E11Y/1dTzN0nCLAzGCQTMsIo3Zpn6Ej2LjkqZOhFLOrGpeejYo2gxYFvolI77ESFOo3kVQ4Z88sg8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i8wSDWRz; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i8wSDWRz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736528677; 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=J4BDXZ6x639C0G4kpyYWVvitWAZ0yDkF4pGsMZYgD9k=; b=i8wSDWRzTczpNFp7y2P5vz0MDCf9vjvhNJiqF5JrQI+eEW3xROyWNQofD3gmqvK6ARtErv yidoWXkuhNlO+yJc7OfrGs9Wclmj3KINIq8WfdwYpdD+TAV8F7sYKb+oFn5nLWENCSI3bM 3vcBcXOaS0fCkLrCbrz6usXdsPSdec4= Received: from mx-prod-mc-01.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-689-HObDEE_SOd-X6oGfMuc3og-1; Fri, 10 Jan 2025 12:04:34 -0500 X-MC-Unique: HObDEE_SOd-X6oGfMuc3og-1 X-Mimecast-MFC-AGG-ID: HObDEE_SOd-X6oGfMuc3og Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BB47919560BB; Fri, 10 Jan 2025 17:04:32 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.2]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A4F4530001BE; Fri, 10 Jan 2025 17:04:28 +0000 (UTC) From: Florian Weimer To: Mathieu Desnoyers Cc: libc-alpha , "carlos@redhat.com" , Mark Rutland , Peter Zijlstra , linux-kernel , x86@kernel.org, paulmck , Michael Jeanson Subject: Re: Prevent inconsistent CPU state after sequence of dlclose/dlopen In-Reply-To: (Mathieu Desnoyers's message of "Fri, 10 Jan 2025 10:55:36 -0500") References: Date: Fri, 10 Jan 2025 18:04:25 +0100 Message-ID: <87plkutxba.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 * Mathieu Desnoyers: > I was discussing with Mark Rutland recently, and he pointed out that a > sequence of dlclose/dlopen mapping new code at the same addresses in > multithreaded environments is an issue on ARM, and possibly on Intel/AMD > with the newer TLB broadcast maintenance. > > I maintain the membarrier(2) system call, which provides a > MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE command for this > purpose. It's been there since Linux 4.16. It can be configured > out (CONFIG_MEMBARRIER=n), but it's enabled by default. > > Calling this after dlclose() in glibc would prevent this issue. > > Is it handled in some other way, or should we open a bugzilla > entry to track this ? There is nothing special about dlopen/dlclose, we just use mmap/munmap. If there is a synchronization problem, we'd have to add to add barriers to mmap and munmap. But why isn't it up to the kernel to handle this correctly? Thanks, Florian