From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.141 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796174342; b=S8vvF/mUDjShMTsTiByBF0PFlvs5GmwWfDCIdfPggxDg+BUThFFulpb//l2gbIMVygrk aHmji8sGqXL4wsr/+PrM55zTtvRRi2J9OzNwQuJig3HhVEdZYGxmtmK4Z/58BKJUUPRxw PvXnRRzp1uRTaCKvdeu7tmBki7woxALsfZYeJd7nYABk69PwyruFmh51YYNcdQfl9bU6+ mVMorAo4vaCi1vQH7l920IryZJ1uItwlXKj5vJJt1L2739kSpjo/pwH+ZxRhmhAdm/DJk xijxWmdUS6Xphsupd4H5Bt5yxD2uppZNYlIavrc5mtQCWnh8YK+RWpPbj5pjUp1Kxrg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796174342; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=57m2aRe5sbhBo8YvC+YUDqjP6lI5kT+4gO5iP110Ujs=; b=ceNJRyRiMET+ZftjpcXDdM/tZiooJtM/FjXrMLJl8RyCSjDmlb32n9UTBO7F0NsRC2i6 HcMD7m6mG+TwuuYeAtYqf+OGdYeMzDBkSkm8pyx6WN1Gsk7ergToVR1RMrlc29SkrznAw uIyzIbalMBP9S36lDXQNJH1/ogSaLR2qByyncsGUggD3HJFylz/5BNbDW44HGKzciDoCl cOGfPjsZwbC/jool9mOuXoyNAYj7XSFmmP2qqc4QeO7xYb5jsTyupgI0x2fj/N9GTgG1o oZivSBvDmeePt0woGdlrC3f3PtaotO61jnvKMTNc1PX3fxYU0wXuJjvQvv4wSTbcMEw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Z4tGvxAN; arc=none smtp.remote-ip=91.218.175.141 Received: from mta0.migadu.com (out-141.mta0.migadu.com [91.218.175.141]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2308D606A31A for ; Wed, 2 Dec 2026 01:19:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2308D606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=Z4tGvxAN X-Envelope-To: stable@vger.kernel.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: stable@vger.kernel.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-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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); >