userns: add a user_namespace as creator/owner of uts_namespace
[firefly-linux-kernel-4.4.55.git] / kernel / utsname.c
index 8a82b4b8ea52cb3690e25bf039eaf32ff5c8c079..a7b3a8d1ad24cebcd69982aa9d924542d02cb53a 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/utsname.h>
 #include <linux/err.h>
 #include <linux/slab.h>
+#include <linux/user_namespace.h>
 
 static struct uts_namespace *create_uts_ns(void)
 {
@@ -40,6 +41,8 @@ static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns)
 
        down_read(&uts_sem);
        memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
+       ns->user_ns = old_ns->user_ns;
+       get_user_ns(ns->user_ns);
        up_read(&uts_sem);
        return ns;
 }
@@ -71,5 +74,6 @@ void free_uts_ns(struct kref *kref)
        struct uts_namespace *ns;
 
        ns = container_of(kref, struct uts_namespace, kref);
+       put_user_ns(ns->user_ns);
        kfree(ns);
 }