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 02/11] unprivileged mounts: allow unprivileged umount
Date: Mon, 17 Mar 2008 21:00:55 +0100 [thread overview]
Message-ID: <20080317200146.080681921@szeredi.hu> (raw)
In-Reply-To: 20080317200053.447640802@szeredi.hu
[-- Attachment #1: unprivileged-mounts-allow-unprivileged-umount.patch --]
[-- Type: text/plain, Size: 1619 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
The owner doesn't need sysadmin capabilities to call umount().
Similar behavior as umount(8) on mounts having "user=UID" option in /etc/mtab.
The difference is that umount also checks /etc/fstab, presumably to exclude
another mount on the same mountpoint.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Acked-by: Serge Hallyn <serue@us.ibm.com>
---
fs/namespace.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
Index: linux/fs/namespace.c
===================================================================
--- linux.orig/fs/namespace.c 2008-03-17 20:55:42.000000000 +0100
+++ linux/fs/namespace.c 2008-03-17 20:55:44.000000000 +0100
@@ -1074,6 +1074,27 @@ static int do_umount(struct vfsmount *mn
return retval;
}
+static bool is_mount_owner(struct vfsmount *mnt, uid_t uid)
+{
+ return (mnt->mnt_flags & MNT_USER) && mnt->mnt_uid == uid;
+}
+
+/*
+ * umount is permitted for
+ * - sysadmin
+ * - mount owner, if not forced umount
+ */
+static bool permit_umount(struct vfsmount *mnt, int flags)
+{
+ if (capable(CAP_SYS_ADMIN))
+ return true;
+
+ if (flags & MNT_FORCE)
+ return false;
+
+ return is_mount_owner(mnt, current->fsuid);
+}
+
/*
* Now umount can handle mount points as well as block devices.
* This is important for filesystems which use unnamed block devices.
@@ -1097,7 +1118,7 @@ asmlinkage long sys_umount(char __user *
goto dput_and_out;
retval = -EPERM;
- if (!capable(CAP_SYS_ADMIN))
+ if (!permit_umount(nd.path.mnt, flags))
goto dput_and_out;
retval = do_umount(nd.path.mnt, flags);
--
next prev parent reply other threads:[~2008-03-17 20:06 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 ` Miklos Szeredi [this message]
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 ` [patch 10/11] unprivileged mounts: add "no submounts" flag Miklos Szeredi
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=20080317200146.080681921@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