Commit 859629c6 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix mmap(MAP_LOCKED)

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.
parent d51832f3
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment