Commit 7db25d36 authored by Amir Goldstein's avatar Amir Goldstein Committed by Miklos Szeredi

ovl: verify whiteout index entries on mount

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

Check on mount that whiteout index entries have a name that looks like
a valid file handle and cleanup invalid index entries.

For whiteout index entries, do not check that they also have valid
origin fh and nlink xattr, because those xattr do not exist for a
whiteout index entry.
Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent ad1d615c
...@@ -439,16 +439,13 @@ int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index) ...@@ -439,16 +439,13 @@ int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index)
/* /*
* Directory index entries are going to be used for looking up * Directory index entries are going to be used for looking up
* redirected upper dirs by lower dir fh when decoding an overlay * redirected upper dirs by lower dir fh when decoding an overlay
* file handle of a merge dir. Whiteout index entries are going to be * file handle of a merge dir. We don't know the verification rules
* used as an indication that an exported overlay file handle should * for directory index entries, because they have not been implemented
* be treated as stale (i.e. after unlink of the overlay inode). * yet, so return EINVAL if those entries are found to abort the mount
* We don't know the verification rules for directory and whiteout * and to avoid corrupting an index that was created by a newer kernel.
* index entries, because they have not been implemented yet, so return
* EINVAL if those entries are found to abort the mount to avoid
* corrupting an index that was created by a newer kernel.
*/ */
err = -EINVAL; err = -EINVAL;
if (d_is_dir(index) || ovl_is_whiteout(index)) if (d_is_dir(index))
goto fail; goto fail;
if (index->d_name.len < sizeof(struct ovl_fh)*2) if (index->d_name.len < sizeof(struct ovl_fh)*2)
...@@ -468,6 +465,14 @@ int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index) ...@@ -468,6 +465,14 @@ int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index)
if (err) if (err)
goto fail; 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
* of the overlay inode). These entries contain no origin xattr.
*/
if (ovl_is_whiteout(index))
goto out;
err = ovl_verify_fh(index, OVL_XATTR_ORIGIN, fh); err = ovl_verify_fh(index, OVL_XATTR_ORIGIN, fh);
if (err) if (err)
goto fail; goto fail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment