]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fix mmap(MAP_LOCKED)
authorAndrew Morton <akpm@digeo.com>
Thu, 19 Sep 2002 15:36:56 +0000 (08:36 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Thu, 19 Sep 2002 15:36:56 +0000 (08:36 -0700)
From Hubertus Franke.

The MAP_LOCKED flag to mmap() currently does nothing.  Hubertus' patch
fixes it so that the relevant mapping is locked into memory, if the
called has CAP_IPC_LOCK.

mm/mmap.c

index 3a2dec63e96d8cab1fe41a2cd1c3bbc26095d68b..309d4014f05027edf9cbdeb0b26c596cd4e779aa 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -463,6 +463,11 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
         */
        vm_flags = calc_vm_flags(prot,flags) | mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
 
+       if (flags & MAP_LOCKED) {
+               if (!capable(CAP_IPC_LOCK))
+                       return -EPERM;
+               vm_flags |= VM_LOCKED;
+       }
        /* mlock MCL_FUTURE? */
        if (vm_flags & VM_LOCKED) {
                unsigned long locked = mm->locked_vm << PAGE_SHIFT;