Skip to content

Commit

Permalink
ovl: modify ovl_permission() to do checks on two inodes
Browse files Browse the repository at this point in the history
Right now ovl_permission() calls __inode_permission(realinode), to do
permission checks on real inode and no checks are done on overlay inode.

Modify it to do checks both on overlay inode as well as underlying inode.
Checks on overlay inode will be done with the creds of calling task while
checks on underlying inode will be done with the creds of mounter.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Vivek Goyal authored and Miklos Szeredi committed Jul 29, 2016
1 parent 39a25b2 commit c0ca3d7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions fs/overlayfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ int ovl_permission(struct inode *inode, int mask)
bool is_upper;
struct dentry *realdentry = ovl_entry_real(oe, &is_upper);
struct inode *realinode;
const struct cred *old_cred;
int err;

if (ovl_is_default_permissions(inode)) {
Expand Down Expand Up @@ -166,7 +167,19 @@ int ovl_permission(struct inode *inode, int mask)
return -EROFS;
}

return __inode_permission(realinode, mask);
/*
* Check overlay inode with the creds of task and underlying inode
* with creds of mounter
*/
err = generic_permission(inode, mask);
if (err)
return err;

old_cred = ovl_override_creds(inode->i_sb);
err = __inode_permission(realinode, mask);
revert_creds(old_cred);

return err;
}

static const char *ovl_get_link(struct dentry *dentry,
Expand Down Expand Up @@ -314,9 +327,6 @@ struct posix_acl *ovl_get_acl(struct inode *inode, int type)
{
struct inode *realinode = ovl_inode_real(inode);

if (!realinode)
return ERR_PTR(-ENOENT);

if (!IS_POSIXACL(realinode))
return NULL;

Expand Down

0 comments on commit c0ca3d7

Please sign in to comment.