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 02/10] allow unprivileged umount
Date: Mon, 16 Apr 2007 13:03:10 +0200 [thread overview]
Message-ID: <20070416110403.068601478@szeredi.hu> (raw)
In-Reply-To: 20070416110308.739051445@szeredi.hu
[-- Attachment #1: unprivileged_umount.patch --]
[-- Type: text/plain, Size: 1373 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>
---
Index: linux/fs/namespace.c
===================================================================
--- linux.orig/fs/namespace.c 2007-04-11 20:07:51.000000000 +0200
+++ linux/fs/namespace.c 2007-04-11 20:08:05.000000000 +0200
@@ -659,6 +659,25 @@ static int do_umount(struct vfsmount *mn
}
/*
+ * 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 (!(mnt->mnt_flags & MNT_USER))
+ return false;
+
+ if (flags & MNT_FORCE)
+ return false;
+
+ return mnt->mnt_uid == current->uid;
+}
+
+/*
* Now umount can handle mount points as well as block devices.
* This is important for filesystems which use unnamed block devices.
*
@@ -681,7 +700,7 @@ asmlinkage long sys_umount(char __user *
goto dput_and_out;
retval = -EPERM;
- if (!capable(CAP_SYS_ADMIN))
+ if (!permit_umount(nd.mnt, flags))
goto dput_and_out;
retval = do_umount(nd.mnt, flags);
--
next prev parent reply other threads:[~2007-04-16 11:06 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 ` Miklos Szeredi [this message]
2007-04-16 19:39 ` [patch 02/10] allow unprivileged umount 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 ` [patch 10/10] allow unprivileged fuse mounts Miklos Szeredi
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 02/10] allow unprivileged umount 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=20070416110403.068601478@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