Linux filesystem development
 help / color / mirror / Atom feed
* Re: changing permission()/vfs_permission... to work on dentry
@ 2003-05-29  0:55 viro
  2003-05-29  4:20 ` Shaya Potter
  0 siblings, 1 reply; 19+ messages in thread
From: viro @ 2003-05-29  0:55 UTC (permalink / raw)
  To: linux-fsdevel

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.

<shrug> 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 -----

^ permalink raw reply	[flat|nested] 19+ messages in thread
* changing permission()/vfs_permission... to work on dentry
@ 2003-05-28 20:43 Shaya Potter
  2003-05-28 21:48 ` viro
  0 siblings, 1 reply; 19+ messages in thread
From: Shaya Potter @ 2003-05-28 20:43 UTC (permalink / raw)
  To: linux-fsdevel

I've gone through the entire fs/* vfs layer picking out every use of
permission to see if it can easily use the dentry instead, and it can
(list below showing that the dentry is readily available in every vfs
case)

The idea for converting it over would be to at first add 2 temporary
functions, entry_permission() and dentry_vfs_permission(), so that one
can proceed incrementally, and then to do a total change over by getting
rid of the old permission() and vfs_permission() and renaming the
temporary functions to the regular.

I'm making an assumption (perhaps dangerous) that the fs permission()
functions directly mirrors vfs_permission() (based only on experience w/
nfs filesystem) and therefore since fs permission() function is only
called from permission() (as vfs_permission() can also be) and therefore
would all be easy to switch over.

anyways, just want to make sure that I'm not missing anything.

thanks,

shaya

-------------------------

exec.c
------

sys_use_lib()
	error = permission(nd.dentry->d_inode, MAY_READ | MAY_EXEC);

open_exec()
	inode = nd.dentry->d_inode;
	int err = permission(inode, MAY_EXEC);

flush_old_exec()
	permission(bprm->file->f_dentry->d_inode,MAY_READ)


prepare_binprm()
	doesn't work off of permission directly - why?


namei.c
-------

vfs_permission()
	change option to take a dentry and get inode from that,
	instead of taking inode directly.

permission()
	same as vfs_permission()

path_walk()
	inode = nd->dentry->d_inode;
	err = permission(inode, MAY_EXEC);

lookup_hash(struct dentry * base)
	inode = base->d_inode;
	err = permission(inode, MAY_EXEC);

static inline int may_delete(struct inode *dir,struct dentry *victim,
int isdir)
	error = permission(dir,MAY_WRITE | MAY_EXEC);
	
	since

	if (!victim->d_inode || victim->d_parent->d_inode != dir)
                return -ENOENT;

	shouldn't be an issue.

static inline int may_create(struct inode *dir, struct dentry *child)
	return permission(dir,MAY_WRITE | MAY_EXEC);

	seems to be the same as above

open_namei()
	inode = dentry->d_inode;
	error = permission(inode,acc_mode);

vfs_rename_dir()
	error = permission(old_dentry->d_inode, MAY_WRITE);

namespace.c
-----------

mount_is_safe()
        if (permission(nd->dentry->d_inode, MAY_WRITE))

open.c
------
do_sys_truncate()
	inode = nd.dentry->d_inode;
	error = permission(inode,MAY_WRITE);

sys_utime()
	inode = nd.dentry->d_inode;
	error = permission(inode,MAY_WRITE)

sys_utimes()
	inode = nd.dentry->d_inode;
	error = permission(inode,MAY_WRITE)

sys_access()
	res = permission(nd.dentry->d_inode, mode);

sys_chdir()
	error = permission(nd.dentry->d_inode,MAY_EXEC);

sys_fchdir()
	inode = dentry->d_inode;
	error = permission(inode, MAY_EXEC);

sys_chroot()
	error = permission(nd.dentry->d_inode,MAY_EXEC);	



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2003-05-29 21:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-29  0:55 changing permission()/vfs_permission... to work on dentry viro
2003-05-29  4:20 ` Shaya Potter
2003-05-29  4:38   ` Chris Wright
2003-05-29  8:27     ` viro
2003-05-29  8:21   ` [long] per-mountpoint readonly viro
2003-05-29  9:02     ` Trond Myklebust
2003-05-29  9:31       ` viro
2003-05-29  9:42     ` Christoph Hellwig
2003-05-29 16:24     ` Bryan Henderson
2003-05-29 19:22       ` viro
2003-05-29 21:30         ` Bryan Henderson
  -- strict thread matches above, loose matches on Subject: below --
2003-05-28 20:43 changing permission()/vfs_permission... to work on dentry Shaya Potter
2003-05-28 21:48 ` viro
2003-05-28 22:34   ` Shaya Potter
2003-05-28 22:53     ` viro
2003-05-29  0:33       ` Shaya Potter
2003-05-29 12:25         ` Jan Hudec
2003-05-29 12:41           ` viro
2003-05-29 12:40         ` Lucas Correia Villa Real

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox