aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-10-10 15:25:28 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-12 20:14:55 -0400
commit91a27b2a756784714e924e5e854b919273082d26 (patch)
tree3913246b7d6e62703ec915f481e3a7159393f0f0 /ipc
parent8e377d15078a501c4da98471f56396343c407d92 (diff)
vfs: define struct filename and have getname() return it
getname() is intended to copy pathname strings from userspace into a kernel buffer. The result is just a string in kernel space. It would however be quite helpful to be able to attach some ancillary info to the string. For instance, we could attach some audit-related info to reduce the amount of audit-related processing needed. When auditing is enabled, we could also call getname() on the string more than once and not need to recopy it from userspace. This patchset converts the getname()/putname() interfaces to return a struct instead of a string. For now, the struct just tracks the string in kernel space and the original userland pointer for it. Later, we'll add other information to the struct as it becomes convenient. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/mqueue.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 9553ed006042..6c5d9dcc9030 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -772,7 +772,7 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, umode_t, mode,
772{ 772{
773 struct path path; 773 struct path path;
774 struct file *filp; 774 struct file *filp;
775 char *name; 775 struct filename *name;
776 struct mq_attr attr; 776 struct mq_attr attr;
777 int fd, error; 777 int fd, error;
778 struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns; 778 struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
@@ -795,7 +795,7 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, umode_t, mode,
795 ro = mnt_want_write(mnt); /* we'll drop it in any case */ 795 ro = mnt_want_write(mnt); /* we'll drop it in any case */
796 error = 0; 796 error = 0;
797 mutex_lock(&root->d_inode->i_mutex); 797 mutex_lock(&root->d_inode->i_mutex);
798 path.dentry = lookup_one_len(name, root, strlen(name)); 798 path.dentry = lookup_one_len(name->name, root, strlen(name->name));
799 if (IS_ERR(path.dentry)) { 799 if (IS_ERR(path.dentry)) {
800 error = PTR_ERR(path.dentry); 800 error = PTR_ERR(path.dentry);
801 goto out_putfd; 801 goto out_putfd;
@@ -804,7 +804,7 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, umode_t, mode,
804 804
805 if (oflag & O_CREAT) { 805 if (oflag & O_CREAT) {
806 if (path.dentry->d_inode) { /* entry already exists */ 806 if (path.dentry->d_inode) { /* entry already exists */
807 audit_inode(name, path.dentry, 0); 807 audit_inode(name->name, path.dentry, 0);
808 if (oflag & O_EXCL) { 808 if (oflag & O_EXCL) {
809 error = -EEXIST; 809 error = -EEXIST;
810 goto out; 810 goto out;
@@ -824,7 +824,7 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, umode_t, mode,
824 error = -ENOENT; 824 error = -ENOENT;
825 goto out; 825 goto out;
826 } 826 }
827 audit_inode(name, path.dentry, 0); 827 audit_inode(name->name, path.dentry, 0);
828 filp = do_open(&path, oflag); 828 filp = do_open(&path, oflag);
829 } 829 }
830 830
@@ -849,7 +849,7 @@ out_putname:
849SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name) 849SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name)
850{ 850{
851 int err; 851 int err;
852 char *name; 852 struct filename *name;
853 struct dentry *dentry; 853 struct dentry *dentry;
854 struct inode *inode = NULL; 854 struct inode *inode = NULL;
855 struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns; 855 struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
@@ -863,7 +863,8 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name)
863 if (err) 863 if (err)
864 goto out_name; 864 goto out_name;
865 mutex_lock_nested(&mnt->mnt_root->d_inode->i_mutex, I_MUTEX_PARENT); 865 mutex_lock_nested(&mnt->mnt_root->d_inode->i_mutex, I_MUTEX_PARENT);
866 dentry = lookup_one_len(name, mnt->mnt_root, strlen(name)); 866 dentry = lookup_one_len(name->name, mnt->mnt_root,
867 strlen(name->name));
867 if (IS_ERR(dentry)) { 868 if (IS_ERR(dentry)) {
868 err = PTR_ERR(dentry); 869 err = PTR_ERR(dentry);
869 goto out_unlock; 870 goto out_unlock;