X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=mm%2Fmlock.c;h=7b2656055d6a96a6b940574e4d23f0a4fc7dd6bc;hb=5b0bf5e25efe;hp=3446b7ef731e6c419cc0cf2656829eeca6fea5a7;hpb=6ee7e78e7c78d871409ad4df30551c9355be7d0e;p=pandora-kernel.git diff --git a/mm/mlock.c b/mm/mlock.c index 3446b7ef731e..7b2656055d6a 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -10,7 +10,18 @@ #include #include #include +#include +#include +int can_do_mlock(void) +{ + if (capable(CAP_IPC_LOCK)) + return 1; + if (current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur != 0) + return 1; + return 0; +} +EXPORT_SYMBOL(can_do_mlock); static int mlock_fixup(struct vm_area_struct *vma, struct vm_area_struct **prev, unsigned long start, unsigned long end, unsigned int newflags) @@ -233,9 +244,12 @@ int user_shm_lock(size_t size, struct user_struct *user) locked = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; + if (lock_limit == RLIM_INFINITY) + allowed = 1; lock_limit >>= PAGE_SHIFT; spin_lock(&shmlock_user_lock); - if (locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK)) + if (!allowed && + locked + user->locked_shm > lock_limit && !capable(CAP_IPC_LOCK)) goto out; get_uid(user); user->locked_shm += locked;