@@ -136,7 +136,8 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
down_write(¤t->mm->mmap_sem);
locked = npages + current->mm->locked_vm;
- lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
+ lock_limit = ACCESS_ONCE(current->signal->
+ rlim[RLIMIT_MEMLOCK].rlim_cur) >> PAGE_SHIFT;
if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
ret = -ENOMEM;
@@ -59,8 +59,8 @@ static int __get_user_pages(unsigned long start_page, size_t num_pages,
size_t got;
int ret;
- lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
- PAGE_SHIFT;
+ lock_limit = ACCESS_ONCE(current->signal->
+ rlim[RLIMIT_MEMLOCK].rlim_cur) >> PAGE_SHIFT;
if (num_pages > lock_limit) {
ret = -ENOMEM;
@@ -152,8 +152,8 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
spin_lock(&mq_lock);
if (u->mq_bytes + mq_bytes < u->mq_bytes ||
- u->mq_bytes + mq_bytes >
- p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) {
+ u->mq_bytes + mq_bytes > ACCESS_ONCE(p->signal->
+ rlim[RLIMIT_MSGQUEUE].rlim_cur)) {
spin_unlock(&mq_lock);
goto out_inode;
}
@@ -761,8 +761,8 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
if (euid != shp->shm_perm.uid &&
euid != shp->shm_perm.cuid)
goto out_unlock;
- if (cmd == SHM_LOCK &&
- !current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur)
+ if (cmd == SHM_LOCK && !ACCESS_ONCE(current->signal->
+ rlim[RLIMIT_MEMLOCK].rlim_cur))
goto out_unlock;
}