linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH 1/2] fsck.f2fs: fix to check validation of block address
@ 2020-04-07 10:01 Chao Yu
  2020-04-07 10:01 ` [f2fs-dev] [PATCH 2/2] fsck.f2fs: fix to check validation of i_xattr_nid Chao Yu
  0 siblings, 1 reply; 7+ messages in thread
From: Chao Yu @ 2020-04-07 10:01 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: kilobyte, jaegeuk

Otherwise, if block address is invalid, we may access invalid
memory address in is_sit_bitmap_set().

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fsck/dump.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fsck/dump.c b/fsck/dump.c
index 8481a58..144c10e 100644
--- a/fsck/dump.c
+++ b/fsck/dump.c
@@ -486,10 +486,15 @@ void dump_node(struct f2fs_sb_info *sbi, nid_t nid, int force)
 	DBG(1, "nat_entry.version     [0x%x]\n", ni.version);
 	DBG(1, "nat_entry.ino         [0x%x]\n", ni.ino);
 
+	if (!IS_VALID_BLK_ADDR(sbi, ni.blk_addr)) {
+		MSG(force, "Invalid node blkaddr: %u\n\n", ni.blk_addr);
+		goto out;
+	}
+
 	if (ni.blk_addr == 0x0)
 		MSG(force, "Invalid nat entry\n\n");
 	else if (!is_sit_bitmap_set(sbi, ni.blk_addr))
-		MSG(force, "Invalid node blk addr\n\n");
+		MSG(force, "Invalid sit bitmap, %u\n\n", ni.blk_addr);
 
 	DBG(1, "node_blk.footer.ino [0x%x]\n", le32_to_cpu(node_blk->footer.ino));
 	DBG(1, "node_blk.footer.nid [0x%x]\n", le32_to_cpu(node_blk->footer.nid));
@@ -504,7 +509,7 @@ void dump_node(struct f2fs_sb_info *sbi, nid_t nid, int force)
 		print_node_info(sbi, node_blk, force);
 		MSG(force, "Invalid (i)node block\n\n");
 	}
-
+out:
 	free(node_blk);
 }
 
-- 
2.18.0.rc1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-11-02 16:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-07 10:01 [f2fs-dev] [PATCH 1/2] fsck.f2fs: fix to check validation of block address Chao Yu
2020-04-07 10:01 ` [f2fs-dev] [PATCH 2/2] fsck.f2fs: fix to check validation of i_xattr_nid Chao Yu
2020-10-31 23:48   ` Eric Biggers
2020-11-02  1:31     ` Chao Yu
2020-11-02  2:39       ` Eric Biggers
2020-11-02  3:28         ` Chao Yu
2020-11-02 16:04           ` Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).