mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Mike Rapoport <rppt@kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>
Cc: 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: Tue, 8 Sep 2026 17:15:46 -0700	[thread overview]
Message-ID: <522548e1-ebbf-4785-83d7-e2cc3aa83b62@intel.com> (raw)
In-Reply-To: <20260908092730.4002628-1-rppt@kernel.org>

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?

  parent reply	other threads:[~2026-09-09  0:15 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 [this message]
2026-09-09  9:40   ` Mike Rapoport
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=522548e1-ebbf-4785-83d7-e2cc3aa83b62@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bp@alien8.de \
    --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=rppt@kernel.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®