Skip to content

Commit 93ffb6c

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: detect more inconsistent cases in sanity_check_node_footer()
Let's enhance sanity_check_node_footer() to detect more inconsistent cases as below: Node Type Node Footer Info =================== ============================= NODE_TYPE_REGULAR inode = true and xnode = true NODE_TYPE_INODE inode = false or xnode = true NODE_TYPE_XATTR inode = true or xnode = false NODE_TYPE_NON_INODE inode = false Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 50ac3ec commit 93ffb6c

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

fs/f2fs/node.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,20 +1515,29 @@ int f2fs_sanity_check_node_footer(struct f2fs_sb_info *sbi,
15151515
struct folio *folio, pgoff_t nid,
15161516
enum node_type ntype, bool in_irq)
15171517
{
1518+
bool is_inode, is_xnode;
1519+
15181520
if (unlikely(nid != nid_of_node(folio)))
15191521
goto out_err;
15201522

1523+
is_inode = IS_INODE(folio);
1524+
is_xnode = f2fs_has_xattr_block(ofs_of_node(folio));
1525+
15211526
switch (ntype) {
1527+
case NODE_TYPE_REGULAR:
1528+
if (is_inode && is_xnode)
1529+
goto out_err;
1530+
break;
15221531
case NODE_TYPE_INODE:
1523-
if (!IS_INODE(folio))
1532+
if (!is_inode || is_xnode)
15241533
goto out_err;
15251534
break;
15261535
case NODE_TYPE_XATTR:
1527-
if (!f2fs_has_xattr_block(ofs_of_node(folio)))
1536+
if (is_inode || !is_xnode)
15281537
goto out_err;
15291538
break;
15301539
case NODE_TYPE_NON_INODE:
1531-
if (IS_INODE(folio))
1540+
if (is_inode)
15321541
goto out_err;
15331542
break;
15341543
default:

0 commit comments

Comments
 (0)