Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932453AbZJUT0A (ORCPT ); Wed, 21 Oct 2009 15:26:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932253AbZJUTVG (ORCPT ); Wed, 21 Oct 2009 15:21:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3787 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932215AbZJUTVE (ORCPT ); Wed, 21 Oct 2009 15:21:04 -0400 From: Valerie Aurora To: Jan Blunck , Alexander Viro , Christoph Hellwig , Andy Whitcroft , Scott James Remnant , Sandu Popa Marius , Jan Rekorajski , "J. R. Okajima" , Arnd Bergmann , Vladimir Dronnikov , Felix Fietkau Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Blunck , Miklos Szeredi Subject: [PATCH 22/41] union-mount: Some checks during namespace changes Date: Wed, 21 Oct 2009 12:19:20 -0700 Message-Id: <1256152779-10054-23-git-send-email-vaurora@redhat.com> In-Reply-To: <1256152779-10054-22-git-send-email-vaurora@redhat.com> References: <1256152779-10054-1-git-send-email-vaurora@redhat.com> <1256152779-10054-2-git-send-email-vaurora@redhat.com> <1256152779-10054-3-git-send-email-vaurora@redhat.com> <1256152779-10054-4-git-send-email-vaurora@redhat.com> <1256152779-10054-5-git-send-email-vaurora@redhat.com> <1256152779-10054-6-git-send-email-vaurora@redhat.com> <1256152779-10054-7-git-send-email-vaurora@redhat.com> <1256152779-10054-8-git-send-email-vaurora@redhat.com> <1256152779-10054-9-git-send-email-vaurora@redhat.com> <1256152779-10054-10-git-send-email-vaurora@redhat.com> <1256152779-10054-11-git-send-email-vaurora@redhat.com> <1256152779-10054-12-git-send-email-vaurora@redhat.com> <1256152779-10054-13-git-send-email-vaurora@redhat.com> <1256152779-10054-14-git-send-email-vaurora@redhat.com> <1256152779-10054-15-git-send-email-vaurora@redhat.com> <1256152779-10054-16-git-send-email-vaurora@redhat.com> <1256152779-10054-17-git-send-email-vaurora@redhat.com> <1256152779-10054-18-git-send-email-vaurora@redhat.com> <1256152779-10054-19-git-send-email-vaurora@redhat.com> <1256152779-10054-20-git-send-email-vaurora@redhat.com> <1256152779-10054-21-git-send-email-vaurora@redhat.com> <1256152779-10054-22-git-send-email-vaurora@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2728 Lines: 99 From: Jan Blunck Add some additional checks when mounting something into an union. Signed-off-by: Jan Blunck Signed-off-by: Miklos Szeredi Signed-off-by: Valerie Aurora --- fs/namespace.c | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 81b3188..dc01385 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include "pnode.h" @@ -1427,6 +1428,10 @@ static int do_change_type(struct path *path, int flag) 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); @@ -1478,6 +1483,18 @@ static int do_loopback(struct path *path, char *old_name, int recurse, if (!mnt) goto out; + /* + * Unions couldn't be writable if the filesystem doesn't know about + * whiteouts + */ + err = -ENOTSUPP; + if ((mnt_flags & MNT_UNION) && + !(mnt->mnt_sb->s_flags & (MS_WHITEOUT|MS_RDONLY))) + goto out; + + if (mnt_flags & MNT_UNION) + mnt->mnt_flags |= MNT_UNION; + err = graft_tree(mnt, path); if (err) { LIST_HEAD(umount_list); @@ -1571,6 +1588,13 @@ static int do_move_mount(struct path *path, char *old_name) 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)) @@ -1628,6 +1652,7 @@ out: up_write(&namespace_sem); if (!err) path_put(&parent_path); +exit: path_put(&old_path); return err; } @@ -1685,6 +1710,15 @@ int do_add_mount(struct vfsmount *newmnt, struct path *path, if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) goto unlock; + /* + * Unions couldn't be writable if the filesystem doesn't know about + * whiteouts + */ + err = -ENOTSUPP; + if ((mnt_flags & MNT_UNION) && + !(newmnt->mnt_sb->s_flags & (MS_WHITEOUT|MS_RDONLY))) + goto unlock; + newmnt->mnt_flags = mnt_flags; if ((err = graft_tree(newmnt, path))) goto unlock; -- 1.6.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/