]> git.baikalelectronics.ru Git - kernel.git/commitdiff
fix sysfs_init_fs_context() in !CONFIG_NET_NS case
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 16 Mar 2019 13:45:42 +0000 (09:45 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 16 Mar 2019 13:45:42 +0000 (09:45 -0400)
Permission checks on current's netns should be done only when
netns are enabled.

Reported-by: Dominik Brodowski <linux@dominikbrodowski.net>
Fixes: 2231ce6dd1c1
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/sysfs/mount.c

index 4cb21b558a856188de12cb33d5b0bba4a85fb551..1b56686ab178dc6d4363ea2f76fde6cff90926da 100644 (file)
@@ -71,9 +71,11 @@ static int sysfs_init_fs_context(struct fs_context *fc)
        kfc->magic = SYSFS_MAGIC;
        fc->fs_private = kfc;
        fc->ops = &sysfs_fs_context_ops;
-       if (fc->user_ns)
-               put_user_ns(fc->user_ns);
-       fc->user_ns = get_user_ns(netns->user_ns);
+       if (netns) {
+               if (fc->user_ns)
+                       put_user_ns(fc->user_ns);
+               fc->user_ns = get_user_ns(netns->user_ns);
+       }
        fc->global = true;
        return 0;
 }