Re: [tip: x86/urgent] x86/mm: Fix pti_clone_entry_text() for i386

Peter Zijlstra
2024-08-06T15:59:25Z

On Tue, Aug 06, 2024 at 05:46:53PM +0200, Peter Zijlstra wrote:
> On Tue, Aug 06, 2024 at 05:05:15PM +0200, Peter Zijlstra wrote:
> > On Tue, Aug 06, 2024 at 04:56:32PM +0200, Peter Zijlstra wrote:
> > > On Tue, Aug 06, 2024 at 07:25:42AM -0700, Guenter Roeck wrote:
> > >
> > > > I created http://server.roeck-us.net/qemu/x86-v6.11-rc2/ with all
> > > > the relevant information. Please let me know if you need anything else.
> > >
> > > So I grabbed that config, stuck it in the build dir I used last time and
> > > upgraded gcc-13 from 13.2 ro 13.3. But alas, my build runs successfully
> > > :/
> > >
> > > Is there anything else special I missed?
> >
> > run.sh is not exacrlty the same this time, different CPU model, that
> > made it go.
> >
> > OK, lemme poke at this.
>
> Urgh, so crypto's late_initcall() does user-mode-helper based modprobe
> looking for algorithms before we kick off /bin/init :/
>
> This makes things difficult.
>
> Urgh.

So the problem is that mark_readonly() splits a code PMD due to NX. Then
the second pti_clone_entry_text() finds a kernel PTE but a user PMD
mapping for the same address (from the early clone) and gets upset.

And we can't run mark_readonly() sooner, because initcall expect stuff
to be RW. But initcalls do modprobe, which runs user crap before we're
done initializing everything.

This is a right mess, and I really don't know what to do.