Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309766
b: refs/heads/master
c: 113289c
h: refs/heads/master
v: v3
  • Loading branch information
Doug Ledford authored and Linus Torvalds committed Jun 1, 2012
1 parent dd3ab03 commit 20dd7a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2c12ea498f349207c28840c0ed9654321aab7720
refs/heads/master: 113289cc086f80f28acd06f160a7c6423cdd4191
27 changes: 18 additions & 9 deletions trunk/ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,26 +680,26 @@ static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr)
unsigned long total_size;

if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0)
return 0;
return -EINVAL;
if (capable(CAP_SYS_RESOURCE)) {
if (attr->mq_maxmsg > HARD_MSGMAX ||
attr->mq_msgsize > HARD_MSGSIZEMAX)
return 0;
return -EINVAL;
} else {
if (attr->mq_maxmsg > ipc_ns->mq_msg_max ||
attr->mq_msgsize > ipc_ns->mq_msgsize_max)
return 0;
return -EINVAL;
}
/* check for overflow */
if (attr->mq_msgsize > ULONG_MAX/attr->mq_maxmsg)
return 0;
return -EOVERFLOW;
mq_treesize = attr->mq_maxmsg * sizeof(struct msg_msg) +
min_t(unsigned int, attr->mq_maxmsg, MQ_PRIO_MAX) *
sizeof(struct posix_msg_tree_node);
total_size = attr->mq_maxmsg * attr->mq_msgsize;
if (total_size + mq_treesize < total_size)
return 0;
return 1;
return -EOVERFLOW;
return 0;
}

/*
Expand All @@ -714,12 +714,21 @@ static struct file *do_create(struct ipc_namespace *ipc_ns, struct dentry *dir,
int ret;

if (attr) {
if (!mq_attr_ok(ipc_ns, attr)) {
ret = -EINVAL;
ret = mq_attr_ok(ipc_ns, attr);
if (ret)
goto out;
}
/* store for use during create */
dentry->d_fsdata = attr;
} else {
struct mq_attr def_attr;

def_attr.mq_maxmsg = min(ipc_ns->mq_msg_max,
ipc_ns->mq_msg_default);
def_attr.mq_msgsize = min(ipc_ns->mq_msgsize_max,
ipc_ns->mq_msgsize_default);
ret = mq_attr_ok(ipc_ns, &def_attr);
if (ret)
goto out;
}

mode &= ~current_umask();
Expand Down

0 comments on commit 20dd7a5

Please sign in to comment.