Forwarded: Re: [syzbot] kernel BUG in jffs2_del_ino_cache

From: syzbot

Date: Sat Apr 18 2026 - 08:57:03 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx, syzkaller-bugs@xxxxxxxxxxxxxxxx.

***

Subject: Re: [syzbot] kernel BUG in jffs2_del_ino_cache
Author: tristmd@xxxxxxxxx

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

>From 7108f321633c0bdfbbab9d305e2e01e7d83c8902 Mon Sep 17 00:00:00 2001
From: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>
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: syzbot+44664704c1494ad5f7a0@xxxxxxxxxxxxxxxxxxxxxxxxx
Fixes: aa98d7cf59b5 ("[JFFS2][XATTR] XATTR support on JFFS2 (version 5)")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Tristan Madani <tristan@xxxxxxxxxxxxxxxxxxx>
---
fs/jffs2/nodelist.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index b86c78d178c60..498308f741a34 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -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);
--
2.47.3