Skip to content

Commit ab81dab

Browse files
author
Al Viro
committed
fix sysfs_init_fs_context() in !CONFIG_NET_NS case
Permission checks on current's netns should be done only when netns are enabled. Reported-by: Dominik Brodowski <linux@dominikbrodowski.net> Fixes: 23bf1b6 Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent c99c217 commit ab81dab

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fs/sysfs/mount.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ static int sysfs_init_fs_context(struct fs_context *fc)
7171
kfc->magic = SYSFS_MAGIC;
7272
fc->fs_private = kfc;
7373
fc->ops = &sysfs_fs_context_ops;
74-
if (fc->user_ns)
75-
put_user_ns(fc->user_ns);
76-
fc->user_ns = get_user_ns(netns->user_ns);
74+
if (netns) {
75+
if (fc->user_ns)
76+
put_user_ns(fc->user_ns);
77+
fc->user_ns = get_user_ns(netns->user_ns);
78+
}
7779
fc->global = true;
7880
return 0;
7981
}

0 commit comments

Comments
 (0)