[PATCH 02/11] ovl: verify whiteout index entries on mount

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Whiteout index entries are used as an indication that
an exported overlay file handle should be treated as stale
(i.e. after unlink/rmdir of the overlay inode).
These entries contain no xattr.

Currently we only verify that whiteout index have a sane name,
but we do not try to decode the index name as file handle to
verify it is not stale.

This allows mounting overlayfs that has whiteout index entries
generated by newer kernel.

Fixes: 61b674710cd9 ("ovl: do not cleanup directory and whiteout index")
Cc: <stable@xxxxxxxxxxxxxxx> # v4.13
Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
---
 fs/overlayfs/namei.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 6a8e0156d40d..c73f490695c6 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -412,16 +412,13 @@ int ovl_verify_index(struct dentry *index, struct path *lowerstack,
 	/*
 	 * Directory index entries are going to be used for looking up
 	 * redirected upper dirs by lower dir fh when decoding an overlay
-	 * file handle of a merge dir. Whiteout index entries are going to be
-	 * used as an indication that an exported overlay file handle should
-	 * be treated as stale (i.e. after unlink of the overlay inode).
-	 * We don't know the verification rules for directory and whiteout
-	 * index entries, because they have not been implemented yet, so return
-	 * EROFS if those entries are found to avoid corrupting an index that
-	 * was created by a newer kernel.
+	 * file handle of a merge dir.  We don't know the verification rules
+	 * for directory index entries, because they have not been implemented
+	 * yet, so return EROFS if those entries are found to avoid corrupting
+	 * an index that was created by a newer kernel.
 	 */
 	err = -EROFS;
-	if (d_is_dir(index) || ovl_is_whiteout(index))
+	if (d_is_dir(index))
 		goto fail;
 
 	err = -EINVAL;
@@ -438,6 +435,17 @@ int ovl_verify_index(struct dentry *index, struct path *lowerstack,
 	if (hex2bin((u8 *)fh, index->d_name.name, len) || len != fh->len)
 		goto fail;
 
+	/*
+	 * Whiteout index entries are used as an indication that
+	 * an exported overlay file handle should be treated as stale
+	 * (i.e. after unlink/rmdir of the overlay inode).
+	 * These entries contain no xattr.
+	 * TODO: cleanup stale whiteout index (try to decode index name).
+	 */
+	err = 0;
+	if (ovl_is_whiteout(index))
+		goto out;
+
 	err = ovl_verify_origin_fh(index, fh);
 	if (err)
 		goto fail;
-- 
2.7.4




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]