[patch 10/10] unprivileged mounts: add "no submounts" flag

Previous thread: [patch 09/10] unprivileged mounts: propagation: inherit owner from parent by Miklos Szeredi on Friday, April 27, 2007 - 8:04 am. (1 message)

Next thread: [patch 02/10] unprivileged mounts: allow unprivileged umount by Miklos Szeredi on Friday, April 27, 2007 - 8:04 am. (1 message)
To: <akpm@...>, <serue@...>, <viro@...>, <linuxram@...>, <ebiederm@...>, <kzak@...>
Cc: <linux-fsdevel@...>, <linux-kernel@...>, <containers@...>
Date: Friday, April 27, 2007 - 8:04 am

From: Miklos Szeredi <mszeredi@suse.cz>

Add a new mount flag "nomnt", which denies submounts for the owner.
This would be useful, if we want to support traditional /etc/fstab
based user mounts.

In this case mount(8) would still have to be suid-root, to check the
mountpoint against the user/users flag in /etc/fstab, but /etc/mtab
would no longer be mandatory for storing the actual owner of the
mount.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---

Index: linux/fs/namespace.c
===================================================================
--- linux.orig/fs/namespace.c 2007-04-27 12:57:11.000000000 +0200
+++ linux/fs/namespace.c 2007-04-27 12:57:14.000000000 +0200
@@ -449,6 +449,7 @@ static int show_vfsmnt(struct seq_file *
{ MNT_NOATIME, ",noatime" },
{ MNT_NODIRATIME, ",nodiratime" },
{ MNT_RELATIME, ",relatime" },
+ { MNT_NOMNT, ",nomnt" },
{ 0, NULL }
};
struct proc_fs_info *fs_infop;
@@ -806,6 +807,9 @@ static bool permit_mount(struct nameidat
if (S_ISLNK(inode->i_mode))
return false;

+ if (nd->mnt->mnt_flags & MNT_NOMNT)
+ return false;
+
if (!is_mount_owner(nd->mnt, current->fsuid))
return false;

@@ -1575,9 +1579,11 @@ long do_mount(char *dev_name, char *dir_
mnt_flags |= MNT_NODIRATIME;
if (flags & MS_RELATIME)
mnt_flags |= MNT_RELATIME;
+ if (flags & MS_NOMNT)
+ mnt_flags |= MNT_NOMNT;

flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
- MS_NOATIME | MS_NODIRATIME | MS_RELATIME);
+ MS_NOATIME | MS_NODIRATIME | MS_RELATIME | MS_NOMNT);

/* ... and get the mountpoint */
retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
Index: linux/include/linux/fs.h
===================================================================
--- linux.orig/include/linux/fs.h 2007-04-27 12:57:11.000000000 +0200
+++ linux/include/linux/fs.h 2007-04-27 12:57:14.000000000 +0200
@@ -128,6 +128,7 @@ extern int dir_notify_enable;
#define MS_SHARED (1<<20) ...

Previous thread: [patch 09/10] unprivileged mounts: propagation: inherit owner from parent by Miklos Szeredi on Friday, April 27, 2007 - 8:04 am. (1 message)

Next thread: [patch 02/10] unprivileged mounts: allow unprivileged umount by Miklos Szeredi on Friday, April 27, 2007 - 8:04 am. (1 message)