From: Miklos Szeredi <miklos@szeredi.hu>
To: akpm@linux-foundation.org, hch@infradead.org, serue@us.ibm.com,
viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [patch 10/11] unprivileged mounts: add "no submounts" flag
Date: Mon, 17 Mar 2008 21:01:03 +0100 [thread overview]
Message-ID: <20080317200157.872688735@szeredi.hu> (raw)
In-Reply-To: 20080317200053.447640802@szeredi.hu
[-- Attachment #1: unprivileged-mounts-add-no-submounts-flag.patch --]
[-- Type: text/plain, Size: 3089 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Add a new mount flag "nosubmnt", 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>
Acked-by: Serge Hallyn <serue@us.ibm.com>
---
fs/namespace.c | 10 ++++++++--
include/linux/fs.h | 1 +
include/linux/mount.h | 1 +
3 files changed, 10 insertions(+), 2 deletions(-)
Index: linux/fs/namespace.c
===================================================================
--- linux.orig/fs/namespace.c 2008-03-17 20:55:52.000000000 +0100
+++ linux/fs/namespace.c 2008-03-17 20:55:53.000000000 +0100
@@ -810,6 +810,7 @@ static void show_mnt_opts(struct seq_fil
{ MNT_NOATIME, ",noatime" },
{ MNT_NODIRATIME, ",nodiratime" },
{ MNT_RELATIME, ",relatime" },
+ { MNT_NOSUBMNT, ",nosubmnt" },
{ 0, NULL }
};
const struct proc_fs_info *fs_infop;
@@ -1230,6 +1231,9 @@ static bool permit_mount(struct nameidat
if (S_ISLNK(inode->i_mode))
return false;
+ if (nd->path.mnt->mnt_flags & MNT_NOSUBMNT)
+ return false;
+
if (!is_mount_owner(nd->path.mnt, current->fsuid))
return false;
@@ -2082,9 +2086,11 @@ long do_mount(char *dev_name, char *dir_
mnt_flags |= MNT_RELATIME;
if (flags & MS_RDONLY)
mnt_flags |= MNT_READONLY;
+ if (flags & MS_NOSUBMNT)
+ mnt_flags |= MNT_NOSUBMNT;
- flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE |
- MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT);
+ flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_NOATIME |
+ MS_NODIRATIME | MS_RELATIME | MS_KERNMOUNT | MS_NOSUBMNT);
/* ... and get the mountpoint */
retval = path_lookup(dir_name, LOOKUP_FOLLOW, &nd);
Index: linux/include/linux/fs.h
===================================================================
--- linux.orig/include/linux/fs.h 2008-03-17 20:55:52.000000000 +0100
+++ linux/include/linux/fs.h 2008-03-17 20:55:53.000000000 +0100
@@ -129,6 +129,7 @@ extern int dir_notify_enable;
#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
#define MS_I_VERSION (1<<23) /* Update inode I_version field */
#define MS_SETUSER (1<<24) /* set mnt_uid to current user */
+#define MS_NOSUBMNT (1<<25) /* don't allow unprivileged submounts */
#define MS_ACTIVE (1<<30)
#define MS_NOUSER (1<<31)
Index: linux/include/linux/mount.h
===================================================================
--- linux.orig/include/linux/mount.h 2008-03-17 20:55:42.000000000 +0100
+++ linux/include/linux/mount.h 2008-03-17 20:55:53.000000000 +0100
@@ -30,6 +30,7 @@ struct mnt_namespace;
#define MNT_NODIRATIME 0x10
#define MNT_RELATIME 0x20
#define MNT_READONLY 0x40 /* does the user want this to be r/o? */
+#define MNT_NOSUBMNT 0x80
#define MNT_SHRINKABLE 0x100
#define MNT_IMBALANCED_WRITE_COUNT 0x200 /* just for debugging */
--
next prev parent reply other threads:[~2008-03-17 20:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-17 20:00 [patch 00/11] mount ownership and unprivileged mount syscall (v9) Miklos Szeredi
2008-03-17 20:00 ` [patch 01/11] unprivileged mounts: add user mounts to the kernel Miklos Szeredi
2008-03-17 20:00 ` [patch 02/11] unprivileged mounts: allow unprivileged umount Miklos Szeredi
2008-03-17 20:00 ` [patch 03/11] unprivileged mounts: propagate error values from clone_mnt Miklos Szeredi
2008-03-17 20:00 ` [patch 04/11] unprivileged mounts: account user mounts Miklos Szeredi
2008-03-17 20:00 ` [patch 05/11] unprivileged mounts: allow unprivileged bind mounts Miklos Szeredi
2008-03-17 20:00 ` [patch 06/11] unprivileged mounts: allow unprivileged mounts Miklos Szeredi
2008-03-17 20:01 ` [patch 07/11] unprivileged mounts: add sysctl tunable for "safe" property Miklos Szeredi
2008-03-17 20:01 ` [patch 08/11] unprivileged mounts: make fuse safe Miklos Szeredi
2008-03-17 20:01 ` [patch 09/11] unprivileged mounts: propagation: inherit owner from parent Miklos Szeredi
2008-03-17 20:01 ` Miklos Szeredi [this message]
2008-03-17 20:01 ` [patch 11/11] unprivileged mounts: copy mount ownership on namespace cloning Miklos Szeredi
2008-03-17 22:51 ` [patch 00/11] mount ownership and unprivileged mount syscall (v9) James Morris
2008-03-18 11:33 ` Miklos Szeredi
2008-03-18 23:04 ` James Morris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080317200157.872688735@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=serue@us.ibm.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox