From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Chao Yu <chao@kernel.org>
Subject: [PATCH v5 3/3] f2fs: detect more inconsistent cases in sanity_check_node_footer()
Date: Mon, 12 Jan 2026 15:49:17 +0800 [thread overview]
Message-ID: <20260112074917.40107-3-chao@kernel.org> (raw)
In-Reply-To: <20260112074917.40107-1-chao@kernel.org>
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>
---
v5:
- split original patch 1/2 to two, in this patch, fix to not sanity check
on uninitialized i_mode for new inode page, instead, let's enhance
sanity_check_node_footer() to detect more inconsistent cases in node footer.
fs/f2fs/node.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index e8b2618fcac7..c79af2bc5728 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:
--
2.40.1
next prev parent reply other threads:[~2026-01-12 8:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 7:49 [PATCH v5 1/3] f2fs: fix to do sanity check on node footer in __write_node_folio() Chao Yu
2026-01-12 7:49 ` [PATCH v5 2/3] f2fs: fix to do sanity check on node footer in {read,write}_end_io Chao Yu
2026-01-12 7:49 ` Chao Yu [this message]
2026-01-19 13:50 ` [f2fs-dev] [PATCH v5 1/3] f2fs: fix to do sanity check on node footer in __write_node_folio() patchwork-bot+f2fs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260112074917.40107-3-chao@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®