From: Miklos Szeredi <miklos@szeredi.hu>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: jblunck@suse.de, bharata@in.ibm.com, vaurora@redhat.com,
viro@zeniv.linux.org.uk
Subject: [patch 3/5] union-directory: Some checks during namespace changes
Date: Thu, 21 May 2009 11:22:34 +0200 [thread overview]
Message-ID: <20090521092249.788100020@szeredi.hu> (raw)
In-Reply-To: 20090521092231.979256687@szeredi.hu
[-- Attachment #1: union-directory-mount.diff --]
[-- Type: text/plain, Size: 2515 bytes --]
From: Jan Blunck <jblunck@suse.de>
Add some additional checks when mounting something into an union.
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/namespace.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
Index: linux-2.6/fs/namespace.c
===================================================================
--- linux-2.6.orig/fs/namespace.c 2009-05-20 15:07:46.000000000 +0200
+++ linux-2.6/fs/namespace.c 2009-05-20 15:10:05.000000000 +0200
@@ -32,6 +32,7 @@
#include <asm/unistd.h>
#include "pnode.h"
#include "internal.h"
+#include "union.h"
#define HASH_SHIFT ilog2(PAGE_SIZE / sizeof(struct list_head))
#define HASH_SIZE (1UL << HASH_SHIFT)
@@ -1456,6 +1457,10 @@ static int do_change_type(struct path *p
if (path->dentry != path->mnt->mnt_root)
return -EINVAL;
+ /* Don't change the type of union mounts */
+ if (IS_MNT_UNION(path->mnt))
+ return -EINVAL;
+
down_write(&namespace_sem);
if (type == MS_SHARED) {
err = invent_group_ids(mnt, recurse);
@@ -1477,7 +1482,7 @@ static int do_change_type(struct path *p
* do loopback mount.
*/
static int do_loopback(struct path *path, char *old_name,
- int recurse)
+ int recurse, int mnt_flags)
{
struct path old_path;
struct vfsmount *mnt = NULL;
@@ -1507,6 +1512,9 @@ static int do_loopback(struct path *path
if (!mnt)
goto out;
+ if (mnt_flags & MNT_UNION)
+ mnt->mnt_flags |= MNT_UNION;
+
err = graft_tree(mnt, path);
if (err) {
LIST_HEAD(umount_list);
@@ -1600,6 +1608,13 @@ static int do_move_mount(struct path *pa
if (err)
return err;
+ /* moving to or from a union mount is not supported */
+ err = -EINVAL;
+ if (IS_MNT_UNION(path->mnt))
+ goto exit;
+ if (IS_MNT_UNION(old_path.mnt))
+ goto exit;
+
down_write(&namespace_sem);
while (d_mountpoint(path->dentry) &&
follow_down(&path->mnt, &path->dentry))
@@ -1657,6 +1672,7 @@ out:
up_write(&namespace_sem);
if (!err)
path_put(&parent_path);
+exit:
path_put(&old_path);
return err;
}
@@ -1974,7 +1990,7 @@ long do_mount(char *dev_name, char *dir_
retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
data_page);
else if (flags & MS_BIND)
- retval = do_loopback(&path, dev_name, flags & MS_REC);
+ retval = do_loopback(&path, dev_name, flags & MS_REC, mnt_flags);
else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
retval = do_change_type(&path, flags);
else if (flags & MS_MOVE)
--
next prev parent reply other threads:[~2009-05-21 9:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-21 9:22 [patch 0/5] union-directory implementation Miklos Szeredi
2009-05-21 9:22 ` [patch 1/5] union-directory: Introduce MNT_UNION and MS_UNION flags Miklos Szeredi
2009-05-21 9:22 ` [patch 2/5] union-directory: Support for traversing the layers of a union-directory Miklos Szeredi
2009-05-21 9:22 ` Miklos Szeredi [this message]
2009-05-21 9:22 ` [patch 4/5] union-directory: Make lookup continue in overlayed directories Miklos Szeredi
2009-05-21 9:22 ` [patch 5/5] union-directory: Simple union-mount readdir implementation Miklos Szeredi
2009-05-21 9:56 ` [patch 0/5] union-directory implementation 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=20090521092249.788100020@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=bharata@in.ibm.com \
--cc=jblunck@suse.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vaurora@redhat.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;
as well as URLs for NNTP newsgroup(s).