vfs: Pass data, ns, and ns->userns to mount_ns
[deliverable/linux.git] / fs / super.c
index 74914b1bae70ff09d451450cb596fb3b5639d969..fd65667832e568bce0aa1c133031297bb02dc255 100644 (file)
@@ -285,7 +285,7 @@ static void put_super(struct super_block *sb)
  *     deactivate_locked_super -       drop an active reference to superblock
  *     @s: superblock to deactivate
  *
- *     Drops an active reference to superblock, converting it into a temprory
+ *     Drops an active reference to superblock, converting it into a temporary
  *     one if there is no other active references left.  In that case we
  *     tell fs driver to shut it down and drop the temporary reference we
  *     had just acquired.
@@ -918,12 +918,19 @@ static int ns_set_super(struct super_block *sb, void *data)
        return set_anon_super(sb, NULL);
 }
 
-struct dentry *mount_ns(struct file_system_type *fs_type, int flags,
-       void *data, int (*fill_super)(struct super_block *, void *, int))
+struct dentry *mount_ns(struct file_system_type *fs_type,
+       int flags, void *data, void *ns, struct user_namespace *user_ns,
+       int (*fill_super)(struct super_block *, void *, int))
 {
        struct super_block *sb;
 
-       sb = sget(fs_type, ns_test_super, ns_set_super, flags, data);
+       /* Don't allow mounting unless the caller has CAP_SYS_ADMIN
+        * over the namespace.
+        */
+       if (!(flags & MS_KERNMOUNT) && !ns_capable(user_ns, CAP_SYS_ADMIN))
+               return ERR_PTR(-EPERM);
+
+       sb = sget(fs_type, ns_test_super, ns_set_super, flags, ns);
        if (IS_ERR(sb))
                return ERR_CAST(sb);
 
This page took 0.024315 seconds and 5 git commands to generate.