From: viro@parcelfarce.linux.theplanet.co.uk Subject: Re: changing permission()/vfs_permission... to work on dentry Date: Thu, 29 May 2003 01:55:49 +0100 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <20030529005549.GJ14138@parcelfarce.linux.theplanet.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from parcelfarce.linux.theplanet.co.uk ([195.92.249.252]:41617 "EHLO www.linux.org.uk") by vger.kernel.org with ESMTP id S261783AbTE2Amd (ORCPT ); Wed, 28 May 2003 20:42:33 -0400 Received: from viro by www.linux.org.uk with local (Exim 4.14) id 19LBht-000776-NC for linux-fsdevel@vger.kernel.org; Thu, 29 May 2003 01:55:49 +0100 To: linux-fsdevel@vger.kernel.org Content-Disposition: inline List-Id: linux-fsdevel.vger.kernel.org On Wed, May 28, 2003 at 08:29:13PM -0400, Shaya Potter wrote: > > Define "real". There can be a lot of them and none are more real than > > other - same situation as with dentries, actually (all links have the > > same status; there is no "primary" one). > > well real depends on what you want. Take for instance the example I > gave w/ the context, the context can contain a vfsmount, which you then > use. touch /tmp/zero && mount --bind /dev/zero /tmp/zero After that we have a vfsmount mounted on /tmp/zero and pointing to superblock of root filesystem and dentry of dev/zero from it. Both /tmp/zero and /dev/zero will resolve to the same inode (and same dentry, for that matter). vfsmounts are different and both are obviously visible to your process. Which one is "real"? What's more, I can e.g. mount ramfs on /mnt, then bind it on /tmp/foo and /tmp/bar and umount /mnt. After that we have the same tree mounted twice and original vfsmount already gone. Which one is real - one for /tmp/foo or one for /tmp/bar? > > You'll need to propagate pointers to vfsmounts and it won't be pretty - > > e.g. hpfs_unlink() calls permission() and passing vfsmount to ->unlink() > > is just plain *wrong*. > > one doesn't have to. permission() figures out calling process > (current->uid), figures out calling processes context. See above. > yes. The issue we are trying to solve (much like SubDomain > http://www.immunix.org/subdomain.html) is that you have a single fs, but > not every application needs access to that entire namespace, but from an > administrative point of view, its easier to deal w/ a single namespace. > For instance, sendmail doesn't need /bin/sh, it be fairly hard to > administrate a sendmail box that didn't have it though. If there's no > /bin/sh in the processes "namespace" (used loosely, as in mode 000 to it So give it a _REAL_ namespace. And bind /dev/null over /bin/sh in it. And revoke the capability to call mount(2) and umount(2). End of story. > and even uid 0 processes) the ability to get a root shell is limited. And why would I need a /bin/sh binary if I'd already acquired control over a process that runs with UID 0? Anyway, judging by the description on immunix.org, it looks fairly useless these days. We can trivially do the same without any kernel extensions: | * A SubDomain is easier to construct than a chroot environment. | Instead of copying everything required for the program to run into | the chroot jail, SubDomain only requires that the files be | specified in the /etc/subdomain entry. Yes, and...? clone() with CLONE_NEWNS, bind whatever you want wherever you feel like and you are done. | * SubDomain can share files with the rest of the system. Files in a | chroot jail are effectively isolated from the rest of the system. | They should not be hard- or sym-linked to files outside the chroot | jail, because they may provide an escape route. In contrast, | SubDomain allows flexible sharing with the rest of the system; | each file accessed also specifies the access modes (read, write, | and execute) that may be used. aside of the last bit, everything still applies. Per-mountpoint read_only is wort doing (and would cover the rest), but it can get tricky. Basically, you need IS_RDONLY() taking vfsmount and looking both into superblock and vfsmount flags. Then the same game with propagating new argument to all callers. | * SubDomain descriptions can be distributed. To distribute a | program along with its SubDomain jail, one need only package the | SubDomain specification along with the program. In contrast, | distributing a chroot jail is problematic; the files to be placed | in the chroot jail must actually be included in the package, and | are not consistent with the files on the system where they are | installed. In other words, SubDomain distributes a jail by | reference, while chroot distributes a jail by value. Ditto for namespaces. Comparison with FPOSIX crapabilities also applies, obviously. ----- End forwarded message -----