diff options
| author | Chao Yu <chao@kernel.org> | 2026-01-12 10:49:17 +0300 |
|---|---|---|
| committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2026-01-17 03:00:35 +0300 |
| commit | 93ffb6c28ff180560d2d7313ac106efcd9e012b8 (patch) | |
| tree | 39fcf49c84d61907b3e1472d1703939d255f67dc | |
| parent | 50ac3ecd8e05b6bcc350c71a4307d40c030ec7e4 (diff) | |
| download | linux-93ffb6c28ff180560d2d7313ac106efcd9e012b8.tar.xz | |
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>
| -rw-r--r-- | fs/f2fs/node.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index efd4f176a1f4..63252ff1e5c3 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1515,20 +1515,29 @@ int f2fs_sanity_check_node_footer(struct f2fs_sb_info *sbi, struct folio *folio, pgoff_t nid, enum node_type ntype, bool in_irq) { + bool is_inode, is_xnode; + if (unlikely(nid != nid_of_node(folio))) goto out_err; + is_inode = IS_INODE(folio); + is_xnode = f2fs_has_xattr_block(ofs_of_node(folio)); + switch (ntype) { + case NODE_TYPE_REGULAR: + if (is_inode && is_xnode) + goto out_err; + break; case NODE_TYPE_INODE: - if (!IS_INODE(folio)) + if (!is_inode || is_xnode) goto out_err; break; case NODE_TYPE_XATTR: - if (!f2fs_has_xattr_block(ofs_of_node(folio))) + if (is_inode || !is_xnode) goto out_err; break; case NODE_TYPE_NON_INODE: - if (IS_INODE(folio)) + if (is_inode) goto out_err; break; default: |
