Skip to content

Commit

Permalink
ovl: fix BUG_ON() in may_delete() when called from ovl_cleanup()
Browse files Browse the repository at this point in the history
If function ovl_instantiate() returns an error, ovl_cleanup will be called
and try to remove newdentry from wdir, but the newdentry has been moved to
udir at this time.  This will causes BUG_ON(victim->d_parent->d_inode !=
dir) in fs/namei.c:may_delete.

Signed-off-by: chenying <[email protected]>
Fixes: 01b39dc ("ovl: use inode_insert5() to hash a newly created inode")
Link: https://lore.kernel.org/linux-unionfs/[email protected]/
Cc: <[email protected]> # v4.18
Signed-off-by: Miklos Szeredi <[email protected]>
  • Loading branch information
chenyingk authored and Miklos Szeredi committed Aug 17, 2021
1 parent f945ca1 commit 52d5a0c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/overlayfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,10 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
goto out_cleanup;
}
err = ovl_instantiate(dentry, inode, newdentry, hardlink);
if (err)
goto out_cleanup;
if (err) {
ovl_cleanup(udir, newdentry);
dput(newdentry);
}
out_dput:
dput(upper);
out_unlock:
Expand Down

0 comments on commit 52d5a0c

Please sign in to comment.