[lkml]   [2018]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.18 037/171] ovl: check whiteout in ovl_create_over_whiteout()
4.18-stable review patch.  If anyone has any objections, please let me know.


From: Miklos Szeredi <>

commit 5e1275808630ea3b2c97c776f40e475017535f72 upstream.

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

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

Reported by: kaixuxia <>
Signed-off-by: Miklos Szeredi <>
Fixes: e9be9d5e76e3 ("overlay filesystem")
Cc: <> # v3.18
Signed-off-by: Greg Kroah-Hartman <>

fs/overlayfs/dir.c | 4 ++++
1 file changed, 4 insertions(+)

--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -461,6 +461,10 @@ static int ovl_create_over_whiteout(stru
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))

 \ /
  Last update: 2018-11-19 18:53    [W:0.479 / U:1.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site