Ubuntu Pastebin

Paste from ubuntu at Tue, 23 Feb 2016 17:51:26 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
 			}
Download as text