Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1387925

[PATCH 4/8] x86/segments/64: When load_gs_index fails, clear the base

From Andy Lutomirski <luto@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 4/8] x86/segments/64: When load_gs_index fails, clear the base
Date 2016-04-26 21:30 +0200
Message-ID <rsgQi-4Hw-11@gated-at.bofh.it> (permalink)
References <rsgQi-4Hw-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On AMD CPUs, a failed load_gs_base currently may not clear the FS
base.  Fix it.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/entry/entry_64.S | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 1693c17dbf81..6344629ae1ce 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -794,6 +794,12 @@ END(native_load_gs_index)
 	/* running with kernelgs */
 bad_gs:
 	SWAPGS					/* switch back to user gs */
+.macro ZAP_GS
+	/* This can't be a string because the preprocessor needs to see it. */
+	movl $__USER_DS, %eax
+	movl %eax, %gs
+.endm
+	ALTERNATIVE "", "ZAP_GS", X86_BUG_NULL_SEG
 	xorl	%eax, %eax
 	movl	%eax, %gs
 	jmp	2b
-- 
2.5.5

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 4/8] x86/segments/64: When load_gs_index fails, clear the base Andy Lutomirski <luto@kernel.org> - 2016-04-26 21:30 +0200

csiph-web