diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-04-23 19:17:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-12 18:02:44 -0400 |
commit | 05cb94bc742f64a3dcc4e7dbed3e523ffe88c711 (patch) | |
tree | be2b8db7669a1cc3503fd6a3b99cca271aa9e4d6 /arch/x86/kernel | |
parent | 73f0c8de569332547c42046b5cf179483be99bef (diff) |
x86-64: Clear a 64-bit FS/GS base on fork if selector is nonzero
commit 7ce5a2b9bb2e92902230e3121d8c3047fab9cb47 upstream.
When we do a thread switch, we clear the outgoing FS/GS base if the
corresponding selector is nonzero. This is taken by __switch_to() as
an entry invariant; it does not verify that it is true on entry.
However, copy_thread() doesn't enforce this constraint, which can
result in inconsistent results after fork().
Make copy_thread() match the behavior of __switch_to().
Reported-and-tested-by: Samuel Thibault <samuel.thibault@inria.fr>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
LKML-Reference: <4BD1E061.8030605@zytor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/process_64.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 126f0b493d04..11d0702f0e0d 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c | |||
@@ -282,12 +282,12 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, | |||
282 | 282 | ||
283 | set_tsk_thread_flag(p, TIF_FORK); | 283 | set_tsk_thread_flag(p, TIF_FORK); |
284 | 284 | ||
285 | p->thread.fs = me->thread.fs; | ||
286 | p->thread.gs = me->thread.gs; | ||
287 | p->thread.io_bitmap_ptr = NULL; | 285 | p->thread.io_bitmap_ptr = NULL; |
288 | 286 | ||
289 | savesegment(gs, p->thread.gsindex); | 287 | savesegment(gs, p->thread.gsindex); |
288 | p->thread.gs = p->thread.gsindex ? 0 : me->thread.gs; | ||
290 | savesegment(fs, p->thread.fsindex); | 289 | savesegment(fs, p->thread.fsindex); |
290 | p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs; | ||
291 | savesegment(es, p->thread.es); | 291 | savesegment(es, p->thread.es); |
292 | savesegment(ds, p->thread.ds); | 292 | savesegment(ds, p->thread.ds); |
293 | 293 | ||