]> Git Repo - J-linux.git/commitdiff
ovl: check whiteout in ovl_create_over_whiteout()
authorMiklos Szeredi <[email protected]>
Wed, 31 Oct 2018 11:15:23 +0000 (12:15 +0100)
committerMiklos Szeredi <[email protected]>
Wed, 31 Oct 2018 11:15:23 +0000 (12:15 +0100)
Kaixuxia repors that it's possible to crash overlayfs by removing the
whiteout on the upper layer before creating a directory over it.  This is a
reproducer:

 mkdir lower upper work merge
 touch lower/file
 mount -t overlay overlay -olowerdir=lower,upperdir=upper,workdir=work merge
 rm merge/file
 ls -al merge/file
 rm upper/file
 ls -al merge/
 mkdir merge/file

Before commencing with a vfs_rename(..., RENAME_EXCHANGE) verify that the
lookup of "upper" is positive and is a whiteout, and return ESTALE
otherwise.

Reported by: kaixuxia <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
Fixes: e9be9d5e76e3 ("overlay filesystem")
Cc: <[email protected]> # v3.18
fs/overlayfs/dir.c

index ce1857fb54348ef83b810b3f9fa143cbb923cfd3..c6289147c7871f165b70f5ca8e13668f3010d4b0 100644 (file)
@@ -462,6 +462,10 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
        if (IS_ERR(upper))
                goto out_unlock;
 
+       err = -ESTALE;
+       if (d_is_negative(upper) || !IS_WHITEOUT(d_inode(upper)))
+               goto out_dput;
+
        newdentry = ovl_create_temp(workdir, cattr);
        err = PTR_ERR(newdentry);
        if (IS_ERR(newdentry))
This page took 0.055463 seconds and 4 git commands to generate.