Skip to content

Commit 0a73610

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to do sanity check on node footer in __write_node_folio()
Add node footer sanity check during node folio's writeback, if sanity check fails, let's shutdown filesystem to avoid looping to redirty and writeback in .writepages. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent f7b929e commit 0a73610

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

fs/f2fs/node.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,11 @@ static bool __write_node_folio(struct folio *folio, bool atomic, bool *submitted
17631763

17641764
/* get old block addr of this node page */
17651765
nid = nid_of_node(folio);
1766-
f2fs_bug_on(sbi, folio->index != nid);
1766+
1767+
if (sanity_check_node_footer(sbi, folio, nid, NODE_TYPE_REGULAR)) {
1768+
f2fs_handle_critical_error(sbi, STOP_CP_REASON_CORRUPTED_NID);
1769+
goto redirty_out;
1770+
}
17671771

17681772
if (f2fs_get_node_info(sbi, nid, &ni, !do_balance))
17691773
goto redirty_out;

0 commit comments

Comments
 (0)