From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44A2B606A31A for ; Wed, 2 Dec 2026 01:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=GaWMtArI; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Z4tGvxAN DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=e39NFyRr+gVZGxIiHHxFTfpHCCrON5eMlLr7GG8WghY=; b=GaWMtArIR6P9gCjWMvle0XNfd/ 2kEa5gy9PB/unRSN6kGzcjtc0trjHzkKdpnNqTFpSN8vMiWL0qkUamwCBCHbTva1rokZJ1OxOZOKH GFsQgb6cozpQJ/cvxDoSqWhAJ/06bNl/+HgSgZ+EeO0wFR8QS1HEAVJFuaKW3QqAGU2WUjdeFwYTR i921ESe/8ONpswBY60BH+I9jHIYYj/Y9xDS9Wu570hM7UgR+XTeOk5EtagR0OKQy1igH1YZ3cEUXS mlPiGTpXZWDS5mVYdfhpqhbe5QTu9TG4oubwwXyiOAN1fns4jk54OeE94d9rgYJ72Ilo60R2tu8Bo 8u120EBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYYzy-00000009rcR-1Z8g; Wed, 02 Dec 2026 01:19:06 +0000 Received: from out-146.mta1.migadu.com ([95.215.58.146] helo=mta1.migadu.com) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYYzv-00000009rbk-2Vf6 for linux-mtd@lists.infradead.org; Wed, 02 Dec 2026 01:19:05 +0000 X-Envelope-To: linux-mtd@lists.infradead.org DKIM-Signature: a=rsa-sha256; bh=HfQVmGNyiWmFEVgpcGZ/FAKp39T3M+L+eYu+XQnVCfs=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796174340; v=1; x=1796779140; b=Z4tGvxANtWezNyRl0yVebM5CtLqcXOX0+qwPl0aXAbwidcO6/q+Vzfg31M+kBCWySM3s50eu 0k/+b9uU6DP04cb69n1x5gR6Fle175XWT6bO0n7SaTNWzyUQQtnaUeOxrIzz91/NIJ9QaO3drED pDsrFf5hbFj7s+ZIRFMSIm/Y= X-Envelope-To: linux-mtd@lists.infradead.org Received: by smtp.migadu.com with ESMTPS id c5a5d7cad2492226; Wed, 02 Dec 2026 01:18:59 +0000 X-Mizu-Trace-ID: c5a5d7cad2492226 X-Migadu-Flow: FLOW_OUT Message-ID: <6fd8cc9d-57e7-46ee-ba38-df4e8e3132dd@linux.dev> Date: Wed, 2 Dec 2026 02:18:57 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] jffs2: clean up xattr refs in jffs2_del_ino_cache instead of BUG_ON To: Richard Weinberger , David Woodhouse , Richard Weinberger , linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Tristan Madani , syzbot+44664704c1494ad5f7a0@syzkaller.appspotmail.com, Tristan Madani References: <20260501110246.50647-1-tristmd@gmail.com> <20260501110246.50647-2-tristmd@gmail.com> <5hmscKuSR3ughce1aoesBg@sigma-star.at> Content-Language: en-US From: Haris Iqbal In-Reply-To: <5hmscKuSR3ughce1aoesBg@sigma-star.at> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261201_171903_906126_9E276F11 X-CRM114-Status: GOOD ( 16.77 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-mtd" X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 12/1/26 23:45, Richard Weinberger wrote: > On Freitag, 1. Mai 2026 13:02 Tristan Madani wrote: >> From: Tristan Madani >> >> 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 >> --- >> 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); > ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/