mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	libc-alpha <libc-alpha@sourceware.org>
Cc: Florian Weimer <fweimer@redhat.com>,
	"carlos@redhat.com" <carlos@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	x86@kernel.org, paulmck <paulmck@kernel.org>,
	Michael Jeanson <mjeanson@efficios.com>
Subject: Re: Prevent inconsistent CPU state after sequence of dlclose/dlopen
Date: Wed, 15 Jan 2025 15:16:53 -0500	[thread overview]
Message-ID: <7cd665f6-7b1d-409f-b7eb-417c08440a35@efficios.com> (raw)
In-Reply-To: <5de4b3c3-7f11-4d81-ac75-1b7381a87f0a@linaro.org>

On 2025-01-10 11:47, Adhemerval Zanella Netto wrote:
> 
> 
> On 10/01/25 12:55, Mathieu Desnoyers wrote:
>> Hi,
>>
>> 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 ?
> 
> Yes please, it would be helpful if you can add some information on
> what kind of hardware and kernel version this is an issue.

Done:

https://sourceware.org/bugzilla/show_bug.cgi?id=32563

> 
> Also, could you add some detail of the issue and why kernel itself does
> not or can not guarantee memory consistent after the mmap call?

I've added a comment detailing this.

> 
> Is is because this would be an extra non-required overhead on
> mmap that userland should handle?

Yes, overhead is the culprit there, although it could be manageable
if we target this kind of extra sync-core operations on specific
sequences of mmap/munmap/mprotect with the PROT_EXEC flag.

I've documented a possible approach in the bugzilla entry.

Thanks,

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


  reply	other threads:[~2025-01-15 20:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-10 15:55 Mathieu Desnoyers
2025-01-10 16:47 ` Adhemerval Zanella Netto
2025-01-15 20:16   ` Mathieu Desnoyers [this message]
2025-01-10 16:54 ` Peter Zijlstra
2025-01-10 17:02   ` Mathieu Desnoyers
2025-01-10 17:10     ` Florian Weimer
2025-01-10 17:14       ` Adhemerval Zanella Netto
2025-01-10 17:15       ` Mathieu Desnoyers
2025-01-10 17:24         ` Adhemerval Zanella Netto
2025-01-10 17:35           ` Mathieu Desnoyers
2025-01-10 17:46         ` Florian Weimer
2025-01-10 19:16           ` Mathieu Desnoyers
2025-01-10 17:11     ` Peter Zijlstra
2025-01-10 18:41       ` Mark Rutland
2025-01-10 17:12     ` Adhemerval Zanella Netto
2025-01-10 17:04 ` Florian Weimer
2025-01-10 17:13   ` Mathieu Desnoyers
2025-01-10 18:33     ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7cd665f6-7b1d-409f-b7eb-417c08440a35@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mjeanson@efficios.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®