From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Chao Yu <chao@kernel.org>, Jaegeuk Kim <jaegeuk@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.18.y 4/5] f2fs: detect more inconsistent cases in sanity_check_node_footer()
Date: Sat, 4 Jul 2026 09:01:05 -0400 [thread overview]
Message-ID: <20260704130106.828918-4-sashal@kernel.org> (raw)
In-Reply-To: <20260704130106.828918-1-sashal@kernel.org>
From: Chao Yu <chao@kernel.org>
[ Upstream commit 93ffb6c28ff180560d2d7313ac106efcd9e012b8 ]
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>
Stable-dep-of: 8712353ed80f ("f2fs: fix to do sanity check on f2fs_get_node_folio_ra()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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 ca3dad7418b268..bf06c9582ae49b 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1504,20 +1504,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.53.0
next prev parent reply other threads:[~2026-07-04 13:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 13:36 FAILED: patch "[PATCH] f2fs: fix to do sanity check on f2fs_get_node_folio_ra()" failed to apply to 6.18-stable tree gregkh
2026-07-04 13:01 ` [PATCH 6.18.y 1/5] f2fs: use memalloc_retry_wait() as much as possible Sasha Levin
2026-07-04 13:01 ` [PATCH 6.18.y 2/5] f2fs: introduce f2fs_schedule_timeout() Sasha Levin
2026-07-04 13:01 ` [PATCH 6.18.y 3/5] f2fs: optimize trace_f2fs_write_checkpoint with enums Sasha Levin
2026-07-04 13:01 ` Sasha Levin [this message]
2026-07-04 13:01 ` [PATCH 6.18.y 5/5] f2fs: fix to do sanity check on f2fs_get_node_folio_ra() Sasha Levin
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=20260704130106.828918-4-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.