Skip to content

Commit

Permalink
ipc/mqueue: enforce hard limits
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Serge E. Hallyn <[email protected]>
Cc: Amerigo Wang <[email protected]>
Cc: Joe Korty <[email protected]>
Cc: Jiri Slaby <[email protected]>
Acked-by: KOSAKI Motohiro <[email protected]>
Cc: Manfred Spraul <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
dledford authored and torvalds committed Jun 1, 2012
1 parent 858ee37 commit 02967ea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,9 @@ static int mqueue_create(struct inode *dir, struct dentry *dentry,
error = -EACCES;
goto out_unlock;
}
if (ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max &&
!capable(CAP_SYS_RESOURCE)) {
if (ipc_ns->mq_queues_count >= HARD_QUEUESMAX ||
(ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max &&
!capable(CAP_SYS_RESOURCE))) {
error = -ENOSPC;
goto out_unlock;
}
Expand Down Expand Up @@ -589,7 +590,8 @@ static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr)
if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0)
return 0;
if (capable(CAP_SYS_RESOURCE)) {
if (attr->mq_maxmsg > HARD_MSGMAX)
if (attr->mq_maxmsg > HARD_MSGMAX ||
attr->mq_msgsize > HARD_MSGSIZEMAX)
return 0;
} else {
if (attr->mq_maxmsg > ipc_ns->mq_msg_max ||
Expand Down

0 comments on commit 02967ea

Please sign in to comment.