Skip to content

Commit cd2fec9

Browse files
chaseyugregkh
authored andcommitted
f2fs: fix to do sanity check on node footer in __write_node_folio()
[ Upstream commit 0a73610 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 715a7a7 commit cd2fec9

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
@@ -1751,7 +1751,11 @@ static bool __write_node_folio(struct folio *folio, bool atomic, bool *submitted
17511751

17521752
/* get old block addr of this node page */
17531753
nid = nid_of_node(folio);
1754-
f2fs_bug_on(sbi, folio->index != nid);
1754+
1755+
if (sanity_check_node_footer(sbi, folio, nid, NODE_TYPE_REGULAR)) {
1756+
f2fs_handle_critical_error(sbi, STOP_CP_REASON_CORRUPTED_NID);
1757+
goto redirty_out;
1758+
}
17551759

17561760
if (f2fs_get_node_info(sbi, nid, &ni, !do_balance))
17571761
goto redirty_out;

0 commit comments

Comments
 (0)