mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] jffs2: reset unchecked_size on summary fallback to full scan
@ 2026-12-01  8:33 Thanh Nguyen
  0 siblings, 0 replies; only message in thread
From: Thanh Nguyen @ 2026-12-01  8:33 UTC (permalink / raw)
  To: David Woodhouse, Richard Weinberger
  Cc: linux-mtd, linux-kernel, stable, Thanh Nguyen,
	syzbot+f9e8c522812e12a70ee5

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-01  8:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  8:33 [PATCH] jffs2: reset unchecked_size on summary fallback to full scan Thanh Nguyen

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®