Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756118AbbGPQAM (ORCPT ); Thu, 16 Jul 2015 12:00:12 -0400 Received: from mail-ob0-f173.google.com ([209.85.214.173]:33559 "EHLO mail-ob0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751083AbbGPQAJ (ORCPT ); Thu, 16 Jul 2015 12:00:09 -0400 Date: Thu, 16 Jul 2015 10:59:05 -0500 From: Seth Forshee To: "Eric W. Biederman" Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Serge Hallyn , Andy Lutomirski , linux-kernel@vger.kernel.org, Casey Schaufler Subject: Re: [PATCH 0/7] Initial support for user namespace owned mounts Message-ID: <20150716155905.GA51751@ubuntu-hedt> References: <1436989569-69582-1-git-send-email-seth.forshee@canonical.com> <87615k7pyu.fsf@x220.int.ebiederm.org> <20150716135947.GC77715@ubuntu-hedt> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150716135947.GC77715@ubuntu-hedt> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2533 Lines: 58 On Thu, Jul 16, 2015 at 08:59:47AM -0500, Seth Forshee wrote: > 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. What might work instead is to add a check in security_sb_kern_mount. Then it would need to check s_user_ns, that way if proc, sysfs, etc. use sget_userns(..., &init_user_ns) they can still be mounted in containers. It would be nicer to have a hook after sget but before fill_super so that a bunch of work doesn't have to be done and then undone. Right now there doesn't seem to be any suitable hook. > > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/