From: Miklos Szeredi <miklos@szeredi.hu>
To: akpm@linux-foundation.org, serue@us.ibm.com,
viro@ftp.linux.org.uk, linuxram@us.ibm.com,
ebiederm@xmission.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
containers@lists.osdl.org
Subject: [patch 10/10] allow unprivileged fuse mounts
Date: Mon, 16 Apr 2007 13:03:18 +0200 [thread overview]
Message-ID: <20070416110444.880888315@szeredi.hu> (raw)
In-Reply-To: 20070416110308.739051445@szeredi.hu
[-- Attachment #1: fuse_safe.patch --]
[-- Type: text/plain, Size: 2509 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Use FS_SAFE for "fuse" fs type, but not for "fuseblk".
FUSE was designed from the beginning to be safe for unprivileged
users. This has also been verified in practice over many years. In
addition unprivileged fuse mounts require the "usermnt" mount option
to be set on the parent mount, which is more strict than the current
userspace policy.
This will enable future installations to remove the suid-root
fusermount utility.
Don't require the "user_id=" and "group_id=" options for unprivileged
mounts, but if they are present, verify them for sanity.
Disallow the "allow_other" option for unprivileged mounts.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
Index: linux/fs/fuse/inode.c
===================================================================
--- linux.orig/fs/fuse/inode.c 2007-04-13 14:20:23.000000000 +0200
+++ linux/fs/fuse/inode.c 2007-04-13 14:20:27.000000000 +0200
@@ -311,6 +311,19 @@ static int parse_fuse_opt(char *opt, str
d->max_read = ~0;
d->blksize = 512;
+ /*
+ * For unprivileged mounts use current uid/gid. Still allow
+ * "user_id" and "group_id" options for compatibility, but
+ * only if they match these values.
+ */
+ if (!capable(CAP_SYS_ADMIN)) {
+ d->user_id = current->uid;
+ d->user_id_present = 1;
+ d->group_id = current->gid;
+ d->group_id_present = 1;
+
+ }
+
while ((p = strsep(&opt, ",")) != NULL) {
int token;
int value;
@@ -339,6 +352,8 @@ static int parse_fuse_opt(char *opt, str
case OPT_USER_ID:
if (match_int(&args[0], &value))
return 0;
+ if (d->user_id_present && d->user_id != value)
+ return 0;
d->user_id = value;
d->user_id_present = 1;
break;
@@ -346,6 +361,8 @@ static int parse_fuse_opt(char *opt, str
case OPT_GROUP_ID:
if (match_int(&args[0], &value))
return 0;
+ if (d->group_id_present && d->group_id != value)
+ return 0;
d->group_id = value;
d->group_id_present = 1;
break;
@@ -536,6 +553,10 @@ static int fuse_fill_super(struct super_
if (!parse_fuse_opt((char *) data, &d, is_bdev))
return -EINVAL;
+ /* This is a privileged option */
+ if ((d.flags & FUSE_ALLOW_OTHER) && !capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
if (is_bdev) {
#ifdef CONFIG_BLOCK
if (!sb_set_blocksize(sb, d.blksize))
@@ -639,6 +660,7 @@ static struct file_system_type fuse_fs_t
.fs_flags = FS_HAS_SUBTYPE,
.get_sb = fuse_get_sb,
.kill_sb = kill_anon_super,
+ .fs_flags = FS_SAFE,
};
#ifdef CONFIG_BLOCK
--
next prev parent reply other threads:[~2007-04-16 11:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-16 11:03 [patch 00/10] mount ownership and unprivileged mount syscall (v3) Miklos Szeredi
2007-04-16 11:03 ` [patch 01/10] add user mounts to the kernel Miklos Szeredi
2007-04-16 11:03 ` [patch 02/10] allow unprivileged umount Miklos Szeredi
2007-04-16 19:39 ` Eric W. Biederman
2007-04-16 19:58 ` Greg KH
2007-04-16 11:03 ` [patch 03/10] account user mounts Miklos Szeredi
2007-04-16 11:03 ` [patch 04/10] allow per-mount flags to be set/cleared individually Miklos Szeredi
2007-04-16 11:03 ` [patch 05/10] Add "permit user submounts" flag to vfsmount Miklos Szeredi
2007-04-16 19:20 ` Serge E. Hallyn
2007-04-17 10:44 ` Miklos Szeredi
2007-04-17 14:33 ` Serge E. Hallyn
2007-04-17 16:08 ` Miklos Szeredi
2007-04-17 16:54 ` Serge E. Hallyn
2007-04-16 11:03 ` [patch 06/10] propagate error values from clone_mnt Miklos Szeredi
2007-04-16 11:03 ` [patch 07/10] allow unprivileged bind mounts Miklos Szeredi
2007-04-16 11:03 ` [patch 08/10] put declaration of put_filesystem() in fs.h Miklos Szeredi
2007-04-16 11:03 ` [patch 09/10] allow unprivileged mounts Miklos Szeredi
2007-04-16 11:03 ` Miklos Szeredi [this message]
2007-04-18 7:08 ` [patch 00/10] mount ownership and unprivileged mount syscall (v3) Jeremy Maitin-Shepard
-- strict thread matches above, loose matches on Subject: below --
2007-04-12 16:45 [patch 00/10] (resend) mount ownership and unprivileged mount syscall Miklos Szeredi
2007-04-12 16:45 ` [patch 10/10] allow unprivileged fuse mounts Miklos Szeredi
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=20070416110444.880888315@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.osdl.org \
--cc=ebiederm@xmission.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxram@us.ibm.com \
--cc=serue@us.ibm.com \
--cc=viro@ftp.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