diff --git a/fs/super.c b/fs/super.c
index 732bffa..42ef8d8 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -446,6 +446,17 @@ void generic_shutdown_super(struct super_block *sb)
EXPORT_SYMBOL(generic_shutdown_super);
+static bool verify_userns_access(struct file_system_type *type,
+ struct user_namespace *sb_ns,
+ struct user_namespace *task_ns)
+{
+ if (type->fs_flags & FS_USERNS_MOUNT &&
+ !(type->fs_flags & FS_REQUIRES_DEV))
+ return true;
+ return (sb_ns == task_ns);
+}
+
+
/**
* sget_userns - find or create a superblock
* @type: filesystem type superblock should belong to
@@ -471,7 +482,7 @@ retry:
hlist_for_each_entry(old, &type->fs_supers, s_instances) {
if (!test(old, data))
continue;
- if (user_ns != old->s_user_ns) {
+ if (!verify_userns_access(type, old->s_user_ns, user_ns)) {
spin_unlock(&sb_lock);
return ERR_PTR(-EBUSY);
}