Merge tag 'powerpc-4.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[cascardo/linux.git] / ipc / mqueue.c
index ade739f..8cbd6e6 100644 (file)
@@ -225,7 +225,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
        inode->i_mode = mode;
        inode->i_uid = current_fsuid();
        inode->i_gid = current_fsgid();
-       inode->i_mtime = inode->i_ctime = inode->i_atime = CURRENT_TIME;
+       inode->i_mtime = inode->i_ctime = inode->i_atime = current_time(inode);
 
        if (S_ISREG(mode)) {
                struct mqueue_inode_info *info;
@@ -305,8 +305,9 @@ err:
 static int mqueue_fill_super(struct super_block *sb, void *data, int silent)
 {
        struct inode *inode;
-       struct ipc_namespace *ns = data;
+       struct ipc_namespace *ns = sb->s_fs_info;
 
+       sb->s_iflags |= SB_I_NOEXEC | SB_I_NODEV;
        sb->s_blocksize = PAGE_SIZE;
        sb->s_blocksize_bits = PAGE_SHIFT;
        sb->s_magic = MQUEUE_MAGIC;
@@ -326,17 +327,14 @@ static struct dentry *mqueue_mount(struct file_system_type *fs_type,
                         int flags, const char *dev_name,
                         void *data)
 {
-       if (!(flags & MS_KERNMOUNT)) {
-               struct ipc_namespace *ns = current->nsproxy->ipc_ns;
-               /* Don't allow mounting unless the caller has CAP_SYS_ADMIN
-                * over the ipc namespace.
-                */
-               if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
-                       return ERR_PTR(-EPERM);
-
-               data = ns;
+       struct ipc_namespace *ns;
+       if (flags & MS_KERNMOUNT) {
+               ns = data;
+               data = NULL;
+       } else {
+               ns = current->nsproxy->ipc_ns;
        }
-       return mount_ns(fs_type, flags, data, mqueue_fill_super);
+       return mount_ns(fs_type, flags, data, ns, ns->user_ns, mqueue_fill_super);
 }
 
 static void init_once(void *foo)
@@ -448,7 +446,7 @@ static int mqueue_create(struct inode *dir, struct dentry *dentry,
 
        put_ipc_ns(ipc_ns);
        dir->i_size += DIRENT_SIZE;
-       dir->i_ctime = dir->i_mtime = dir->i_atime = CURRENT_TIME;
+       dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir);
 
        d_instantiate(dentry, inode);
        dget(dentry);
@@ -464,7 +462,7 @@ static int mqueue_unlink(struct inode *dir, struct dentry *dentry)
 {
        struct inode *inode = d_inode(dentry);
 
-       dir->i_ctime = dir->i_mtime = dir->i_atime = CURRENT_TIME;
+       dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir);
        dir->i_size -= DIRENT_SIZE;
        drop_nlink(inode);
        dput(dentry);
@@ -502,7 +500,7 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data,
        if (ret <= 0)
                return ret;
 
-       file_inode(filp)->i_atime = file_inode(filp)->i_ctime = CURRENT_TIME;
+       file_inode(filp)->i_atime = file_inode(filp)->i_ctime = current_time(file_inode(filp));
        return ret;
 }
 
@@ -1062,7 +1060,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
                        __do_notify(info);
                }
                inode->i_atime = inode->i_mtime = inode->i_ctime =
-                               CURRENT_TIME;
+                               current_time(inode);
        }
 out_unlock:
        spin_unlock(&info->lock);
@@ -1158,7 +1156,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
                msg_ptr = msg_get(info);
 
                inode->i_atime = inode->i_mtime = inode->i_ctime =
-                               CURRENT_TIME;
+                               current_time(inode);
 
                /* There is now free space in queue. */
                pipelined_receive(&wake_q, info);
@@ -1279,7 +1277,7 @@ retry:
        if (u_notification == NULL) {
                if (info->notify_owner == task_tgid(current)) {
                        remove_notification(info);
-                       inode->i_atime = inode->i_ctime = CURRENT_TIME;
+                       inode->i_atime = inode->i_ctime = current_time(inode);
                }
        } else if (info->notify_owner != NULL) {
                ret = -EBUSY;
@@ -1304,7 +1302,7 @@ retry:
 
                info->notify_owner = get_pid(task_tgid(current));
                info->notify_user_ns = get_user_ns(current_user_ns());
-               inode->i_atime = inode->i_ctime = CURRENT_TIME;
+               inode->i_atime = inode->i_ctime = current_time(inode);
        }
        spin_unlock(&info->lock);
 out_fput:
@@ -1361,7 +1359,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
                        f.file->f_flags &= ~O_NONBLOCK;
                spin_unlock(&f.file->f_lock);
 
-               inode->i_atime = inode->i_ctime = CURRENT_TIME;
+               inode->i_atime = inode->i_ctime = current_time(inode);
        }
 
        spin_unlock(&info->lock);