Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
  sparc: Fix fork/clone/vfork system call restart.
  sparc: Fix mmap VA span checking.
  • Loading branch information
torvalds committed May 8, 2008
2 parents e0164af + 1e38c12 commit 3de2403
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
20 changes: 16 additions & 4 deletions arch/sparc/kernel/process.c
Expand Up @@ -419,14 +419,26 @@ asmlinkage int sparc_do_fork(unsigned long clone_flags,
unsigned long stack_size)
{
unsigned long parent_tid_ptr, child_tid_ptr;
unsigned long orig_i1 = regs->u_regs[UREG_I1];
long ret;

parent_tid_ptr = regs->u_regs[UREG_I2];
child_tid_ptr = regs->u_regs[UREG_I4];

return do_fork(clone_flags, stack_start,
regs, stack_size,
(int __user *) parent_tid_ptr,
(int __user *) child_tid_ptr);
ret = do_fork(clone_flags, stack_start,
regs, stack_size,
(int __user *) parent_tid_ptr,
(int __user *) child_tid_ptr);

/* If we get an error and potentially restart the system
* call, we're screwed because copy_thread() clobbered
* the parent's %o1. So detect that case and restore it
* here.
*/
if ((unsigned long)ret >= -ERESTART_RESTARTBLOCK)
regs->u_regs[UREG_I1] = orig_i1;

return ret;
}

/* Copy a Sparc thread. The fork() return value conventions
Expand Down
3 changes: 1 addition & 2 deletions arch/sparc/kernel/sys_sparc.c
Expand Up @@ -223,8 +223,7 @@ int sparc_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
{
if (ARCH_SUN4C_SUN4 &&
(len > 0x20000000 ||
((flags & MAP_FIXED) &&
addr < 0xe0000000 && addr + len > 0x20000000)))
(addr < 0xe0000000 && addr + len > 0x20000000)))
return -EINVAL;

/* See asm-sparc/uaccess.h */
Expand Down
18 changes: 15 additions & 3 deletions arch/sparc64/kernel/process.c
Expand Up @@ -503,6 +503,8 @@ asmlinkage long sparc_do_fork(unsigned long clone_flags,
unsigned long stack_size)
{
int __user *parent_tid_ptr, *child_tid_ptr;
unsigned long orig_i1 = regs->u_regs[UREG_I1];
long ret;

#ifdef CONFIG_COMPAT
if (test_thread_flag(TIF_32BIT)) {
Expand All @@ -515,9 +517,19 @@ asmlinkage long sparc_do_fork(unsigned long clone_flags,
child_tid_ptr = (int __user *) regs->u_regs[UREG_I4];
}

return do_fork(clone_flags, stack_start,
regs, stack_size,
parent_tid_ptr, child_tid_ptr);
ret = do_fork(clone_flags, stack_start,
regs, stack_size,
parent_tid_ptr, child_tid_ptr);

/* If we get an error and potentially restart the system
* call, we're screwed because copy_thread() clobbered
* the parent's %o1. So detect that case and restore it
* here.
*/
if ((unsigned long)ret >= -ERESTART_RESTARTBLOCK)
regs->u_regs[UREG_I1] = orig_i1;

return ret;
}

/* Copy a Sparc thread. The fork() return value conventions
Expand Down
4 changes: 2 additions & 2 deletions arch/sparc64/kernel/sys_sparc.c
Expand Up @@ -549,13 +549,13 @@ int sparc64_mmap_check(unsigned long addr, unsigned long len,
if (len >= STACK_TOP32)
return -EINVAL;

if ((flags & MAP_FIXED) && addr > STACK_TOP32 - len)
if (addr > STACK_TOP32 - len)
return -EINVAL;
} else {
if (len >= VA_EXCLUDE_START)
return -EINVAL;

if ((flags & MAP_FIXED) && invalid_64bit_range(addr, len))
if (invalid_64bit_range(addr, len))
return -EINVAL;
}

Expand Down

0 comments on commit 3de2403

Please sign in to comment.