The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Haris Iqbal <haris.iqbal@linux.dev>
To: Richard Weinberger <richard@sigma-star.at>,
	David Woodhouse <dwmw2@infradead.org>,
	Richard Weinberger <richard@nod.at>,
	linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Tristan Madani <tristan@talencesecurity.com>,
	syzbot+44664704c1494ad5f7a0@syzkaller.appspotmail.com,
	Tristan Madani <tristmd@gmail.com>
Subject: Re: [PATCH 2/3] jffs2: clean up xattr refs in jffs2_del_ino_cache instead of BUG_ON
Date: Wed, 2 Dec 2026 02:18:57 +0100	[thread overview]
Message-ID: <6fd8cc9d-57e7-46ee-ba38-df4e8e3132dd@linux.dev> (raw)
In-Reply-To: <5hmscKuSR3ughce1aoesBg@sigma-star.at>



On 12/1/26 23:45, Richard Weinberger wrote:
> On Freitag, 1. Mai 2026 13:02 Tristan Madani wrote:
>> From: Tristan Madani <tristan@talencesecurity.com>
>>
>> jffs2_del_ino_cache() triggers BUG_ON(old->xref) when an inode cache
>> entry still has xattr references.  This can happen during unmount:
>> generic_shutdown_super() calls evict_inodes() before put_super(), but
>> jffs2_evict_inode -> jffs2_do_clear_inode -> jffs2_xattr_delete_inode
>> only clears xrefs when pino_nlink == 0.  For inodes with nlink > 0
>> at unmount time, xrefs survive past eviction, and the subsequent
>> jffs2_del_ino_cache() hits the BUG_ON.
>>
>> Replace the BUG_ON with a call to jffs2_xattr_free_inode(), which
>> walks the xref list and frees each entry without writing delete markers
>> to flash.  This is appropriate during unmount since the flash state
>> will be reconstructed by the next mount scan anyway.
>>
>> jffs2_xattr_free_inode() already exists for this purpose and is used
>> by jffs2_clear_xattr_subsystem() in the put_super path, but that
>> runs too late -- after jffs2_del_ino_cache has already been called
>> from evict_inode.
>>
>> Reported-by: syzbot+44664704c1494ad5f7a0@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?extid=44664704c1494ad5f7a0
>> Fixes: aa98d7cf59b5 ("[JFFS2][XATTR] XATTR support on JFFS2 (version 5)")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
>> ---
>>   fs/jffs2/nodelist.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
>> index b86c78d178c60..9af269b78b241 100644
>> --- a/fs/jffs2/nodelist.c
>> +++ b/fs/jffs2/nodelist.c
>> @@ -459,7 +459,8 @@ 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)
>> +		jffs2_xattr_free_inode(c, old);
> 
> jffs2_del_ino_cache() can get called under a spinlock, but jffs2_xattr_free_inode() down's a semaphore.
> 
> Thanks,
> //richard

I was able to reproduce the above BUG_ON hit described.

One alternate way to solve it would be to move the free into 
jffs2_do_clear_inode().

diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 1caabff9dc91..9ff780e5f65f 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -1439,8 +1439,10 @@ void jffs2_do_clear_inode(struct jffs2_sb_info 
*c, struct jffs2_inode_info *f)

         if (f->inocache && f->inocache->state != INO_STATE_CHECKING) {
                 jffs2_set_inocache_state(c, f->inocache, 
INO_STATE_CHECKEDABSENT);
-               if (f->inocache->nodes == (void *)f->inocache)
+               if (f->inocache->nodes == (void *)f->inocache) {
+                       jffs2_xattr_free_inode(c, f->inocache);
                         jffs2_del_ino_cache(c, f->inocache);
+               }
         }

         mutex_unlock(&f->sem);


> 


  reply	other threads:[~2026-12-02  1:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01 11:02 [PATCH 1/3] jffs2: always stop garbage collection thread on unmount Tristan Madani
2026-05-01 11:02 ` [PATCH 2/3] jffs2: clean up xattr refs in jffs2_del_ino_cache instead of BUG_ON Tristan Madani
2026-12-01 22:45   ` Richard Weinberger
2026-12-02  1:18     ` Haris Iqbal [this message]
2026-05-01 11:02 ` [PATCH 3/3] jffs2: fix GC thread BUG_ON during reconfigure via fspick Tristan Madani

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=6fd8cc9d-57e7-46ee-ba38-df4e8e3132dd@linux.dev \
    --to=haris.iqbal@linux.dev \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=richard@sigma-star.at \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+44664704c1494ad5f7a0@syzkaller.appspotmail.com \
    --cc=tristan@talencesecurity.com \
    --cc=tristmd@gmail.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