aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/mqueue.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/mqueue.c')
-rw-r--r--ipc/mqueue.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 68eb857cfdea..d9393f8e4c3e 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -112,13 +112,14 @@ static inline struct mqueue_inode_info *MQUEUE_I(struct inode *inode)
112static struct inode *mqueue_get_inode(struct super_block *sb, int mode, 112static struct inode *mqueue_get_inode(struct super_block *sb, int mode,
113 struct mq_attr *attr) 113 struct mq_attr *attr)
114{ 114{
115 struct user_struct *u = current_user();
115 struct inode *inode; 116 struct inode *inode;
116 117
117 inode = new_inode(sb); 118 inode = new_inode(sb);
118 if (inode) { 119 if (inode) {
119 inode->i_mode = mode; 120 inode->i_mode = mode;
120 inode->i_uid = current->fsuid; 121 inode->i_uid = current_fsuid();
121 inode->i_gid = current->fsgid; 122 inode->i_gid = current_fsgid();
122 inode->i_blocks = 0; 123 inode->i_blocks = 0;
123 inode->i_mtime = inode->i_ctime = inode->i_atime = 124 inode->i_mtime = inode->i_ctime = inode->i_atime =
124 CURRENT_TIME; 125 CURRENT_TIME;
@@ -126,7 +127,6 @@ static struct inode *mqueue_get_inode(struct super_block *sb, int mode,
126 if (S_ISREG(mode)) { 127 if (S_ISREG(mode)) {
127 struct mqueue_inode_info *info; 128 struct mqueue_inode_info *info;
128 struct task_struct *p = current; 129 struct task_struct *p = current;
129 struct user_struct *u = p->user;
130 unsigned long mq_bytes, mq_msg_tblsz; 130 unsigned long mq_bytes, mq_msg_tblsz;
131 131
132 inode->i_fop = &mqueue_file_operations; 132 inode->i_fop = &mqueue_file_operations;
@@ -507,7 +507,7 @@ static void __do_notify(struct mqueue_inode_info *info)
507 sig_i.si_code = SI_MESGQ; 507 sig_i.si_code = SI_MESGQ;
508 sig_i.si_value = info->notify.sigev_value; 508 sig_i.si_value = info->notify.sigev_value;
509 sig_i.si_pid = task_tgid_vnr(current); 509 sig_i.si_pid = task_tgid_vnr(current);
510 sig_i.si_uid = current->uid; 510 sig_i.si_uid = current_uid();
511 511
512 kill_pid_info(info->notify.sigev_signo, 512 kill_pid_info(info->notify.sigev_signo,
513 &sig_i, info->notify_owner); 513 &sig_i, info->notify_owner);
@@ -594,6 +594,7 @@ static int mq_attr_ok(struct mq_attr *attr)
594static struct file *do_create(struct dentry *dir, struct dentry *dentry, 594static struct file *do_create(struct dentry *dir, struct dentry *dentry,
595 int oflag, mode_t mode, struct mq_attr __user *u_attr) 595 int oflag, mode_t mode, struct mq_attr __user *u_attr)
596{ 596{
597 const struct cred *cred = current_cred();
597 struct mq_attr attr; 598 struct mq_attr attr;
598 struct file *result; 599 struct file *result;
599 int ret; 600 int ret;
@@ -618,7 +619,7 @@ static struct file *do_create(struct dentry *dir, struct dentry *dentry,
618 if (ret) 619 if (ret)
619 goto out_drop_write; 620 goto out_drop_write;
620 621
621 result = dentry_open(dentry, mqueue_mnt, oflag); 622 result = dentry_open(dentry, mqueue_mnt, oflag, cred);
622 /* 623 /*
623 * dentry_open() took a persistent mnt_want_write(), 624 * dentry_open() took a persistent mnt_want_write(),
624 * so we can now drop this one. 625 * so we can now drop this one.
@@ -637,8 +638,10 @@ out:
637/* Opens existing queue */ 638/* Opens existing queue */
638static struct file *do_open(struct dentry *dentry, int oflag) 639static struct file *do_open(struct dentry *dentry, int oflag)
639{ 640{
640static int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE, 641 const struct cred *cred = current_cred();
641 MAY_READ | MAY_WRITE }; 642
643 static const int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE,
644 MAY_READ | MAY_WRITE };
642 645
643 if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY)) { 646 if ((oflag & O_ACCMODE) == (O_RDWR | O_WRONLY)) {
644 dput(dentry); 647 dput(dentry);
@@ -652,7 +655,7 @@ static int oflag2acc[O_ACCMODE] = { MAY_READ, MAY_WRITE,
652 return ERR_PTR(-EACCES); 655 return ERR_PTR(-EACCES);
653 } 656 }
654 657
655 return dentry_open(dentry, mqueue_mnt, oflag); 658 return dentry_open(dentry, mqueue_mnt, oflag, cred);
656} 659}
657 660
658asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode, 661asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,