Commit 767d035d authored by Andy Lutomirski's avatar Andy Lutomirski Committed by Ingo Molnar

x86/fsgsbase/64: Fully initialize FS and GS state in start_thread_common

execve used to leak FSBASE and GSBASE on AMD CPUs.  Fix it.

The security impact of this bug is small but not quite zero -- it
could weaken ASLR when a privileged task execs a less privileged
program, but only if program changed bitness across the exec, or the
child binary was highly unusual or actively malicious.  A child
program that was compromised after the exec would not have access to
the leaked base.
Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Chang Seok <chang.seok.bae@intel.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent af79ded4
...@@ -228,10 +228,19 @@ start_thread_common(struct pt_regs *regs, unsigned long new_ip, ...@@ -228,10 +228,19 @@ start_thread_common(struct pt_regs *regs, unsigned long new_ip,
unsigned long new_sp, unsigned long new_sp,
unsigned int _cs, unsigned int _ss, unsigned int _ds) unsigned int _cs, unsigned int _ss, unsigned int _ds)
{ {
WARN_ON_ONCE(regs != current_pt_regs());
if (static_cpu_has(X86_BUG_NULL_SEG)) {
/* Loading zero below won't clear the base. */
loadsegment(fs, __USER_DS);
load_gs_index(__USER_DS);
}
loadsegment(fs, 0); loadsegment(fs, 0);
loadsegment(es, _ds); loadsegment(es, _ds);
loadsegment(ds, _ds); loadsegment(ds, _ds);
load_gs_index(0); load_gs_index(0);
regs->ip = new_ip; regs->ip = new_ip;
regs->sp = new_sp; regs->sp = new_sp;
regs->cs = _cs; regs->cs = _cs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment