linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] private mounts
@ 2005-05-10 18:28 Nir Tzachar
  2005-05-10 19:15 ` Jan Hudec
  0 siblings, 1 reply; 147+ messages in thread
From: Nir Tzachar @ 2005-05-10 18:28 UTC (permalink / raw)
  To: linux-fsdevel

hello.

please shout if im missing something, but i think there can be a simple 
solution (which involves quite a bit of coding....).
Why not implement FUSE as a user space applications --> not involving any 
kernel code at all.

what i have in mind is replacing the user space daemon (which FUSE 
currently utilizes to speak with the kernel) with a different 
daemon. i suggest using a user space nfs daemon, which can than be mounted 
on the local (or on a remote) machine as a regular nfs exported fs. 

this solution seems to solve the permissions problems and simplifies 
things a bit, since no kernel code is needed (apart from allowing user 
mounts). 
however, implementing this is quit involved, and im sure several hurdles 
must be passed along the way. regardless, i think the benefits can 
outweigh such drawbacks.....




-- 
========================================================================
nir.


^ permalink raw reply	[flat|nested] 147+ messages in thread
* [PATCH] private mounts
@ 2005-04-24 20:08 Miklos Szeredi
  2005-04-24 20:13 ` Al Viro
  2005-04-24 20:18 ` Christoph Hellwig
  0 siblings, 2 replies; 147+ messages in thread
From: Miklos Szeredi @ 2005-04-24 20:08 UTC (permalink / raw)
  To: linux-fsdevel, hch; +Cc: linux-kernel, akpm

This simple patch adds support for private (or invisible) mounts.  The
rationale is to allow mounts to be private for a user but still in the
global namespace.

An immediate user of this would be FUSE, which currently achieves the
hiding of data with inode->permission(), which is less elegant.

Christoph, I'm specially interested in your opinion, since you were so
strongly opposed to the current solution in FUSE.

Performance measurements indicate that the overhead is about 2% of the
time spent following mounts, or 6ns per-mount on a 533 Celeron.

This patch does:

 - add new mount flag: MS_PRIVATE / MNT_PRIVATE
 - add new member in struct vfsmount: mnt_uid
 - if MNT_PRIVATE is set, set mnt_uid to current->fsuid in
   do_add_mount() and do_remount()
 - in clone_mnt() copy mnt_uid to the new mount
 - in lookup_mnt() while looping through the hash chain for the
   mountpoint, check if the mount is "visible" for this process, and
   skip it if not

Comments are appreciated.  If there are no vetoes agains the patch, I
think it's suitable for -mm.

Thanks,
Miklos

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>

diff -rup orig/linux-2.6.11/fs/namespace.c linux-2.6.11/fs/namespace.c
--- orig/linux-2.6.11/fs/namespace.c	2005-03-04 23:18:48.000000000 +0100
+++ linux-2.6.11/fs/namespace.c	2005-04-24 12:44:41.000000000 +0200
@@ -81,6 +81,15 @@ void free_vfsmnt(struct vfsmount *mnt)
 }
 
 /*
+ * Check if this mount should be skipped or not
+ */
+static inline int mnt_visible(struct vfsmount *mnt)
+{
+	return !(mnt->mnt_flags & MNT_PRIVATE) ||
+		mnt->mnt_uid == current->fsuid;
+}
+
+/*
  * Now, lookup_mnt increments the ref count before returning
  * the vfsmount struct.
  */
@@ -97,7 +106,8 @@ struct vfsmount *lookup_mnt(struct vfsmo
 		if (tmp == head)
 			break;
 		p = list_entry(tmp, struct vfsmount, mnt_hash);
-		if (p->mnt_parent == mnt && p->mnt_mountpoint == dentry) {
+		if (p->mnt_parent == mnt && p->mnt_mountpoint == dentry &&
+		    mnt_visible(p)) {
 			found = mntget(p);
 			break;
 		}
@@ -155,6 +165,7 @@ clone_mnt(struct vfsmount *old, struct d
 
 	if (mnt) {
 		mnt->mnt_flags = old->mnt_flags;
+		mnt->mnt_uid = old->mnt_uid;
 		atomic_inc(&sb->s_active);
 		mnt->mnt_sb = sb;
 		mnt->mnt_root = dget(root);
@@ -234,6 +245,7 @@ static int show_vfsmnt(struct seq_file *
 		{ MNT_NOSUID, ",nosuid" },
 		{ MNT_NODEV, ",nodev" },
 		{ MNT_NOEXEC, ",noexec" },
+		{ MNT_PRIVATE, ",private" },
 		{ 0, NULL }
 	};
 	struct proc_fs_info *fs_infop;
@@ -252,6 +264,8 @@ static int show_vfsmnt(struct seq_file *
 		if (mnt->mnt_flags & fs_infop->flag)
 			seq_puts(m, fs_infop->str);
 	}
+	if (mnt->mnt_flags & MNT_PRIVATE)
+		seq_printf(m, ",mnt_uid=%u", mnt->mnt_uid);
 	if (mnt->mnt_sb->s_op->show_options)
 		err = mnt->mnt_sb->s_op->show_options(m, mnt);
 	seq_puts(m, " 0 0\n");
@@ -684,8 +698,11 @@ static int do_remount(struct nameidata *
 
 	down_write(&sb->s_umount);
 	err = do_remount_sb(sb, flags, data, 0);
-	if (!err)
+	if (!err) {
 		nd->mnt->mnt_flags=mnt_flags;
+		if (mnt_flags & MNT_PRIVATE)
+			nd->mnt->mnt_uid = current->fsuid;
+	}
 	up_write(&sb->s_umount);
 	if (!err)
 		security_sb_post_remount(nd->mnt, flags, data);
@@ -807,6 +824,8 @@ int do_add_mount(struct vfsmount *newmnt
 		goto unlock;
 
 	newmnt->mnt_flags = mnt_flags;
+	if (mnt_flags & MNT_PRIVATE)
+		newmnt->mnt_uid = current->fsuid;
 	err = graft_tree(newmnt, nd);
 
 	if (err == 0 && fslist) {
@@ -1033,7 +1052,9 @@ long do_mount(char * dev_name, char * di
 		mnt_flags |= MNT_NODEV;
 	if (flags & MS_NOEXEC)
 		mnt_flags |= MNT_NOEXEC;
-	flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);
+	if (flags & MS_PRIVATE)
+		mnt_flags |= MNT_PRIVATE;
+	flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_PRIVATE|MS_ACTIVE);
 
 	/* ... and get the mountpoint */
 	retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
diff -rup orig/linux-2.6.11/include/linux/fs.h linux-2.6.11/include/linux/fs.h
--- orig/linux-2.6.11/include/linux/fs.h	2005-03-04 23:19:05.000000000 +0100
+++ linux-2.6.11/include/linux/fs.h	2005-04-24 10:23:33.000000000 +0200
@@ -96,6 +96,7 @@ extern int dir_notify_enable;
 #define MS_REMOUNT	32	/* Alter flags of a mounted FS */
 #define MS_MANDLOCK	64	/* Allow mandatory locks on an FS */
 #define MS_DIRSYNC	128	/* Directory modifications are synchronous */
+#define MS_PRIVATE	256	/* Make this mount invisible to other users */
 #define MS_NOATIME	1024	/* Do not update access times. */
 #define MS_NODIRATIME	2048	/* Do not update directory access times */
 #define MS_BIND		4096
diff -rup orig/linux-2.6.11/include/linux/mount.h linux-2.6.11/include/linux/mount.h
--- orig/linux-2.6.11/include/linux/mount.h	2004-12-25 11:52:55.000000000 +0100
+++ linux-2.6.11/include/linux/mount.h	2005-04-24 10:24:29.000000000 +0200
@@ -19,6 +19,7 @@
 #define MNT_NOSUID	1
 #define MNT_NODEV	2
 #define MNT_NOEXEC	4
+#define MNT_PRIVATE	8
 
 struct vfsmount
 {
@@ -31,6 +32,7 @@ struct vfsmount
 	struct list_head mnt_child;	/* and going through their mnt_child */
 	atomic_t mnt_count;
 	int mnt_flags;
+	uid_t mnt_uid;
 	int mnt_expiry_mark;		/* true if marked for expiry */
 	char *mnt_devname;		/* Name of device e.g. /dev/dsk/hda1 */
 	struct list_head mnt_list;

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

end of thread, other threads:[~2005-05-11 10:43 UTC | newest]

Thread overview: 147+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <3WVU1-2GE-7@gated-at.bofh.it>
     [not found] ` <3WWn1-2ZC-5@gated-at.bofh.it>
     [not found]   ` <3WWn1-2ZC-3@gated-at.bofh.it>
     [not found]     ` <3WWwR-3hT-35@gated-at.bofh.it>
     [not found]       ` <3WWwU-3hT-49@gated-at.bofh.it>
     [not found]         ` <3WWGj-3nm-3@gated-at.bofh.it>
     [not found]           ` <3WWQ9-3uA-15@gated-at.bofh.it>
     [not found]             ` <3WWZG-3AC-7@gated-at.bofh.it>
     [not found]               ` <3X630-2qD-21@gated-at.bofh.it>
     [not found]                 ` <3X8HA-4IH-15@gated-at.bofh.it>
     [not found]                   ` <3Xagd-5Wb-1@gated-at.bofh.it>
2005-04-25 15:17                     ` [PATCH] private mounts Bodo Eggert <harvested.in.lkml@posting.7eggert.dyndns.org>
2005-04-25 16:18                       ` Ram
2005-04-25 19:10                         ` Jamie Lokier
2005-04-26  9:16                           ` Miklos Szeredi
2005-04-26  9:19                             ` Christoph Hellwig
2005-04-26  9:22                               ` Miklos Szeredi
2005-04-26  9:36                                 ` Christoph Hellwig
2005-04-26  9:41                                   ` Miklos Szeredi
2005-04-26  9:47                                     ` Christoph Hellwig
2005-04-26  9:53                                       ` Miklos Szeredi
2005-04-26  9:56                                         ` Christoph Hellwig
2005-04-26 10:01                                           ` Miklos Szeredi
2005-04-26 10:09                                             ` Christoph Hellwig
2005-04-26 12:08                                               ` Miklos Szeredi
2005-04-26 10:02                                           ` Christoph Hellwig
2005-04-26 13:19                                       ` Pavel Machek
2005-04-26 13:28                                         ` Miklos Szeredi
2005-04-26 20:14                                           ` Pavel Machek
2005-04-27  8:49                                             ` Miklos Szeredi
2005-04-27  9:24                                               ` Pavel Machek
2005-04-27 10:42                                                 ` Miklos Szeredi
2005-04-27 11:57                                                   ` Jan Hudec
2005-04-27 12:23                                                     ` Miklos Szeredi
2005-04-27 12:39                                                       ` Jan Hudec
2005-04-27 13:22                                                         ` Miklos Szeredi
2005-04-27 14:40                                                           ` Jamie Lokier
2005-04-27 14:58                                                           ` Pavel Machek
2005-04-27 23:21                                                             ` Trond Myklebust
2005-04-28  8:24                                                               ` Pavel Machek
2005-04-28  8:28                                                                 ` Miklos Szeredi
2005-04-28 11:35                                                                 ` Trond Myklebust
2005-04-28 17:58                                                                   ` Bryan Henderson
2005-04-28 19:46                                                                     ` Trond Myklebust
2005-04-28 22:38                                                                       ` Bryan Henderson
2005-04-29  0:35                                                                         ` Trond Myklebust
2005-04-27 14:31                                                   ` Jamie Lokier
2005-04-27 14:46                                                     ` Miklos Szeredi
2005-04-27 14:55                                                       ` Miklos Szeredi
2005-04-27 15:33                                                       ` Martin Mares
2005-04-27 15:50                                                         ` Lars Marowsky-Bree
2005-04-27 16:46                                                           ` Martin Mares
2005-04-27 17:38                                                             ` Miklos Szeredi
2005-04-27 17:54                                                               ` Martin Mares
2005-04-27 18:05                                                                 ` Miklos Szeredi
2005-04-27 18:25                                                                   ` Martin Mares
2005-04-27 18:42                                                                     ` Miklos Szeredi
2005-04-28 13:08                                                                   ` Pavel Machek
2005-04-28 19:41                                                                     ` Miklos Szeredi
2005-04-28 20:21                                                                       ` Pavel Machek
2005-04-27 17:33                                                           ` Miklos Szeredi
2005-04-27 17:39                                                             ` Ram
2005-04-27 17:47                                                               ` Miklos Szeredi
2005-04-27 17:55                                                                 ` Ram
2005-04-27 18:09                                                                   ` Miklos Szeredi
2005-04-27 19:40                                                                     ` Ram
2005-04-27 20:03                                                                       ` Miklos Szeredi
2005-04-27 21:38                                                                         ` Ram
2005-04-28  7:00                                                                           ` Miklos Szeredi
2005-04-28 19:30                                                                             ` Ram
2005-04-27 20:55                                                                       ` Bill Davidsen
2005-04-28  7:24                                                                         ` Miklos Szeredi
     [not found]                                                             ` <20050427174641.GZ4431@marowsky-bree.de>
2005-04-27 17:52                                                               ` Miklos Szeredi
2005-04-26 10:00                                     ` Andrew Morton
2005-04-26 10:04                                       ` Christoph Hellwig
2005-04-26 10:14                                         ` Andrew Morton
2005-04-26 10:38                                           ` Christoph Hellwig
2005-04-26 13:05                                             ` Eric Van Hensbergen
2005-04-26 14:14                                               ` Miklos Szeredi
2005-04-26 15:01                                                 ` Eric Van Hensbergen
2005-04-26 18:55                                         ` Bryan Henderson
2005-04-26  9:30                             ` Martin Mares
2005-04-25 19:02                       ` Bryan Henderson
2005-04-26  8:58                         ` Jan Hudec
2005-04-26 11:48                         ` Bodo Eggert
2005-04-26 17:10                           ` Bryan Henderson
2005-04-26 20:08                             ` Bodo Eggert
2005-04-26 22:07                               ` Bryan Henderson
2005-04-27  8:18                                 ` Bodo Eggert
2005-04-25 19:03                       ` Jamie Lokier
2005-04-26  9:05                       ` Jan Hudec
2005-04-26 11:46                         ` Bodo Eggert
2005-05-10 18:28 Nir Tzachar
2005-05-10 19:15 ` Jan Hudec
  -- strict thread matches above, loose matches on Subject: below --
2005-04-24 20:08 Miklos Szeredi
2005-04-24 20:13 ` Al Viro
2005-04-24 20:45   ` Miklos Szeredi
2005-04-24 20:18 ` Christoph Hellwig
2005-04-24 20:50   ` Miklos Szeredi
2005-04-24 20:54     ` Al Viro
2005-04-24 20:59       ` Miklos Szeredi
2005-04-24 21:06         ` Al Viro
2005-04-24 21:15           ` Miklos Szeredi
2005-04-24 21:19             ` Al Viro
2005-04-24 21:29               ` Miklos Szeredi
2005-04-24 21:39                 ` Jamie Lokier
2005-04-25  7:10                 ` Jan Hudec
2005-04-25  9:58                   ` Miklos Szeredi
2005-04-25 11:45                     ` Jan Hudec
2005-04-30  8:35                     ` Christoph Hellwig
2005-04-30  9:25                       ` Miklos Szeredi
2005-04-30  9:42                         ` Jamie Lokier
2005-04-30 10:14                           ` Miklos Szeredi
2005-04-30 14:36                             ` Jamie Lokier
2005-04-30 15:59                               ` Miklos Szeredi
2005-04-30 16:42                                 ` Jamie Lokier
2005-04-30 17:07                                   ` Miklos Szeredi
2005-04-30 18:20                                     ` Olivier Galibert
2005-04-30 23:58                                       ` Jamie Lokier
2005-05-01  2:39                                         ` Ram
2005-04-30 23:54                                     ` Jamie Lokier
2005-05-01  5:56                                       ` Miklos Szeredi
2005-05-01  6:39                                         ` Miklos Szeredi
2005-05-01 15:41                                         ` Eric Van Hensbergen
2005-05-11  9:00                         ` Christoph Hellwig
2005-05-11 10:42                           ` Miklos Szeredi
2005-04-24 21:43               ` Jamie Lokier
2005-04-25  7:14                 ` Jan Hudec
2005-04-27  9:14                 ` Helge Hafting
2005-04-25  9:48               ` Olivier Galibert
2005-04-25 16:37                 ` Tim Hockin
2005-04-30  8:37                 ` Christoph Hellwig
2005-04-25 21:09               ` Bryan Henderson
2005-04-24 21:38           ` Jamie Lokier
2005-04-24 22:20             ` Ram
2005-04-24 22:22               ` Jamie Lokier
2005-04-25  6:00             ` Miklos Szeredi
2005-04-25  6:41               ` Ram
2005-04-25  9:55                 ` Miklos Szeredi
2005-04-25  7:22               ` Jan Hudec
2005-04-25 10:08                 ` Miklos Szeredi
2005-04-25 15:20             ` Pavel Machek
2005-04-25 19:07               ` Jamie Lokier
2005-04-26  9:29                 ` Pavel Machek
2005-04-26 14:07                   ` Jamie Lokier
2005-04-28 13:28                     ` Eric Van Hensbergen
2005-04-28 19:22                       ` Jamie Lokier
2005-04-28 13:47                     ` Eric Van Hensbergen
2005-04-28 19:20                       ` Jamie Lokier
2005-04-28 19:39                         ` Ram
2005-04-28 22:08                           ` Jamie Lokier
2005-04-29  7:57                             ` Ram
2005-04-29 14:13                               ` Miklos Szeredi
2005-04-29 14:42                                 ` Jamie Lokier
2005-04-30  8:33                 ` Christoph Hellwig
2005-04-30 16:47                   ` Ram
2005-04-24 21:06         ` Christoph Hellwig
2005-04-24 21:12           ` Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).