Skip to content

Commit

Permalink
fix sysfs_init_fs_context() in !CONFIG_NET_NS case
Browse files Browse the repository at this point in the history
Permission checks on current's netns should be done only when
netns are enabled.

Reported-by: Dominik Brodowski <[email protected]>
Fixes: 23bf1b6
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Mar 16, 2019
1 parent c99c217 commit ab81dab
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions fs/sysfs/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ab81dab

Please sign in to comment.