Re: [PATCH 12/13] ovl: switch to __inode_permission()

Casey Schaufler
2012-08-15T16:59:56Z

On 8/15/2012 8:48 AM, Miklos Szeredi wrote:
> From: Andy Whitcroft <apw@canonical.com>
>
> When checking permissions on an overlayfs inode we do not take into
> account either device cgroup restrictions nor security permissions.
> This allows a user to mount an overlayfs layer over a restricted device
> directory and by pass those permissions to open otherwise restricted
> files.

Why is this a good idea? Either you're not including enough context
about the conditions under which this can occur, or you're suggesting
the introduction of a trivial mechanism for bypassing all file access
controls. This does not seem right.

>
> Switch over to __inode_permissions.
>
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
> ---
> fs/overlayfs/inode.c | 12 +-----------
> 1 files changed, 1 insertions(+), 11 deletions(-)
>
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index e854720..f3a534f 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -100,19 +100,9 @@ int ovl_permission(struct inode *inode, int mask)
> if (is_upper && !IS_RDONLY(inode) && IS_RDONLY(realinode) &&
> (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
> goto out_dput;
> -
> - /*
> - * Nobody gets write access to an immutable file.
> - */
> - err = -EACCES;
> - if (IS_IMMUTABLE(realinode))
> - goto out_dput;
> }
>
> - if (realinode->i_op->permission)
> - err = realinode->i_op->permission(realinode, mask);
> - else
> - err = generic_permission(realinode, mask);
> + err = __inode_permission(realinode, mask);
> out_dput:
> dput(alias);
> return err;