From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 204935B1EB for ; Fri, 12 Dec 2025 07:13:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765523626; cv=none; b=eKb+RIuobWZQU3Ak0m4XJR7v/1uTc3nx04BFLqur+fw3oMJPwQhnO/P6Zjbdvu5r/hh8PK231BhQTTuVc24C1/za67BjuXzIIzuwqxMRu2o7UPH4Hv+zKbJdYedqIqhFHpd4Ys6N5EpP/nJn6h+BmB9Li7SBjctjORa75zPXKN4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765523626; c=relaxed/simple; bh=K8MtrBOFrG554Tq0/LtGtmG91BQEYMn2dz5/yj+JJCU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=AD8KFJCIWkuXgq+lr3C0uVFRm+WEm0JSZTgzE6NnOwpKk6h+uxGTnJa+EkoFnhxlNIeH0dDQVZluv3D21+SDH1PKYhXWpdLkBfnOg2q0Mr2DqQacglyBL3g5GIYnHdxbwUtJIkmGqwZRbUV1+/q4t/UNcppYoYFtDxDR2X+c7RQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=lL6px+cP; arc=none smtp.client-ip=115.124.30.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="lL6px+cP" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1765523620; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=L2y8fQcX6a79m4xMCeLeaa2YHm7bV3+qA1r3yVsF+Ic=; b=lL6px+cP79dxe1vNZJDVWo7aBYh3hk/acT9V+i/uKQOFs0SLbKlmQ9NGwxanbYU/qfONTvspvrtAUan0KfRxjumCfnxoKv1ZjSmU3c/kDrYtRH+/vdFCPx18hqceZTvU5MMTCMgWm10ulDoA3Pidw5zbzksBl+Rs6IhnKZlxFDo= Received: from 30.221.145.122(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0WudIePH_1765523619 cluster:ay36) by smtp.aliyun-inc.com; Fri, 12 Dec 2025 15:13:40 +0800 Message-ID: Date: Fri, 12 Dec 2025 15:13:39 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] ocfs2: validate i_refcount_loc when refcount flag is set To: Deepanshu Kartikey , mark@fasheh.com, jlbec@evilplan.org, heming.zhao@suse.com, akpm Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, syzbot+6d832e79d3efe1c46743@syzkaller.appspotmail.com References: <20251212055826.20929-1-kartikey406@gmail.com> From: Joseph Qi In-Reply-To: <20251212055826.20929-1-kartikey406@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2025/12/12 13:58, Deepanshu Kartikey wrote: > Add validation in ocfs2_validate_inode_block() to check that if an > inode has OCFS2_HAS_REFCOUNT_FL set, it must also have a valid > i_refcount_loc. A corrupted filesystem image can have this inconsistent > state, which later triggers a BUG_ON in ocfs2_remove_refcount_tree() > when the inode is being wiped during unlink. > > Catch this corruption early during inode validation to fail gracefully > instead of crashing the kernel. > > Reported-by: syzbot+6d832e79d3efe1c46743@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=6d832e79d3efe1c46743 > Tested-by: syzbot+6d832e79d3efe1c46743@syzkaller.appspotmail.com > Link: https://lore.kernel.org/all/20251208084407.3021466-1-kartikey406@gmail.com/T/ [v1] > Link: https://lore.kernel.org/all/20251212045646.9988-1-kartikey406@gmail.com/T/ [v2] > Signed-off-by: Deepanshu Kartikey Reviewed-by: Joseph Qi > --- > v3: Use le16_to_cpu() for consistency with other checks (Joseph Qi) > v2: Shortened error message to fix line length (Heming Zhao) > --- > fs/ocfs2/inode.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c > index 78f81950c9ee..1019ca80760c 100644 > --- a/fs/ocfs2/inode.c > +++ b/fs/ocfs2/inode.c > @@ -1484,6 +1484,13 @@ int ocfs2_validate_inode_block(struct super_block *sb, > goto bail; > } > > + if ((le16_to_cpu(di->i_dyn_features) & OCFS2_HAS_REFCOUNT_FL) && > + !di->i_refcount_loc) { > + rc = ocfs2_error(sb, "Inode #%llu has refcount flag but no i_refcount_loc\n", > + (unsigned long long)bh->b_blocknr); > + goto bail; > + } > + > rc = 0; > > bail: