aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2008-12-14 04:02:26 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-01-04 15:14:41 -0500
commit564f6993ffef656aebaf46cf2f1f6cb4f5c97207 (patch)
tree0bf1ee553ab1241338fe522ffbaed8cd48e10c99 /ipc
parentc32c8af43b9adde8d6f938d8e6328c13b8de79ac (diff)
sanitize audit_mq_open()
* don't bother with allocations * don't do double copy_from_user() * don't duplicate parts of check for audit_dummy_context() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/mqueue.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 192da806c28..d448b69672b 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -588,22 +588,18 @@ static int mq_attr_ok(struct mq_attr *attr)
588 * Invoked when creating a new queue via sys_mq_open 588 * Invoked when creating a new queue via sys_mq_open
589 */ 589 */
590static struct file *do_create(struct dentry *dir, struct dentry *dentry, 590static struct file *do_create(struct dentry *dir, struct dentry *dentry,
591 int oflag, mode_t mode, struct mq_attr __user *u_attr) 591 int oflag, mode_t mode, struct mq_attr *attr)
592{ 592{
593 const struct cred *cred = current_cred(); 593 const struct cred *cred = current_cred();
594 struct mq_attr attr;
595 struct file *result; 594 struct file *result;
596 int ret; 595 int ret;
597 596
598 if (u_attr) { 597 if (attr) {
599 ret = -EFAULT;
600 if (copy_from_user(&attr, u_attr, sizeof(attr)))
601 goto out;
602 ret = -EINVAL; 598 ret = -EINVAL;
603 if (!mq_attr_ok(&attr)) 599 if (!mq_attr_ok(attr))
604 goto out; 600 goto out;
605 /* store for use during create */ 601 /* store for use during create */
606 dentry->d_fsdata = &attr; 602 dentry->d_fsdata = attr;
607 } 603 }
608 604
609 mode &= ~current->fs->umask; 605 mode &= ~current->fs->umask;
@@ -660,11 +656,13 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
660 struct dentry *dentry; 656 struct dentry *dentry;
661 struct file *filp; 657 struct file *filp;
662 char *name; 658 char *name;
659 struct mq_attr attr;
663 int fd, error; 660 int fd, error;
664 661
665 error = audit_mq_open(oflag, mode, u_attr); 662 if (u_attr && copy_from_user(&attr, u_attr, sizeof(struct mq_attr)))
666 if (error != 0) 663 return -EFAULT;
667 return error; 664
665 audit_mq_open(oflag, mode, u_attr ? &attr : NULL);
668 666
669 if (IS_ERR(name = getname(u_name))) 667 if (IS_ERR(name = getname(u_name)))
670 return PTR_ERR(name); 668 return PTR_ERR(name);
@@ -690,7 +688,8 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
690 filp = do_open(dentry, oflag); 688 filp = do_open(dentry, oflag);
691 } else { 689 } else {
692 filp = do_create(mqueue_mnt->mnt_root, dentry, 690 filp = do_create(mqueue_mnt->mnt_root, dentry,
693 oflag, mode, u_attr); 691 oflag, mode,
692 u_attr ? &attr : NULL);
694 } 693 }
695 } else { 694 } else {
696 error = -ENOENT; 695 error = -ENOENT;