Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02967ea0 authored by Doug Ledford's avatar Doug Ledford Committed by Linus Torvalds
Browse files

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: default avatarDoug 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: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 858ee378
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -301,8 +301,9 @@ static int mqueue_create(struct inode *dir, struct dentry *dentry,
		error = -EACCES;
		error = -EACCES;
		goto out_unlock;
		goto out_unlock;
	}
	}
	if (ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max &&
	if (ipc_ns->mq_queues_count >= HARD_QUEUESMAX ||
			!capable(CAP_SYS_RESOURCE)) {
	    (ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max &&
	     !capable(CAP_SYS_RESOURCE))) {
		error = -ENOSPC;
		error = -ENOSPC;
		goto out_unlock;
		goto out_unlock;
	}
	}
@@ -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)
	if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0)
		return 0;
		return 0;
	if (capable(CAP_SYS_RESOURCE)) {
	if (capable(CAP_SYS_RESOURCE)) {
		if (attr->mq_maxmsg > HARD_MSGMAX)
		if (attr->mq_maxmsg > HARD_MSGMAX ||
		    attr->mq_msgsize > HARD_MSGSIZEMAX)
			return 0;
			return 0;
	} else {
	} else {
		if (attr->mq_maxmsg > ipc_ns->mq_msg_max ||
		if (attr->mq_maxmsg > ipc_ns->mq_msg_max ||