aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm
diff options
context:
space:
mode:
authorAndy Lutomirski <luto@kernel.org>2016-04-26 15:23:26 -0400
committerIngo Molnar <mingo@kernel.org>2016-04-29 05:56:41 -0400
commit45e876f794e8e566bf827c25ef0791875081724f (patch)
tree0c725250ba4073785997ea5a74bdb1f7e84cb9d7 /arch/x86/mm
parentf005f5d860e0231fe212cfda8c1a3148b99609f4 (diff)
x86/segments/64: When loadsegment(fs, ...) fails, clear the base
On AMD CPUs, a failed loadsegment currently may not clear the FS base. Fix it. While we're at it, prevent loadsegment(gs, xyz) from even compiling on 64-bit kernels. It shouldn't be used. Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/a084c1b93b7b1408b58d3fd0b5d6e47da8e7d7cf.1461698311.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r--arch/x86/mm/extable.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
index aaeda3ffaafe..4bb53b89f3c5 100644
--- a/arch/x86/mm/extable.c
+++ b/arch/x86/mm/extable.c
@@ -70,6 +70,16 @@ bool ex_handler_wrmsr_unsafe(const struct exception_table_entry *fixup,
70} 70}
71EXPORT_SYMBOL(ex_handler_wrmsr_unsafe); 71EXPORT_SYMBOL(ex_handler_wrmsr_unsafe);
72 72
73bool ex_handler_clear_fs(const struct exception_table_entry *fixup,
74 struct pt_regs *regs, int trapnr)
75{
76 if (static_cpu_has(X86_BUG_NULL_SEG))
77 asm volatile ("mov %0, %%fs" : : "rm" (__USER_DS));
78 asm volatile ("mov %0, %%fs" : : "rm" (0));
79 return ex_handler_default(fixup, regs, trapnr);
80}
81EXPORT_SYMBOL(ex_handler_clear_fs);
82
73bool ex_has_fault_handler(unsigned long ip) 83bool ex_has_fault_handler(unsigned long ip)
74{ 84{
75 const struct exception_table_entry *e; 85 const struct exception_table_entry *e;