lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 30 Nov 2009 04:04:50 -0500
From:	Erez Zadok <ezk@...sunysb.edu>
To:	Valerie Aurora <vaurora@...hat.com>
Cc:	Jan Blunck <jblunck@...e.de>,
	Alexander Viro <viro@...iv.linux.org.uk>,
	Christoph Hellwig <hch@...radead.org>,
	Andy Whitcroft <apw@...onical.com>,
	Scott James Remnant <scott@...onical.com>,
	Sandu Popa Marius <sandupopamarius@...il.com>,
	Jan Rekorajski <baggins@...h.mimuw.edu.pl>,
	"J. R. Okajima" <hooanon05@...oo.co.jp>,
	Arnd Bergmann <arnd@...db.de>,
	Vladimir Dronnikov <dronnikov@...il.com>,
	Felix Fietkau <nbd@...nwrt.org>, linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org, Miklos Szeredi <mszeredi@...e.cz>
Subject: Re: [PATCH 22/41] union-mount: Some checks during namespace changes 

In message <1256152779-10054-23-git-send-email-vaurora@...hat.com>, Valerie Aurora writes:
> From: Jan Blunck <jblunck@...e.de>
> 
> Add some additional checks when mounting something into an union.

The text "add some additional checks" seems to imply "code I forgot to add
earlier".  If this patch is better merged with some other one, then do so;
otherwise, the subject line and patch header need to give this patch more
credit than this: better explain what the checks are more precisely.

> Signed-off-by: Jan Blunck <jblunck@...e.de>
> Signed-off-by: Miklos Szeredi <mszeredi@...e.cz>
> Signed-off-by: Valerie Aurora <vaurora@...hat.com>
> ---
>  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 <linux/log2.h>
>  #include <linux/idr.h>
>  #include <linux/fs_struct.h>
> +#include <linux/union.h>
>  #include <asm/uaccess.h>
>  #include <asm/unistd.h>
>  #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;
>  }

I'd avoid using 'exit' as a label and goto name; use "out_err" or some other
out_XXX label.  'exit' is almost a reserved word in C. :-)

> @@ -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-fsdevel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Erez.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ