util.c (dc0ef0df7b6a90892ec41933212ac701152a254c) util.c (9fbeb5ab59a2b2a09cca2eb68283e7a090d4b98d)
1#include <linux/mm.h>
2#include <linux/slab.h>
3#include <linux/string.h>
4#include <linux/compiler.h>
5#include <linux/export.h>
6#include <linux/err.h>
7#include <linux/sched.h>
8#include <linux/security.h>

--- 275 unchanged lines hidden (view full) ---

284 int nr_pages, int write, struct page **pages)
285{
286 return get_user_pages_unlocked(start, nr_pages, write, 0, pages);
287}
288EXPORT_SYMBOL_GPL(get_user_pages_fast);
289
290unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr,
291 unsigned long len, unsigned long prot,
1#include <linux/mm.h>
2#include <linux/slab.h>
3#include <linux/string.h>
4#include <linux/compiler.h>
5#include <linux/export.h>
6#include <linux/err.h>
7#include <linux/sched.h>
8#include <linux/security.h>

--- 275 unchanged lines hidden (view full) ---

284 int nr_pages, int write, struct page **pages)
285{
286 return get_user_pages_unlocked(start, nr_pages, write, 0, pages);
287}
288EXPORT_SYMBOL_GPL(get_user_pages_fast);
289
290unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr,
291 unsigned long len, unsigned long prot,
292 unsigned long flag, unsigned long pgoff, bool killable)
292 unsigned long flag, unsigned long pgoff)
293{
294 unsigned long ret;
295 struct mm_struct *mm = current->mm;
296 unsigned long populate;
297
298 ret = security_mmap_file(file, prot, flag);
299 if (!ret) {
293{
294 unsigned long ret;
295 struct mm_struct *mm = current->mm;
296 unsigned long populate;
297
298 ret = security_mmap_file(file, prot, flag);
299 if (!ret) {
300 if (killable) {
301 if (down_write_killable(&mm->mmap_sem))
302 return -EINTR;
303 } else {
304 down_write(&mm->mmap_sem);
305 }
300 if (down_write_killable(&mm->mmap_sem))
301 return -EINTR;
306 ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff,
307 &populate);
308 up_write(&mm->mmap_sem);
309 if (populate)
310 mm_populate(ret, populate);
311 }
312 return ret;
313}
314
302 ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff,
303 &populate);
304 up_write(&mm->mmap_sem);
305 if (populate)
306 mm_populate(ret, populate);
307 }
308 return ret;
309}
310
315/* XXX are all callers checking an error */
316unsigned long vm_mmap(struct file *file, unsigned long addr,
317 unsigned long len, unsigned long prot,
318 unsigned long flag, unsigned long offset)
319{
320 if (unlikely(offset + PAGE_ALIGN(len) < offset))
321 return -EINVAL;
322 if (unlikely(offset_in_page(offset)))
323 return -EINVAL;
324
311unsigned long vm_mmap(struct file *file, unsigned long addr,
312 unsigned long len, unsigned long prot,
313 unsigned long flag, unsigned long offset)
314{
315 if (unlikely(offset + PAGE_ALIGN(len) < offset))
316 return -EINVAL;
317 if (unlikely(offset_in_page(offset)))
318 return -EINVAL;
319
325 return vm_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT, false);
320 return vm_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT);
326}
327EXPORT_SYMBOL(vm_mmap);
328
329void kvfree(const void *addr)
330{
331 if (is_vmalloc_addr(addr))
332 vfree(addr);
333 else

--- 313 unchanged lines hidden ---
321}
322EXPORT_SYMBOL(vm_mmap);
323
324void kvfree(const void *addr)
325{
326 if (is_vmalloc_addr(addr))
327 vfree(addr);
328 else

--- 313 unchanged lines hidden ---