aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/overlayfs/namei.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 229a88ff335c..8aef2b304b2d 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -513,6 +513,7 @@ static struct dentry *ovl_lookup_index(struct dentry *dentry,
513 goto out; 513 goto out;
514 } 514 }
515 515
516 inode = d_inode(index);
516 if (d_is_negative(index)) { 517 if (d_is_negative(index)) {
517 if (upper && d_inode(origin)->i_nlink > 1) { 518 if (upper && d_inode(origin)->i_nlink > 1) {
518 pr_warn_ratelimited("overlayfs: hard link with origin but no index (ino=%lu).\n", 519 pr_warn_ratelimited("overlayfs: hard link with origin but no index (ino=%lu).\n",
@@ -522,11 +523,22 @@ static struct dentry *ovl_lookup_index(struct dentry *dentry,
522 523
523 dput(index); 524 dput(index);
524 index = NULL; 525 index = NULL;
525 } else if (upper && d_inode(index) != d_inode(upper)) { 526 } else if (upper && d_inode(upper) != inode) {
526 inode = d_inode(index); 527 pr_warn_ratelimited("overlayfs: wrong index found (index=%pd2, ino=%lu, upper ino=%lu).\n",
527 pr_warn_ratelimited("overlayfs: wrong index found (index ino: %lu, upper ino: %lu).\n", 528 index, inode->i_ino, d_inode(upper)->i_ino);
528 d_inode(index)->i_ino, 529 goto fail;
529 d_inode(upper)->i_ino); 530 } else if (ovl_dentry_weird(index) || ovl_is_whiteout(index) ||
531 ((inode->i_mode ^ d_inode(origin)->i_mode) & S_IFMT)) {
532 /*
533 * Index should always be of the same file type as origin
534 * except for the case of a whiteout index. A whiteout
535 * index should only exist if all lower aliases have been
536 * unlinked, which means that finding a lower origin on lookup
537 * whose index is a whiteout should be treated as an error.
538 */
539 pr_warn_ratelimited("overlayfs: bad index found (index=%pd2, ftype=%x, origin ftype=%x).\n",
540 index, d_inode(index)->i_mode & S_IFMT,
541 d_inode(origin)->i_mode & S_IFMT);
530 goto fail; 542 goto fail;
531 } 543 }
532 544