FAILED: patch "[PATCH] ovl: check whiteout in ovl_create_over_whiteout()" failed to apply to 4.4-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
5e1275808630ea3b2c97c776f40e475017535f72Mon Sep 17 00:00:00 2001
From: Miklos Szeredi <[email protected]>
Date: Wed, 31 Oct 2018 12:15:23 +0100
Subject: [PATCH] ovl: check whiteout in ovl_create_over_whiteout()
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]>
fs/overlayfs/dir.c +4 -0
@@ -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))