aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2012-05-31 19:26:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-31 20:49:30 -0400
commit02967ea08ede0f8cc7e0526aedffdae65a099b07 (patch)
treeda66e39cf3023f437f43db1f58d510c99b8478fd
parent858ee3784e8105467f1f3017f4ece51cb51d4830 (diff)
ipc/mqueue: enforce hard limits
In two places we don't enforce the hard limits for CAP_SYS_RESOURCE apps. In preparation for making more reasonable hard limits, start enforcing them even on CAP_SYS_RESOURCE. Signed-off-by: Doug Ledford <dledford@redhat.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: Amerigo Wang <amwang@redhat.com> Cc: Joe Korty <joe.korty@ccur.com> Cc: Jiri Slaby <jslaby@suse.cz> Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--ipc/mqueue.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index b103022179a3..6e10a55a78c5 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -301,8 +301,9 @@ static int mqueue_create(struct inode *dir, struct dentry *dentry,
301 error = -EACCES; 301 error = -EACCES;
302 goto out_unlock; 302 goto out_unlock;
303 } 303 }
304 if (ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max && 304 if (ipc_ns->mq_queues_count >= HARD_QUEUESMAX ||
305 !capable(CAP_SYS_RESOURCE)) { 305 (ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max &&
306 !capable(CAP_SYS_RESOURCE))) {
306 error = -ENOSPC; 307 error = -ENOSPC;
307 goto out_unlock; 308 goto out_unlock;
308 } 309 }
@@ -589,7 +590,8 @@ static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr)
589 if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0) 590 if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0)
590 return 0; 591 return 0;
591 if (capable(CAP_SYS_RESOURCE)) { 592 if (capable(CAP_SYS_RESOURCE)) {
592 if (attr->mq_maxmsg > HARD_MSGMAX) 593 if (attr->mq_maxmsg > HARD_MSGMAX ||
594 attr->mq_msgsize > HARD_MSGSIZEMAX)
593 return 0; 595 return 0;
594 } else { 596 } else {
595 if (attr->mq_maxmsg > ipc_ns->mq_msg_max || 597 if (attr->mq_maxmsg > ipc_ns->mq_msg_max ||