From: Peter Zijlstra <peterz@infradead.org>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: libc-alpha <libc-alpha@sourceware.org>,
Florian Weimer <fweimer@redhat.com>,
"carlos@redhat.com" <carlos@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
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: Fri, 10 Jan 2025 18:11:12 +0100 [thread overview]
Message-ID: <20250110171112.GF4213@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <8c1ad304-61bb-4bdf-aa75-8633f3d0196c@efficios.com>
On Fri, Jan 10, 2025 at 12:02:27PM -0500, Mathieu Desnoyers wrote:
> On 2025-01-10 11:54, Peter Zijlstra wrote:
> > On Fri, Jan 10, 2025 at 10:55:36AM -0500, 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.
> >
> > What is the exact race? Should not munmap() invalidate the TLBs before
> > it allows overlapping mmap() to complete?
>
> The race Mark mentioned (on ARM) is AFAIU the following scenario:
>
> CPU 0 CPU 1
>
> - dlopen()
> - mmap PROT_EXEC @addr
> - fetch insn @addr, CPU state expects unchanged insn.
> - execute unrelated code
> - dlclose(addr)
> - munmap @addr
> - dlopen()
> - mmap PROT_EXEC @addr
> - fetch new insn @addr. Incoherent CPU state.
Urgh.. Mark, is this because of non-coherent i-cache or somesuch misery?
But shouldn't flush_{,i}cache_range() or something along those lines not
handle this?
next prev parent reply other threads:[~2025-01-10 17:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 15:55 Prevent inconsistent CPU state after sequence of dlclose/dlopen Mathieu Desnoyers
2025-01-10 16:47 ` Adhemerval Zanella Netto
2025-01-15 20:16 ` Mathieu Desnoyers
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 [this message]
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=20250110171112.GF4213@noisy.programming.kicks-ass.net \
--to=peterz@infradead.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=mathieu.desnoyers@efficios.com \
--cc=mjeanson@efficios.com \
--cc=paulmck@kernel.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