Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 185736
b: refs/heads/master
c: 04db0dd
h: refs/heads/master
v: v3
  • Loading branch information
André Goddard Rosa authored and Al Viro committed Mar 3, 2010
1 parent b39ed1e commit 25926bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 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: 8834cf796a4320be2d3a70b1e4f9aba732a0f4ee
refs/heads/master: 04db0dde0ee1c29110642dff57fba9e438eb805c
16 changes: 10 additions & 6 deletions trunk/ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,24 +657,28 @@ static struct file *do_create(struct ipc_namespace *ipc_ns, struct dentry *dir,
static struct file *do_open(struct ipc_namespace *ipc_ns,
struct dentry *dentry, int oflag)
{
int ret;
const struct cred *cred = current_cred();

static const int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE,
MAY_READ | MAY_WRITE };

if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY)) {
dput(dentry);
mntput(ipc_ns->mq_mnt);
return ERR_PTR(-EINVAL);
ret = -EINVAL;
goto err;
}

if (inode_permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE])) {
dput(dentry);
mntput(ipc_ns->mq_mnt);
return ERR_PTR(-EACCES);
ret = -EACCES;
goto err;
}

return dentry_open(dentry, ipc_ns->mq_mnt, oflag, cred);

err:
dput(dentry);
mntput(ipc_ns->mq_mnt);
return ERR_PTR(ret);
}

SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, mode_t, mode,
Expand Down

0 comments on commit 25926bb

Please sign in to comment.