Commit f1eb1332b8f07e937add24c6fd2ac40b8737a2f4
Committed by
Linus Torvalds
1 parent
d6db2ade10
ipc: use rlimit helpers
Make sure compiler won't do weird things with limits. E.g. fetching them twice may return 2 different values after writable limits are implemented. I.e. either use rlimit helpers added in 3e10e716abf3c71bdb5d86b8f507f9e72236c9cd ("resource: add helpers for fetching rlimits") or ACCESS_ONCE if not applicable. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 2 additions and 3 deletions Side-by-side Diff
ipc/mqueue.c
... | ... | @@ -155,7 +155,7 @@ |
155 | 155 | spin_lock(&mq_lock); |
156 | 156 | if (u->mq_bytes + mq_bytes < u->mq_bytes || |
157 | 157 | u->mq_bytes + mq_bytes > |
158 | - p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) { | |
158 | + task_rlimit(p, RLIMIT_MSGQUEUE)) { | |
159 | 159 | spin_unlock(&mq_lock); |
160 | 160 | kfree(info->messages); |
161 | 161 | goto out_inode; |
ipc/shm.c
... | ... | @@ -764,8 +764,7 @@ |
764 | 764 | if (euid != shp->shm_perm.uid && |
765 | 765 | euid != shp->shm_perm.cuid) |
766 | 766 | goto out_unlock; |
767 | - if (cmd == SHM_LOCK && | |
768 | - !current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur) | |
767 | + if (cmd == SHM_LOCK && !rlimit(RLIMIT_MEMLOCK)) | |
769 | 768 | goto out_unlock; |
770 | 769 | } |
771 | 770 |