Skip to contentSkip to conversation

kernel BUG in jffs2_del_ino_cache

syzbot syzbot 1 participant 4 messages Apr 3, 2024 – Apr 18

Subsystems (3)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following issue on:

HEAD commit:    fe46a7dd189e Merge tag 'sound-6.9-rc1' of git://git.kernel..
git tree:       upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=13f5f003180000
kernel config:  https://syzkaller.appspot.com/x/.config?x=fe78468a74fdc3b7
dashboard link: https://syzkaller.appspot.com/bug?extid=44664704c1494ad5f7a0
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=166276c5180000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12049423180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0f7abe4afac7/disk-fe46a7dd.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/82598d09246c/vmlinux-fe46a7dd.xz
kernel image: https://storage.googleapis.com/syzbot-assets/efa23788c875/bzImage-fe46a7dd.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

jffs2: notice: (5072) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.

------------[ cut here ]------------
kernel BUG at fs/jffs2/nodelist.c:462!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN NOPTI
CPU: 1 PID: 5072 Comm: syz-executor610 Not tainted 6.8.0-syzkaller-08951-gfe46a7dd189e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
RIP: 0010:jffs2_del_ino_cache+0x2c6/0x2d0 fs/jffs2/nodelist.c:462
Code: ff e9 64 ff ff ff 44 89 e1 80 e1 07 80 c1 03 38 c1 0f 8c 51 fe ff ff 4c 89 e7 e8 25 54 06 ff e9 44 fe ff ff e8 2b 05 a3 fe 90 <0f> 0b 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90
RSP: 0018:ffffc90004527958 EFLAGS: 00010293
RAX: ffffffff82f1f025 RBX: ffff88807ca31000 RCX: ffff888011a50000
RDX: 0000000000000000 RSI: ffff88807ca31000 RDI: ffff88802283a000
RBP: ffff88807ca31020 R08: ffff88802283a36b R09: 1ffff1100450746d
R10: dffffc0000000000 R11: ffffed100450746e R12: ffff88807ca31000
R13: ffff888077a080b8 R14: dffffc0000000000 R15: ffff88802283a000
FS:  0000000000000000(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000000 CR3: 00000000760e0000 CR4: 0000000000350ef0
Call Trace:
 <TASK>
 jffs2_do_clear_inode+0x33c/0x3b0 fs/jffs2/readinode.c:1443
 evict+0x2aa/0x630 fs/inode.c:667
 dispose_list fs/inode.c:700 [inline]
 evict_inodes+0x5f9/0x690 fs/inode.c:750
 generic_shutdown_super+0x9d/0x2d0 fs/super.c:626
 kill_mtd_super+0x23/0x70 drivers/mtd/mtdsuper.c:174
 jffs2_kill_sb+0x96/0xb0 fs/jffs2/super.c:349
 deactivate_locked_super+0xc6/0x130 fs/super.c:472
 cleanup_mnt+0x426/0x4c0 fs/namespace.c:1267
 task_work_run+0x251/0x310 kernel/task_work.c:180
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0xa1b/0x27e0 kernel/exit.c:878
 do_group_exit+0x207/0x2c0 kernel/exit.c:1027
 __do_sys_exit_group kernel/exit.c:1038 [inline]
 __se_sys_exit_group kernel/exit.c:1036 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1036
 do_syscall_64+0xfd/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75
RIP: 0033:0x7ffb6a6c11c9
Code: Unable to access opcode bytes at 0x7ffb6a6c119f.
RSP: 002b:00007ffe45c941f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007ffb6a6c11c9
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000001
RBP: 00007ffb6a73c370 R08: ffffffffffffffb8 R09: 00007ffb6a7365f0
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffb6a73c370
R13: 0000000000000000 R14: 00007ffb6a73cdc0 R15: 00007ffb6a68f330
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:jffs2_del_ino_cache+0x2c6/0x2d0 fs/jffs2/nodelist.c:462
Code: ff e9 64 ff ff ff 44 89 e1 80 e1 07 80 c1 03 38 c1 0f 8c 51 fe ff ff 4c 89 e7 e8 25 54 06 ff e9 44 fe ff ff e8 2b 05 a3 fe 90 <0f> 0b 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90
RSP: 0018:ffffc90004527958 EFLAGS: 00010293
RAX: ffffffff82f1f025 RBX: ffff88807ca31000 RCX: ffff888011a50000
RDX: 0000000000000000 RSI: ffff88807ca31000 RDI: ffff88802283a000
RBP: ffff88807ca31020 R08: ffff88802283a36b R09: 1ffff1100450746d
R10: dffffc0000000000 R11: ffffed100450746e R12: ffff88807ca31000
R13: ffff888077a080b8 R14: dffffc0000000000 R15: ffff88802283a000
FS:  0000000000000000(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffb6a73d1d0 CR3: 000000007c154000 CR4: 0000000000350ef0

---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

author syzbot
#1 lore raw

Forwarded: [PATCH] jffs2: replace BUG_ON with warning in

For archival purposes, forwarding an incoming command email to [email protected], [email protected].

For archival purposes, forwarding an incoming command email to [email protected], [email protected].

***

Subject: [PATCH] jffs2: replace BUG_ON with warning in
Author: [email protected]

From: Tristan Madani <[email protected]>

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

jffs2_del_ino_cache

jffs2_del_ino_cache() panics the kernel via BUG_ON if the inode cache entry still has xattr references:

    BUG_ON(old->xref);

This can be triggered by a crafted JFFS2 image where the CRC check path calls jffs2_do_clear_inode() while pino_nlink is non-zero. jffs2_xattr_delete_inode() skips cleanup when pino_nlink > 0, so the xref list survives into jffs2_del_ino_cache(), hitting the BUG_ON.

Replace the BUG_ON with WARN_ON_ONCE to report the inconsistency without crashing the kernel. The leaked xrefs will be cleaned up when the filesystem is unmounted via jffs2_free_ino_caches().

Reported-by [email protected]
Fixes aa98d7cf59b5 ("[JFFS2][XATTR] XATTR support on JFFS2 (version 5)")
---
 fs/jffs2/nodelist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jffs2/nodelist.c +1 -1
index XXXXXXX..XXXXXXX 100644
@@ -459,7 +459,7 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
 	struct jffs2_inode_cache **prev;
 
 #ifdef CONFIG_JFFS2_FS_XATTR
-	BUG_ON(old->xref);
+	WARN_ON_ONCE(old->xref);
 #endif
 	dbg_inocache("del %p (ino #%u)\n", old, old->ino);
 	spin_lock(&c->inocache_lock);

--
2.43.0

author syzbot
#2 lore raw

Forwarded: Re: [syzbot] kernel BUG in jffs2_del_ino_cache

In reply to syzbot
For archival purposes, forwarding an incoming command email to [email protected], [email protected].

For archival purposes, forwarding an incoming command email to [email protected], [email protected].

***

Subject: Re: [syzbot] kernel BUG in jffs2_del_ino_cache
Author: [email protected]

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

Quoted 1 line

From 2e46a94bb2b935dcf0b09aa5f20ff638124cb395 Mon Sep 17 00:00:00 2001

From: Tristan Madani <[email protected]>
Date: Fri, 17 Apr 2026 16:15:21 +0000
Subject: [PATCH] jffs2: replace BUG_ON with warning in jffs2_del_ino_cache() jffs2_del_ino_cache() uses BUG_ON(old->xref) which triggers a kernel panic when called with an inode cache entry that still has xattr references. On corrupted filesystems this is a recoverable condition. Replace with WARN_ON_ONCE to log the issue without crashing.

---
 fs/jffs2/nodelist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jffs2/nodelist.c +1 -1
index b86c78d..c1dc753 100644
@@ -459,7 +459,7 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
 	struct jffs2_inode_cache **prev;
 
 #ifdef CONFIG_JFFS2_FS_XATTR
-	BUG_ON(old->xref);
+	WARN_ON_ONCE(old->xref);
 #endif
 	dbg_inocache("del %p (ino #%u)\n", old, old->ino);
 	spin_lock(&c->inocache_lock);
Signature · 1 line
2.47.3
author syzbot
#3 lore raw

Forwarded: Re: [syzbot] kernel BUG in jffs2_del_ino_cache

In reply to syzbot
For archival purposes, forwarding an incoming command email to [email protected], [email protected].

For archival purposes, forwarding an incoming command email to [email protected], [email protected].

***

Subject: Re: [syzbot] kernel BUG in jffs2_del_ino_cache
Author: [email protected]

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

Quoted 1 line

From 7108f321633c0bdfbbab9d305e2e01e7d83c8902 Mon Sep 17 00:00:00 2001

From: Tristan Madani <[email protected]>
Date: Sat, 18 Apr 2026 12:55:36 +0000
Subject: [PATCH] jffs2: clean up residual xattr refs in jffs2_del_ino_cache

jffs2_del_ino_cache() uses BUG_ON(old->xref) to assert that all xattr references have been cleaned up before deleting an inode cache entry. However, a corrupted filesystem image can lead to inode cache deletion with xattr references still attached, triggering a kernel panic.

Replace the BUG_ON with a graceful cleanup path that calls jffs2_xattr_free_inode() to properly release all residual xattr references before proceeding with the deletion.

Reported-by [email protected]
Fixes aa98d7cf59b5 ("[JFFS2][XATTR] XATTR support on JFFS2 (version 5)")
---
 fs/jffs2/nodelist.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/jffs2/nodelist.c +4 -1
index b86c78d178c60..498308f741a34 100644
@@ -459,7 +459,10 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
 	struct jffs2_inode_cache **prev;
 
 #ifdef CONFIG_JFFS2_FS_XATTR
-	BUG_ON(old->xref);
+	if (old->xref) {
+		pr_notice("ino #%u: cleaning up residual xattr refs\n", old->ino);
+		jffs2_xattr_free_inode(c, old);
+	}
 #endif
 	dbg_inocache("del %p (ino #%u)\n", old, old->ino);
 	spin_lock(&c->inocache_lock);
Signature · 1 line
2.47.3