aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-12-11 15:23:29 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-11 15:23:29 -0500
commitaad3bf04dca5a2147a8406f7aef5703ee5259a52 (patch)
tree558d5915ddceab6bb47ed844dea9386c6036d087 /arch/s390/kernel
parent11bd04f6f35621193311c32e0721142b073a7794 (diff)
parentaa65607373a4daf2010e8c3867b6317619f3c1a3 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/viro/mmap
* git://git.kernel.org/pub/scm/linux/kernel/git/viro/mmap: Add missing alignment check in arch/score sys_mmap() fix broken aliasing checks for MAP_FIXED on sparc32, mips, arm and sh Get rid of open-coding in ia64_brk() sparc_brk() is not needed anymore switch do_brk() to get_unmapped_area() Take arch_mmap_check() into get_unmapped_area() fix a struct file leak in do_mmap_pgoff() Unify sys_mmap* Cut hugetlb case early for 32bit on ia64 arch_mmap_check() on mn10300 Kill ancient crap in s390 compat mmap arm: add arch_mmap_check(), get rid of sys_arm_mremap() file ->get_unmapped_area() shouldn't duplicate work of get_unmapped_area() kill useless checks in sparc mremap variants fix pgoff in "have to relocate" case of mremap() fix the arch checks in MREMAP_FIXED case fix checks for expand-in-place mremap do_mremap() untangling, part 3 do_mremap() untangling, part 2 untangling do_mremap(), part 1
Diffstat (limited to 'arch/s390/kernel')
-rw-r--r--arch/s390/kernel/compat_linux.c37
-rw-r--r--arch/s390/kernel/sys_s390.c30
2 files changed, 5 insertions, 62 deletions
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 25c31d681402..22c9e557bb22 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -624,38 +624,6 @@ struct mmap_arg_struct_emu31 {
624 u32 offset; 624 u32 offset;
625}; 625};
626 626
627/* common code for old and new mmaps */
628static inline long do_mmap2(
629 unsigned long addr, unsigned long len,
630 unsigned long prot, unsigned long flags,
631 unsigned long fd, unsigned long pgoff)
632{
633 struct file * file = NULL;
634 unsigned long error = -EBADF;
635
636 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
637 if (!(flags & MAP_ANONYMOUS)) {
638 file = fget(fd);
639 if (!file)
640 goto out;
641 }
642
643 down_write(&current->mm->mmap_sem);
644 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
645 if (!IS_ERR((void *) error) && error + len >= 0x80000000ULL) {
646 /* Result is out of bounds. */
647 do_munmap(current->mm, addr, len);
648 error = -ENOMEM;
649 }
650 up_write(&current->mm->mmap_sem);
651
652 if (file)
653 fput(file);
654out:
655 return error;
656}
657
658
659asmlinkage unsigned long 627asmlinkage unsigned long
660old32_mmap(struct mmap_arg_struct_emu31 __user *arg) 628old32_mmap(struct mmap_arg_struct_emu31 __user *arg)
661{ 629{
@@ -669,7 +637,8 @@ old32_mmap(struct mmap_arg_struct_emu31 __user *arg)
669 if (a.offset & ~PAGE_MASK) 637 if (a.offset & ~PAGE_MASK)
670 goto out; 638 goto out;
671 639
672 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT); 640 error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd,
641 a.offset >> PAGE_SHIFT);
673out: 642out:
674 return error; 643 return error;
675} 644}
@@ -682,7 +651,7 @@ sys32_mmap2(struct mmap_arg_struct_emu31 __user *arg)
682 651
683 if (copy_from_user(&a, arg, sizeof(a))) 652 if (copy_from_user(&a, arg, sizeof(a)))
684 goto out; 653 goto out;
685 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset); 654 error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
686out: 655out:
687 return error; 656 return error;
688} 657}
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c
index e9d94f61d500..86a74c9c9e63 100644
--- a/arch/s390/kernel/sys_s390.c
+++ b/arch/s390/kernel/sys_s390.c
@@ -32,32 +32,6 @@
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include "entry.h" 33#include "entry.h"
34 34
35/* common code for old and new mmaps */
36static inline long do_mmap2(
37 unsigned long addr, unsigned long len,
38 unsigned long prot, unsigned long flags,
39 unsigned long fd, unsigned long pgoff)
40{
41 long error = -EBADF;
42 struct file * file = NULL;
43
44 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
45 if (!(flags & MAP_ANONYMOUS)) {
46 file = fget(fd);
47 if (!file)
48 goto out;
49 }
50
51 down_write(&current->mm->mmap_sem);
52 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
53 up_write(&current->mm->mmap_sem);
54
55 if (file)
56 fput(file);
57out:
58 return error;
59}
60
61/* 35/*
62 * Perform the select(nd, in, out, ex, tv) and mmap() system 36 * Perform the select(nd, in, out, ex, tv) and mmap() system
63 * calls. Linux for S/390 isn't able to handle more than 5 37 * calls. Linux for S/390 isn't able to handle more than 5
@@ -81,7 +55,7 @@ SYSCALL_DEFINE1(mmap2, struct mmap_arg_struct __user *, arg)
81 55
82 if (copy_from_user(&a, arg, sizeof(a))) 56 if (copy_from_user(&a, arg, sizeof(a)))
83 goto out; 57 goto out;
84 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset); 58 error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset);
85out: 59out:
86 return error; 60 return error;
87} 61}
@@ -98,7 +72,7 @@ SYSCALL_DEFINE1(s390_old_mmap, struct mmap_arg_struct __user *, arg)
98 if (a.offset & ~PAGE_MASK) 72 if (a.offset & ~PAGE_MASK)
99 goto out; 73 goto out;
100 74
101 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT); 75 error = sys_mmap_pgoff(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
102out: 76out:
103 return error; 77 return error;
104} 78}