diff options
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 59 |
1 files changed, 50 insertions, 9 deletions
@@ -240,6 +240,8 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma) | |||
240 | return next; | 240 | return next; |
241 | } | 241 | } |
242 | 242 | ||
243 | static unsigned long do_brk(unsigned long addr, unsigned long len); | ||
244 | |||
243 | SYSCALL_DEFINE1(brk, unsigned long, brk) | 245 | SYSCALL_DEFINE1(brk, unsigned long, brk) |
244 | { | 246 | { |
245 | unsigned long rlim, retval; | 247 | unsigned long rlim, retval; |
@@ -951,7 +953,7 @@ static inline unsigned long round_hint_to_min(unsigned long hint) | |||
951 | * The caller must hold down_write(¤t->mm->mmap_sem). | 953 | * The caller must hold down_write(¤t->mm->mmap_sem). |
952 | */ | 954 | */ |
953 | 955 | ||
954 | unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, | 956 | static unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, |
955 | unsigned long len, unsigned long prot, | 957 | unsigned long len, unsigned long prot, |
956 | unsigned long flags, unsigned long pgoff) | 958 | unsigned long flags, unsigned long pgoff) |
957 | { | 959 | { |
@@ -1087,7 +1089,32 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, | |||
1087 | 1089 | ||
1088 | return mmap_region(file, addr, len, flags, vm_flags, pgoff); | 1090 | return mmap_region(file, addr, len, flags, vm_flags, pgoff); |
1089 | } | 1091 | } |
1090 | EXPORT_SYMBOL(do_mmap_pgoff); | 1092 | |
1093 | unsigned long do_mmap(struct file *file, unsigned long addr, | ||
1094 | unsigned long len, unsigned long prot, | ||
1095 | unsigned long flag, unsigned long offset) | ||
1096 | { | ||
1097 | if (unlikely(offset + PAGE_ALIGN(len) < offset)) | ||
1098 | return -EINVAL; | ||
1099 | if (unlikely(offset & ~PAGE_MASK)) | ||
1100 | return -EINVAL; | ||
1101 | return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT); | ||
1102 | } | ||
1103 | EXPORT_SYMBOL(do_mmap); | ||
1104 | |||
1105 | unsigned long vm_mmap(struct file *file, unsigned long addr, | ||
1106 | unsigned long len, unsigned long prot, | ||
1107 | unsigned long flag, unsigned long offset) | ||
1108 | { | ||
1109 | unsigned long ret; | ||
1110 | struct mm_struct *mm = current->mm; | ||
1111 | |||
1112 | down_write(&mm->mmap_sem); | ||
1113 | ret = do_mmap(file, addr, len, prot, flag, offset); | ||
1114 | up_write(&mm->mmap_sem); | ||
1115 | return ret; | ||
1116 | } | ||
1117 | EXPORT_SYMBOL(vm_mmap); | ||
1091 | 1118 | ||
1092 | SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, | 1119 | SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, |
1093 | unsigned long, prot, unsigned long, flags, | 1120 | unsigned long, prot, unsigned long, flags, |
@@ -2105,21 +2132,25 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len) | |||
2105 | 2132 | ||
2106 | return 0; | 2133 | return 0; |
2107 | } | 2134 | } |
2108 | |||
2109 | EXPORT_SYMBOL(do_munmap); | 2135 | EXPORT_SYMBOL(do_munmap); |
2110 | 2136 | ||
2111 | SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len) | 2137 | int vm_munmap(unsigned long start, size_t len) |
2112 | { | 2138 | { |
2113 | int ret; | 2139 | int ret; |
2114 | struct mm_struct *mm = current->mm; | 2140 | struct mm_struct *mm = current->mm; |
2115 | 2141 | ||
2116 | profile_munmap(addr); | ||
2117 | |||
2118 | down_write(&mm->mmap_sem); | 2142 | down_write(&mm->mmap_sem); |
2119 | ret = do_munmap(mm, addr, len); | 2143 | ret = do_munmap(mm, start, len); |
2120 | up_write(&mm->mmap_sem); | 2144 | up_write(&mm->mmap_sem); |
2121 | return ret; | 2145 | return ret; |
2122 | } | 2146 | } |
2147 | EXPORT_SYMBOL(vm_munmap); | ||
2148 | |||
2149 | SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len) | ||
2150 | { | ||
2151 | profile_munmap(addr); | ||
2152 | return vm_munmap(addr, len); | ||
2153 | } | ||
2123 | 2154 | ||
2124 | static inline void verify_mm_writelocked(struct mm_struct *mm) | 2155 | static inline void verify_mm_writelocked(struct mm_struct *mm) |
2125 | { | 2156 | { |
@@ -2136,7 +2167,7 @@ static inline void verify_mm_writelocked(struct mm_struct *mm) | |||
2136 | * anonymous maps. eventually we may be able to do some | 2167 | * anonymous maps. eventually we may be able to do some |
2137 | * brk-specific accounting here. | 2168 | * brk-specific accounting here. |
2138 | */ | 2169 | */ |
2139 | unsigned long do_brk(unsigned long addr, unsigned long len) | 2170 | static unsigned long do_brk(unsigned long addr, unsigned long len) |
2140 | { | 2171 | { |
2141 | struct mm_struct * mm = current->mm; | 2172 | struct mm_struct * mm = current->mm; |
2142 | struct vm_area_struct * vma, * prev; | 2173 | struct vm_area_struct * vma, * prev; |
@@ -2232,7 +2263,17 @@ out: | |||
2232 | return addr; | 2263 | return addr; |
2233 | } | 2264 | } |
2234 | 2265 | ||
2235 | EXPORT_SYMBOL(do_brk); | 2266 | unsigned long vm_brk(unsigned long addr, unsigned long len) |
2267 | { | ||
2268 | struct mm_struct *mm = current->mm; | ||
2269 | unsigned long ret; | ||
2270 | |||
2271 | down_write(&mm->mmap_sem); | ||
2272 | ret = do_brk(addr, len); | ||
2273 | up_write(&mm->mmap_sem); | ||
2274 | return ret; | ||
2275 | } | ||
2276 | EXPORT_SYMBOL(vm_brk); | ||
2236 | 2277 | ||
2237 | /* Release all mmaps. */ | 2278 | /* Release all mmaps. */ |
2238 | void exit_mmap(struct mm_struct *mm) | 2279 | void exit_mmap(struct mm_struct *mm) |