From: Peter Zijlstra <peterz@infradead.org>
To: Mike Rapoport <rppt@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
mm-commits@vger.kernel.org, will@kernel.org, vgupta@kernel.org,
urezki@gmail.com, tsbogend@alpha.franken.de, tglx@linutronix.de,
surenb@google.com, song@kernel.org, shorne@gmail.com,
rostedt@goodmis.org, richard@nod.at, palmer@dabbelt.com,
oleg@redhat.com, mpe@ellerman.id.au, monstr@monstr.eu,
mingo@redhat.com, mhiramat@kernel.org, mcgrof@kernel.org,
mattst88@gmail.com, mark.rutland@arm.com, luto@kernel.org,
linux@armlinux.org.uk, Liam.Howlett@oracle.com,
kent.overstreet@linux.dev, kdevops@lists.linux.dev,
johannes@sipsolutions.net, jcmvbkbc@gmail.com, hch@lst.de,
guoren@kernel.org, glaubitz@physik.fu-berlin.de,
geert@linux-m68k.org, dinguyen@kernel.org, deller@gmx.de,
dave.hansen@linux.intel.com, christophe.leroy@csgroup.eu,
chenhuacai@kernel.org, catalin.marinas@arm.com, bp@alien8.de,
bcain@quicinc.com, arnd@arndb.de, ardb@kernel.org,
andreas@gaisler.com
Subject: Re: [merged mm-stable] x86-module-prepare-module-loading-for-rox-allocations-of-text.patch removed from -mm tree
Date: Mon, 9 Dec 2024 09:38:18 +0100 [thread overview]
Message-ID: <20241209083818.GK8562@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <Z1LUZJdsDHrSV6oE@kernel.org>
On Fri, Dec 06, 2024 at 12:39:32PM +0200, Mike Rapoport wrote:
> Hi Peter,
>
> On Thu, Dec 05, 2024 at 09:41:28AM +0100, Peter Zijlstra wrote:
> > On Wed, Nov 06, 2024 at 08:50:41AM +0200, Mike Rapoport wrote:
> >
> > Anyway, while noodling with all that, I think there's a fairly
> > fundamental error in all of this. The mem->rw_copy should not be a whole
> > second allocation, it should be a (page granular) RW alias of the
> > (large) ROX map.
>
> I've made mem->rw_copy an allocation because Andy raised a concern [1] that
> we'll have an executable mapping of semi-formed code.
> With an actual copy rather than an alias the ROX pages contain invalid
> instructions up to the point we're through with relocations and
> alternatives patching and the actual code appears in ROX mappings in one
> go.
>
> [1] https://lore.kernel.org/all/a17c65c6-863f-4026-9c6f-a04b659e9ab4@app.fastmail.com
Right, but at the same time he also calls out the problem with this;
you're now forced to carry two pointers, one to indicate where the code
is going to live and one to actually read/write to.
(Not to mention the disparity of module_writable_address() only implying
writes, but in actual reality it is required for reads too.)
Pushing this dual pointer through all the pre-existing code that
rewrites our code is done haphazardly and incomplete (and is quite
ugly and error prone -- as evidenced by my ADL's current inability to
load modules).
He also then goes on to suggest a better approach would be to remap
inplace to RW and back to RX. Now the problem with this is ofcourse
that the remap to RW will shatter the large pages we're so very keen on
preserving, but this can be rectified at the point where er remap back
to RX -- it's just that the current code does not.
All in all, I really don't like the place where we've end up, it is
quite horrible :/
prev parent reply other threads:[~2024-12-09 8:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 1:00 [merged mm-stable] x86-module-prepare-module-loading-for-rox-allocations-of-text.patch removed from -mm tree Andrew Morton
2024-11-06 6:50 ` Mike Rapoport
2024-11-06 21:30 ` Andrew Morton
2024-12-05 8:41 ` Peter Zijlstra
2024-12-06 10:39 ` Mike Rapoport
2024-12-09 8:38 ` Peter Zijlstra [this message]
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=20241209083818.GK8562@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=andreas@gaisler.com \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=bcain@quicinc.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=dave.hansen@linux.intel.com \
--cc=deller@gmx.de \
--cc=dinguyen@kernel.org \
--cc=geert@linux-m68k.org \
--cc=glaubitz@physik.fu-berlin.de \
--cc=guoren@kernel.org \
--cc=hch@lst.de \
--cc=jcmvbkbc@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=kdevops@lists.linux.dev \
--cc=kent.overstreet@linux.dev \
--cc=linux@armlinux.org.uk \
--cc=luto@kernel.org \
--cc=mark.rutland@arm.com \
--cc=mattst88@gmail.com \
--cc=mcgrof@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=mm-commits@vger.kernel.org \
--cc=monstr@monstr.eu \
--cc=mpe@ellerman.id.au \
--cc=oleg@redhat.com \
--cc=palmer@dabbelt.com \
--cc=richard@nod.at \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=shorne@gmail.com \
--cc=song@kernel.org \
--cc=surenb@google.com \
--cc=tglx@linutronix.de \
--cc=tsbogend@alpha.franken.de \
--cc=urezki@gmail.com \
--cc=vgupta@kernel.org \
--cc=will@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