Commit 302cabb7 authored by Seth Forshee's avatar Seth Forshee Committed by Kamal Mostafa

UBUNTU: SAUCE: (namespace) Sync with upstream s_user_ns patches

BugLink: http://bugs.launchpad.net/bugs/1588056

Sync up with changes from Eric Biederman when merging s_user_ns
support upstream. Partial backport of
6e4eab57 from linux-next.
Signed-off-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Acked-by: default avatarTim Gardner <tim.gardner@canonical.com>
Acked-by: default avatarBrad Figg <brad.figg@canonical.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent a5abdcb3
......@@ -242,7 +242,8 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
info->root = root;
info->ns = ns;
sb = sget(fs_type, kernfs_test_super, kernfs_set_super, flags, info);
sb = sget_userns(fs_type, kernfs_test_super, kernfs_set_super, flags,
&init_user_ns, info);
if (IS_ERR(sb) || sb->s_fs_info != info)
kfree(info);
if (IS_ERR(sb))
......
......@@ -531,7 +531,13 @@ struct super_block *sget(struct file_system_type *type,
int flags,
void *data)
{
return sget_userns(type, test, set, flags, current_user_ns(), data);
struct user_namespace *user_ns = current_user_ns();
/* Ensure the requestor has permissions over the target filesystem */
if (!(flags & MS_KERNMOUNT) && !ns_capable(user_ns, CAP_SYS_ADMIN))
return ERR_PTR(-EPERM);
return sget_userns(type, test, set, flags, user_ns, data);
}
EXPORT_SYMBOL(sget);
......@@ -963,7 +969,8 @@ struct dentry *mount_ns(struct file_system_type *fs_type,
if (!(flags & MS_KERNMOUNT) && !ns_capable(user_ns, CAP_SYS_ADMIN))
return ERR_PTR(-EPERM);
sb = sget(fs_type, ns_test_super, ns_set_super, flags, ns);
sb = sget_userns(fs_type, ns_test_super, ns_set_super, flags,
user_ns, ns);
if (IS_ERR(sb))
return ERR_CAST(sb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment