From: Thanh Nguyen <thanhnguyxntester@gmail.com>
To: David Woodhouse <dwmw2@infradead.org>,
Richard Weinberger <richard@nod.at>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Thanh Nguyen <thanhnguyxntester@gmail.com>,
syzbot+f9e8c522812e12a70ee5@syzkaller.appspotmail.com
Subject: [PATCH] jffs2: reset unchecked_size on summary fallback to full scan
Date: Tue, 1 Dec 2026 03:33:03 -0500 [thread overview]
Message-ID: <20261201083303.521-1-thanhnguyxntester@gmail.com> (raw)
In jffs2_sum_process_sum_data(), summary entries for INODE, DIRENT,
XATTR, and XREF nodes are linked via sum_link_node_ref() with
REF_UNCHECKED, which increments both c->unchecked_size and
jeb->unchecked_size while decrementing free_size.
When an unsupported compatible node type is later encountered in the
same summary, the default branch falls back to a full eraseblock scan
and restores c->free_size by (c->sector_size - jeb->free_size), while
subtracting wasted_size, used_size, and dirty_size from the superblock
counters. However, it fails to subtract jeb->unchecked_size from
c->unchecked_size or reset jeb->unchecked_size to 0.
This leaves both c->unchecked_size and jeb->unchecked_size inflated by
the previously scanned unchecked nodes, violating the space-accounting
invariant and triggering BUG() in __jffs2_dbg_acct_sanity_check_nolock().
Subtract jeb->unchecked_size from c->unchecked_size and reset
jeb->unchecked_size to 0 before calling jffs2_free_jeb_node_refs().
Fixes: 7807ef7ba2a4 ("[JFFS2] Fix summary handling of unknown but compatible nodes.")
Reported-by: syzbot+f9e8c522812e12a70ee5@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f9e8c522812e12a70ee5
Cc: stable@vger.kernel.org
Signed-off-by: Thanh Nguyen <thanhnguyxntester@gmail.com>
---
fs/jffs2/summary.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index 4521a7723..94d0ce7bb 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -557,7 +557,9 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
c->free_size += c->sector_size - jeb->free_size;
c->used_size -= jeb->used_size;
c->dirty_size -= jeb->dirty_size;
+ c->unchecked_size -= jeb->unchecked_size;
jeb->wasted_size = jeb->used_size = jeb->dirty_size = 0;
+ jeb->unchecked_size = 0;
jeb->free_size = c->sector_size;
jffs2_free_jeb_node_refs(c, jeb);
--
2.56.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
reply other threads:[~2026-12-01 8:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261201083303.521-1-thanhnguyxntester@gmail.com \
--to=thanhnguyxntester@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=stable@vger.kernel.org \
--cc=syzbot+f9e8c522812e12a70ee5@syzkaller.appspotmail.com \
/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