From: "tip-bot2 for Peter Zijlstra" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
"Borislav Petkov (AMD)" <bp@alien8.de>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/urgent] x86/cpu: Add comment clarifying CRn pinning
Date: Mon, 23 Mar 2026 13:58:23 -0000 [thread overview]
Message-ID: <177427430338.1647592.3628353467254170252.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260320092521.GG3739106@noisy.programming.kicks-ass.net>
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: a3e93cac25316aad03bf561e3c205f4ca0b8f452
Gitweb: https://git.kernel.org/tip/a3e93cac25316aad03bf561e3c205f4ca0b8f452
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Fri, 20 Mar 2026 10:25:21 +01:00
Committer: Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Mon, 23 Mar 2026 14:25:53 +01:00
x86/cpu: Add comment clarifying CRn pinning
To avoid future confusion on the purpose and design of the CRn pinning code.
Also note that if the attacker controls page-tables, the CRn bits lose much of
the attraction anyway.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/20260320092521.GG3739106@noisy.programming.kicks-ass.net
---
arch/x86/kernel/cpu/common.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index c57e897..ec06701 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -434,6 +434,19 @@ static __always_inline void setup_lass(struct cpuinfo_x86 *c)
/* These bits should not change their value after CPU init is finished. */
static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP |
X86_CR4_FSGSBASE | X86_CR4_CET;
+
+/*
+ * The CR pinning protects against ROP on the 'mov %reg, %CRn' instruction(s).
+ * Since you can ROP directly to these instructions (barring shadow stack),
+ * any protection must follow immediately and unconditionally after that.
+ *
+ * Specifically, the CR[04] write functions below will have the value
+ * validation controlled by the @cr_pinning static_branch which is
+ * __ro_after_init, just like the cr4_pinned_bits value.
+ *
+ * Once set, an attacker will have to defeat page-tables to get around these
+ * restrictions. Which is a much bigger ask than 'simple' ROP.
+ */
static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning);
static unsigned long cr4_pinned_bits __ro_after_init;
next prev parent reply other threads:[~2026-03-23 13:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 7:56 [PATCH v3 0/3] x86/fred: Fix SEV-ES/SNP guest boot failures Nikunj A Dadhania
2026-03-18 7:56 ` [PATCH v3 1/3] x86/cpu: Enable FSGSBASE early in cpu_init_exception_handling() Nikunj A Dadhania
2026-03-18 13:54 ` Sohil Mehta
2026-03-18 15:39 ` Borislav Petkov
2026-03-18 15:53 ` Dave Hansen
2026-03-18 16:49 ` Sohil Mehta
2026-03-18 18:51 ` [tip: x86/urgent] " tip-bot2 for Nikunj A Dadhania
2026-03-23 13:58 ` tip-bot2 for Nikunj A Dadhania
2026-03-18 7:56 ` [PATCH v3 2/3] x86/cpu: Disable CR pinning during CPU bringup Nikunj A Dadhania
2026-03-18 18:51 ` [tip: x86/urgent] " tip-bot2 for Dave Hansen
2026-03-18 20:47 ` Peter Zijlstra
2026-03-18 21:08 ` Borislav Petkov
2026-03-18 21:30 ` Peter Zijlstra
2026-03-18 22:01 ` Borislav Petkov
2026-03-18 21:09 ` Peter Zijlstra
2026-03-18 21:30 ` Dave Hansen
2026-03-18 22:09 ` Peter Zijlstra
2026-03-20 9:25 ` [PATCH] x86/cpu: Add comment clarifying CRn pinning Peter Zijlstra
2026-03-20 11:34 ` Borislav Petkov
2026-03-23 13:58 ` tip-bot2 for Peter Zijlstra [this message]
2026-03-18 7:56 ` [PATCH v3 3/3] x86/fred: Fix early boot failures on SEV-ES/SNP guests Nikunj A Dadhania
2026-03-18 18:51 ` [tip: x86/urgent] " tip-bot2 for Nikunj A Dadhania
2026-03-23 13:58 ` tip-bot2 for Nikunj A Dadhania
2026-03-18 11:43 ` [PATCH v3 0/3] x86/fred: Fix SEV-ES/SNP guest boot failures Borislav Petkov
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=177427430338.1647592.3628353467254170252.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.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®