From: Doug Ledford Date: Thu, 3 May 2012 05:44:48 +0000 (+1000) Subject: ipc/mqueue: enforce hard limits X-Git-Tag: next-20120503~2^2~39 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=094974a497f3dff0ab691d7ce0db81d90db51cb0;p=karo-tx-linux.git 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 Cc: Serge E. Hallyn Cc: Amerigo Wang Cc: Joe Korty Cc: Jiri Slaby Acked-by: KOSAKI Motohiro Cc: Manfred Spraul Signed-off-by: Andrew Morton --- diff --git a/ipc/mqueue.c b/ipc/mqueue.c index b17826854d13..8f75d84c8166 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -299,8 +299,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; } @@ -584,7 +585,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 ||