From: Mike Rapoport <rppt@kernel.org>
To: Dave Hansen <dave.hansen@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
Ingo Molnar <mingo@redhat.com>,
Nathan Chancellor <nathan@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@kernel.org>,
linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH] x86/mm/pat: skip RWX verification until kernel text is set to read only
Date: Wed, 9 Sep 2026 12:40:20 +0300 [thread overview]
Message-ID: <aqEphDuTtIZDANnS@kernel.org> (raw)
In-Reply-To: <522548e1-ebbf-4785-83d7-e2cc3aa83b62@intel.com>
On Tue, Sep 08, 2026 at 05:15:46PM -0700, Dave Hansen wrote:
> On 9/8/26 02:27, Mike Rapoport wrote:
> > --- a/arch/x86/mm/pat/set_memory.c
> > +++ b/arch/x86/mm/pat/set_memory.c
> > @@ -708,6 +708,10 @@ static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long star
> > if (!(__supported_pte_mask & _PAGE_NX))
> > return new;
> >
> > + /* skip verification until kernel text is set to read only */
> > + if (!kernel_set_to_readonly)
> > + return new;
>
> If someone sets up a W+X mapping, such a mapping could persist until
> after boot and this would suppress the warning. Right?
>
> Sure, you can _get_ checking with debug_checkwx(). But that's a debug
> option and it's kinda weird to shift the burden from an always-on thing
> like verify_rwx() to a literal debug option.
>
> That said, I think you're completely on target for thinking that it's
> silly for verify_rwx() to even *try* to spew warnings in boot.
>
> How about we add a kernel_strict_rwx() helper:
>
> bool strict_kernel_rwx(void)
> {
> return IS_ENABLED(CONFIG_STRICT_KERNEL_RWX) && rodata_enabled;
> }
>
> Have verify_rwx() check *that*.
Checking only that will bring the warning about ITS pages back :)
Both CONFIG_STRICT_KERNEL_RWX and rodata_enabled are set before the
alternatives patching.
And rodata_enabled is kinda arm64 specific thingy :)
The check for (!kernel_set_to_readonly) has to stay to actually rule
out the silly checks at boot and it covers your strict_kernel_rwx() because
kernel_set_to_readonly is only set when strict_kernel_rwx() will be true.
> Also, make the DEBUG_WX functionality mandatory for STRICT_KERNEL_RWX
> (with appropriate renaming) so that it can be depended upon. I assume
> all the distros are turning DEBUG_WX on already (Ubuntu seems to).
Just checked my Debian config, it does.
> Maybe just do the strict_kernel_rwx() to start and then circle back
> around to muck with making DEBUG_WX mandatory?
I though about making DEBUG_WX mandatory right away, but that's surely not a
oneliner, so I kept it for later. Maybe should have mentioned in the
changelog, though.
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-09-09 9:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 9:27 Mike Rapoport
2026-09-08 23:33 ` Nathan Chancellor
2026-09-09 0:15 ` Dave Hansen
2026-09-09 9:40 ` Mike Rapoport [this message]
2026-09-09 14:22 ` Dave Hansen
2026-09-09 17:45 ` Mike Rapoport
2026-09-09 17:38 ` Ihor Solodrai
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=aqEphDuTtIZDANnS@kernel.org \
--to=rppt@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@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
all inboxes | Powered by JetHome®