summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2017-11-01 04:13:51 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2018-01-24 05:25:53 -0500
commit9ee60ce2491166c73a381e5f04dc4c3a147e169d (patch)
tree1a4d03cf001582847d7d53149fbe1d9978d00242
parente8f9e5b780b0406ab81add72f1a05583ae5d40ac (diff)
ovl: cleanup temp index entries
A previous failed attempt to create or whiteout a directory index may leave index entries named '#%x' in the index dir. Cleanup those temp entries on mount instead of failing the mount. In the future, we may drop 'work' dir and use 'index' dir instead. This change is enough for cleaning up copy up leftovers 'from the future', but it is not enough for cleaning up rmdir leftovers 'from the future' (i.e. temp dir containing whiteouts). Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/overlayfs/namei.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 881caa385a36..7f27ec5999ea 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/fs.h> 10#include <linux/fs.h>
11#include <linux/cred.h> 11#include <linux/cred.h>
12#include <linux/ctype.h>
12#include <linux/namei.h> 13#include <linux/namei.h>
13#include <linux/xattr.h> 14#include <linux/xattr.h>
14#include <linux/ratelimit.h> 15#include <linux/ratelimit.h>
@@ -467,6 +468,12 @@ static struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index)
467 return upper; 468 return upper;
468} 469}
469 470
471/* Is this a leftover from create/whiteout of directory index entry? */
472static bool ovl_is_temp_index(struct dentry *index)
473{
474 return index->d_name.name[0] == '#';
475}
476
470/* 477/*
471 * Verify that an index entry name matches the origin file handle stored in 478 * Verify that an index entry name matches the origin file handle stored in
472 * OVL_XATTR_ORIGIN and that origin file handle can be decoded to lower path. 479 * OVL_XATTR_ORIGIN and that origin file handle can be decoded to lower path.
@@ -484,6 +491,11 @@ int ovl_verify_index(struct ovl_fs *ofs, struct dentry *index)
484 if (!d_inode(index)) 491 if (!d_inode(index))
485 return 0; 492 return 0;
486 493
494 /* Cleanup leftover from index create/cleanup attempt */
495 err = -ESTALE;
496 if (ovl_is_temp_index(index))
497 goto fail;
498
487 err = -EINVAL; 499 err = -EINVAL;
488 if (index->d_name.len < sizeof(struct ovl_fh)*2) 500 if (index->d_name.len < sizeof(struct ovl_fh)*2)
489 goto fail; 501 goto fail;