diff options
Diffstat (limited to 'arch/sparc64/kernel/sys_sparc32.c')
-rw-r--r-- | arch/sparc64/kernel/sys_sparc32.c | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c index 1aa4288125f2..ba5bd626b39e 100644 --- a/arch/sparc64/kernel/sys_sparc32.c +++ b/arch/sparc64/kernel/sys_sparc32.c | |||
@@ -867,44 +867,15 @@ asmlinkage unsigned long sys32_mremap(unsigned long addr, | |||
867 | unsigned long old_len, unsigned long new_len, | 867 | unsigned long old_len, unsigned long new_len, |
868 | unsigned long flags, u32 __new_addr) | 868 | unsigned long flags, u32 __new_addr) |
869 | { | 869 | { |
870 | struct vm_area_struct *vma; | ||
871 | unsigned long ret = -EINVAL; | 870 | unsigned long ret = -EINVAL; |
872 | unsigned long new_addr = __new_addr; | 871 | unsigned long new_addr = __new_addr; |
873 | 872 | ||
874 | if (old_len > STACK_TOP32 || new_len > STACK_TOP32) | 873 | if (unlikely(sparc64_mmap_check(addr, old_len))) |
875 | goto out; | 874 | goto out; |
876 | if (addr > STACK_TOP32 - old_len) | 875 | if (unlikely(sparc64_mmap_check(new_addr, new_len))) |
877 | goto out; | 876 | goto out; |
878 | down_write(¤t->mm->mmap_sem); | 877 | down_write(¤t->mm->mmap_sem); |
879 | if (flags & MREMAP_FIXED) { | ||
880 | if (new_addr > STACK_TOP32 - new_len) | ||
881 | goto out_sem; | ||
882 | } else if (addr > STACK_TOP32 - new_len) { | ||
883 | unsigned long map_flags = 0; | ||
884 | struct file *file = NULL; | ||
885 | |||
886 | ret = -ENOMEM; | ||
887 | if (!(flags & MREMAP_MAYMOVE)) | ||
888 | goto out_sem; | ||
889 | |||
890 | vma = find_vma(current->mm, addr); | ||
891 | if (vma) { | ||
892 | if (vma->vm_flags & VM_SHARED) | ||
893 | map_flags |= MAP_SHARED; | ||
894 | file = vma->vm_file; | ||
895 | } | ||
896 | |||
897 | /* MREMAP_FIXED checked above. */ | ||
898 | new_addr = get_unmapped_area(file, addr, new_len, | ||
899 | vma ? vma->vm_pgoff : 0, | ||
900 | map_flags); | ||
901 | ret = new_addr; | ||
902 | if (new_addr & ~PAGE_MASK) | ||
903 | goto out_sem; | ||
904 | flags |= MREMAP_FIXED; | ||
905 | } | ||
906 | ret = do_mremap(addr, old_len, new_len, flags, new_addr); | 878 | ret = do_mremap(addr, old_len, new_len, flags, new_addr); |
907 | out_sem: | ||
908 | up_write(¤t->mm->mmap_sem); | 879 | up_write(¤t->mm->mmap_sem); |
909 | out: | 880 | out: |
910 | return ret; | 881 | return ret; |