Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 210154
b: refs/heads/master
c: 7a2e8a8
h: refs/heads/master
v: v3
  • Loading branch information
Valerie Aurora authored and Linus Torvalds committed Sep 7, 2010
1 parent 79f288b commit 9ec2c21
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2bfc96a127bc1cc94d26bfaa40159966064f9c8c
refs/heads/master: 7a2e8a8faab76386d8eaae9ded739ee5615be174
23 changes: 22 additions & 1 deletion trunk/fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1483,14 +1483,31 @@ static int graft_tree(struct vfsmount *mnt, struct path *path)
return err;
}

/*
* 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))
Expand All @@ -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);
Expand Down

0 comments on commit 9ec2c21

Please sign in to comment.