fsck.f2fs: check ino of an inode
authorSheng Yong <shengyong1@huawei.com>
Sat, 30 Jan 2016 09:16:39 +0000 (09:16 +0000)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 2 Feb 2016 00:28:25 +0000 (16:28 -0800)
If the node is an inode, its ino in the nat entry should be equal to the
ino in its node footer. Otherwise, we drop the file.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/fsck.c

index 3e5dd4e..99dfe1f 100644 (file)
@@ -383,6 +383,11 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
                                le32_to_cpu(node_blk->footer.ino));
                return -EINVAL;
        }
+       if (ntype == TYPE_INODE && ni->ino != node_blk->footer.ino) {
+               ASSERT_MSG("nid[0x%x] TYPE_INODE nat_entry->ino[0x%x] footer.ino[0x%x]",
+                               nid, ni->ino, le32_to_cpu(node_blk->footer.ino));
+               return -EINVAL;
+       }
        if (ntype != TYPE_INODE &&
                        node_blk->footer.nid == node_blk->footer.ino) {
                ASSERT_MSG("nid[0x%x] footer.nid[0x%x] footer.ino[0x%x]",