Skip to content

Commit

Permalink
ovl: Fix opaque regression in ovl_lookup
Browse files Browse the repository at this point in the history
Current multi-layer support overlayfs has a regression in
.lookup(). If there is a directory in upperdir and a regular
file has same name in lowerdir in a merged directory, lower
file is hidden and upper directory is set to opaque in former
case. But it is changed in present code.

In lowerdir lookup path, if a found inode is not directory,
the type checking of previous inode is missing. This inode
will be copied to the lowerstack of ovl_entry directly.

That will lead to several wrong conditions, for example,
the reading of the directory in upperdir may return an error
like:

   ls: reading directory .: Not a directory

This patch makes the lowerdir lookup path check the opaque
for non-directory file too.

Signed-off-by: hujianyang <hujianyang@huawei.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
hujianyang authored and Miklos Szeredi committed Jan 8, 2015
1 parent 2f83fd8 commit a425c03
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
bool opaque = false;
struct path lowerpath = poe->lowerstack[i];

opaque = false;
this = ovl_lookup_real(lowerpath.dentry, &dentry->d_name);
err = PTR_ERR(this);
if (IS_ERR(this)) {
Expand All @@ -395,20 +394,24 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
*/
if (i < poe->numlower - 1 && ovl_is_opaquedir(this))
opaque = true;
/*
* If this is a non-directory then stop here.
*
* FIXME: check for opaqueness maybe better done in remove code.
*/
if (!S_ISDIR(this->d_inode->i_mode)) {
opaque = true;
} else if (prev && (!S_ISDIR(prev->d_inode->i_mode) ||
!S_ISDIR(this->d_inode->i_mode))) {

if (prev && (!S_ISDIR(prev->d_inode->i_mode) ||
!S_ISDIR(this->d_inode->i_mode))) {
/*
* FIXME: check for upper-opaqueness maybe better done
* in remove code.
*/
if (prev == upperdentry)
upperopaque = true;
dput(this);
break;
}
/*
* If this is a non-directory then stop here.
*/
if (!S_ISDIR(this->d_inode->i_mode))
opaque = true;

stack[ctr].dentry = this;
stack[ctr].mnt = lowerpath.mnt;
ctr++;
Expand Down

0 comments on commit a425c03

Please sign in to comment.