mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Guenter Roeck <linux@roeck-us.net>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org, keescook@chromium.org,
	Sean Christopherson <seanjc@google.com>
Subject: Re: [PATCH v2] x86/mm: Refuse W^X violations
Date: Thu, 22 Sep 2022 08:00:33 -0700	[thread overview]
Message-ID: <44b4b20a-550c-6337-3f7d-8283498f76f2@intel.com> (raw)
In-Reply-To: <YywS0keUorHwJJPt@hirez.programming.kicks-ass.net>

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]

On 9/22/22 00:46, Peter Zijlstra wrote:
> On Wed, Sep 21, 2022 at 08:09:13PM -0700, Guenter Roeck wrote:
> 
>> Oh well, that "helped" to hide one of the crashes. Here is another one.
>> This is with PAE enabled and booting through efi32.
> 
>> [    1.086592]  efi_runtime_update_mappings+0x36/0x42
>> [    1.086717]  efi_enter_virtual_mode+0x351/0x36e
>> [    1.086860]  start_kernel+0x57d/0x60f
>> [    1.086956]  ? set_intr_gate+0x42/0x55
>> [    1.087079]  i386_start_kernel+0x43/0x45
>> [    1.087272]  startup_32_smp+0x161/0x164
> 
> Does this help? Dave; perhaps we should just let i386 be i386 and let it
> bitrot :/

How about we just turn off enforcement for now so that the poor i386
folks can at least boot?  I have the feeling we're going to get bored
with even the warnings if they persist for too long, though.

Untested patch to make i386 violations harmless is attached.

[-- Attachment #2: norefuse.patch --]
[-- Type: text/x-patch, Size: 1185 bytes --]

diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 20b1e24baa85..c899c55d8304 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -585,6 +585,8 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long start,
 static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long start,
 				  unsigned long pfn, unsigned long npg)
 {
+	/* Just warn on i386, there are still too many issues there: */
+	bool refuse = IS_ENABLED(CONFIG_X86_64);
 	unsigned long end;
 
 	/* Only enforce when NX is supported: */
@@ -598,13 +600,17 @@ static inline pgprot_t verify_rwx(pgprot_t old, pgprot_t new, unsigned long star
 		return new;
 
 	end = start + npg * PAGE_SIZE - 1;
-	WARN_ONCE(1, "CPA refuse W^X violation: %016llx -> %016llx range: 0x%016lx - 0x%016lx PFN %lx\n",
+	WARN_ONCE(1, "CPA %sW^X violation: %016llx -> %016llx range: 0x%016lx - 0x%016lx PFN %lx\n",
+		  refuse ? "refuse " : "",
 		  (unsigned long long)pgprot_val(old),
 		  (unsigned long long)pgprot_val(new),
 		  start, end, pfn);
 
 	/* refuse the transition into WX */
-	return old;
+	if (refuse)
+		return old;
+
+	return new;
 }
 
 /*

  reply	other threads:[~2022-09-22 15:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 10:18 Peter Zijlstra
2022-08-29 19:08 ` Kees Cook
2022-09-01 18:17 ` [tip: x86/mm] " tip-bot2 for Peter Zijlstra
2022-09-21 20:07 ` [PATCH v2] " Guenter Roeck
2022-09-21 20:59   ` Dave Hansen
2022-09-21 22:59     ` Guenter Roeck
2022-09-22  3:09       ` Guenter Roeck
2022-09-22  7:46         ` Peter Zijlstra
2022-09-22 15:00           ` Dave Hansen [this message]
2022-09-22 16:38             ` Guenter Roeck
2022-09-22 16:29           ` Guenter Roeck
2022-09-22 19:31             ` [PATCH] x86/mm+efi: Avoid creating W+X mappings Dave Hansen
2022-09-22 22:08               ` Ard Biesheuvel
2022-09-23  6:59                 ` Peter Zijlstra
2022-09-23  9:49                   ` Ard Biesheuvel
2022-09-23 13:58                     ` Guenter Roeck
2022-09-23 14:26                       ` Ard Biesheuvel
2022-09-23 18:31                         ` Kees Cook
2022-09-23 19:53                           ` Ard Biesheuvel
2022-09-23 21:19                             ` Kees Cook
2022-09-23 22:15                               ` Dave Hansen
2022-09-23 22:32                                 ` Eric W. Biederman
2022-09-24  0:04                                 ` Kees Cook
2022-10-02 10:33     ` [PATCH v2] x86/mm: Refuse W^X violations Pavel Machek
2022-10-24 15:27 ` Steven Rostedt

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=44b4b20a-550c-6337-3f7d-8283498f76f2@intel.com \
    --to=dave.hansen@intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=peterz@infradead.org \
    --cc=seanjc@google.com \
    --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®