Re: [PATCH 0/7] Initial support for user namespace owned mounts

Seth Forshee
2015-07-16T14:00:55Z

On Wed, Jul 15, 2015 at 10:15:21PM -0500, Eric W. Biederman wrote:
>
> Seth I think for the LSMs we should start with:
>
> diff --git a/security/security.c b/security/security.c
> index 062f3c997fdc..5b6ece92a8e5 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -310,6 +310,8 @@ int security_sb_statfs(struct dentry *dentry)
> int security_sb_mount(const char *dev_name, struct path *path,
> const char *type, unsigned long flags, void *data)
> {
> + if (current_user_ns() != &init_user_ns)
> + return -EPERM;
> return call_int_hook(sb_mount, 0, dev_name, path, type, flags, data);
> }

This just makes it impossible to mount from a user namespace. Every
mount from current_user_ns() != &init_user_ns will fail.

> Then we should push this down into all of the lsms.
> Then when we should remove or relax or change the check as appropriate
> in each lsm.
>
> The point is this is good enough to see that it is trivially safe,
> and this allows us to focus on the core issues, and stop worrying about
> the lsms for a bit.
>
> Then we can focus on each lsm one at at time and take the time to really
> understand them and talk with their maintainers etc to make certain
> we get things correct.
>
> This should remove the need for your patches 5, 6 and 7. For the
> immediate future.

I'm still not entirely sure what you were trying to do, maybe refuse to
mount whenever a security module is loaded? I think this could be a good
option to start, but couldn't we restrict it to only the LSMs which use
xattrs for security labels? In situations where the filesystem cannot
supply security policy metadata I can't think of any reason to disallow
the mounts.

Seth