Skip to content

Commit

Permalink
[PATCH] uml: arch_prctl should set thread fs
Browse files Browse the repository at this point in the history
In my previous x86_64 thread fix, I forgot to initialize thread.arch.fs in
arch_prctl.  A process calling arch_prctl to set %fs would lose it on the
next context switch.

It also turns out that you can switch to a process which is in the process
of exiting and which has lost its mm.  In this case, it's worse than
useless to try to call arch_prctl on the host process.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jeff Dike authored and Linus Torvalds committed Mar 8, 2007
1 parent 9bebff6 commit 44f5c4c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/um/sys-x86_64/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ long arch_prctl_skas(struct task_struct *task, int code,

switch(code){
case ARCH_SET_FS:
current->thread.arch.fs = (unsigned long) ptr;
save_registers(pid, &current->thread.regs.regs);
break;
case ARCH_SET_GS:
save_registers(pid, &current->thread.regs.regs);
break;
Expand Down Expand Up @@ -140,9 +143,8 @@ long sys_clone(unsigned long clone_flags, unsigned long newsp,

void arch_switch_to_skas(struct task_struct *from, struct task_struct *to)
{
if(to->thread.arch.fs == 0)
if((to->thread.arch.fs == 0) || (to->mm == NULL))
return;

arch_prctl_skas(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs);
}

0 comments on commit 44f5c4c

Please sign in to comment.