Re: [PATCH] x86/mm/pat: skip RWX verification until kernel text is set to read only
From: Dave Hansen
Date: Tue Sep 08 2026 - 20:15:56 EST
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*. 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).
Maybe just do the strict_kernel_rwx() to start and then circle back
around to muck with making DEBUG_WX mandatory?