lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date: Wed, 15 May 2024 11:32:34 +0200
From: Ard Biesheuvel <ardb+git@...gle.com>
To: linux-kernel@...r.kernel.org
Cc: x86@...nel.org, Ard Biesheuvel <ardb@...nel.org>
Subject: [PATCH] x86/boot: Avoid global attribute in early memory mappings

From: Ard Biesheuvel <ardb@...nel.org>

The decompressor uses the __PAGE_KERNEL_LARGE_EXEC template to create
page table entries, and this includes the 'G' global bit. Global
mappings are a performance optimization that requires more elaborate TLB
maintenance, which the decompressor does not implement, and so global
mappings are disabled entirely, by clearing CR4.PGE in the startup code.

Since global mappings are not used, it is better to avoid setting the
bit altogether, so clear it from the 'flag' variable used to populate
page table entries.

Signed-off-by: Ard Biesheuvel <ardb@...nel.org>
---
 arch/x86/boot/compressed/ident_map_64.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/boot/compressed/ident_map_64.c b/arch/x86/boot/compressed/ident_map_64.c
index dfb9c2deb77c..e24fedf1e36b 100644
--- a/arch/x86/boot/compressed/ident_map_64.c
+++ b/arch/x86/boot/compressed/ident_map_64.c
@@ -121,6 +121,12 @@ void initialize_identity_maps(void *rmode)
 	mapping_info.page_flag = __PAGE_KERNEL_LARGE_EXEC | sme_me_mask;
 	mapping_info.kernpg_flag = _KERNPG_TABLE;
 
+	/*
+	 * Entries with the G bit require more elaborate TLB maintenance,
+	 * so avoid them for these early mappings.
+	 */
+	mapping_info.page_flag &= ~_PAGE_GLOBAL;
+
 	/*
 	 * It should be impossible for this not to already be true,
 	 * but since calling this a second time would rewind the other
-- 
2.45.0.rc1.225.g2a3ae87e7f-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ