aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-09-14 16:15:29 +0200
committerTakashi Iwai <tiwai@suse.de>2010-09-14 16:15:29 +0200
commitf3fbba6efbab93b9850821d41a75b02286d18315 (patch)
treee2a680674d334c6e455d1a89a4dbfc3f549cb6d1 /fs/namespace.c
parentALSA: snd-usb-caiaq: Add support for Traktor Kontrol S4 (diff)
parentsound: Remove pr_<level> uses of KERN_<level> (diff)
downloadlinux-dev-f3fbba6efbab93b9850821d41a75b02286d18315.tar.xz
linux-dev-f3fbba6efbab93b9850821d41a75b02286d18315.zip
Merge branch 'fix/misc' into topic/misc
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index de402eb6eafb..a72eaabfe8f2 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1484,13 +1484,30 @@ out_unlock:
}
/*
+ * Sanity check the flags to change_mnt_propagation.
+ */
+
+static int flags_to_propagation_type(int flags)
+{
+ int type = flags & ~MS_REC;
+
+ /* Fail if any non-propagation flags are set */
+ if (type & ~(MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
+ return 0;
+ /* Only one propagation flag should be set */
+ if (!is_power_of_2(type))
+ return 0;
+ return type;
+}
+
+/*
* recursively change the type of the mountpoint.
*/
static int do_change_type(struct path *path, int flag)
{
struct vfsmount *m, *mnt = path->mnt;
int recurse = flag & MS_REC;
- int type = flag & ~MS_REC;
+ int type;
int err = 0;
if (!capable(CAP_SYS_ADMIN))
@@ -1499,6 +1516,10 @@ static int do_change_type(struct path *path, int flag)
if (path->dentry != path->mnt->mnt_root)
return -EINVAL;
+ type = flags_to_propagation_type(flag);
+ if (!type)
+ return -EINVAL;
+
down_write(&namespace_sem);
if (type == MS_SHARED) {
err = invent_group_ids(mnt, recurse);