From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2C9EB3C1FFD; Thu, 15 Jan 2026 17:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768498093; cv=none; b=eHLqOTrmZu5oo83SthzKdG1XGTEQ7/HYdWFdcr50D+MN5prPdwjUwWnj+g4/1xxT8YPZILprrdp9yHfJkIO7Dmdu8pGJRuIyhA19jlV3oQ/GUsLxdV3UxB1KH66ENtEUc98tX1xunLhnnmglztZ2z2gVNsoeClkshsPak1hDwQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768498093; c=relaxed/simple; bh=I9QFJGD6c7hH8hqpu9W9pvvzE7BvgaVGh4wYANvX39s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f2R+I55ZMD6A0ua7n7NIkSEjavrUZueLMgdQY4L00tFInrDMTsOZTtx8w+L5v20f9sa7lrW/4kbmK23kNgwugqUGzSoC1lfi6RxDuI50P2VCed+rBMp4NUg4Yboo6nFT6HGAo2xjL75lEtNDvP26E6/qF9bJy1Fds+9qA2YQTjI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IIVz0nut; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IIVz0nut" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51E6DC116D0; Thu, 15 Jan 2026 17:28:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768498092; bh=I9QFJGD6c7hH8hqpu9W9pvvzE7BvgaVGh4wYANvX39s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IIVz0nutfNXUIbT+qjC9eUZkRat4i/CEQVqXVnaD6HYGe6GEVaK6R0wk6xo2ZpP3o KWILS6Unr8uvYc/61fT+Urto6wJ6Be22OOKlZtsHsF0QJ4yPicIFj10H8RwM9QVacT 7RMd1OUEoHV3vt4b4rK4G6x7N7eAt8Aw0Xqb9q6s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Prithvi Tambewagh , syzbot+96d38c6e1655c1420a72@syzkaller.appspotmail.com, Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Jun Piao , Heming Zhao , Andrew Morton Subject: [PATCH 5.15 309/554] ocfs2: fix kernel BUG in ocfs2_find_victim_chain Date: Thu, 15 Jan 2026 17:46:15 +0100 Message-ID: <20260115164257.416856957@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164246.225995385@linuxfoundation.org> References: <20260115164246.225995385@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Prithvi Tambewagh commit 039bef30e320827bac8990c9f29d2a68cd8adb5f upstream. syzbot reported a kernel BUG in ocfs2_find_victim_chain() because the `cl_next_free_rec` field of the allocation chain list (next free slot in the chain list) is 0, triggring the BUG_ON(!cl->cl_next_free_rec) condition in ocfs2_find_victim_chain() and panicking the kernel. To fix this, an if condition is introduced in ocfs2_claim_suballoc_bits(), just before calling ocfs2_find_victim_chain(), the code block in it being executed when either of the following conditions is true: 1. `cl_next_free_rec` is equal to 0, indicating that there are no free chains in the allocation chain list 2. `cl_next_free_rec` is greater than `cl_count` (the total number of chains in the allocation chain list) Either of them being true is indicative of the fact that there are no chains left for usage. This is addressed using ocfs2_error(), which prints the error log for debugging purposes, rather than panicking the kernel. Link: https://lkml.kernel.org/r/20251201130711.143900-1-activprithvi@gmail.com Signed-off-by: Prithvi Tambewagh Reported-by: syzbot+96d38c6e1655c1420a72@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=96d38c6e1655c1420a72 Tested-by: syzbot+96d38c6e1655c1420a72@syzkaller.appspotmail.com Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Jun Piao Cc: Heming Zhao Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/suballoc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -1923,6 +1923,16 @@ static int ocfs2_claim_suballoc_bits(str } cl = (struct ocfs2_chain_list *) &fe->id2.i_chain; + if (!le16_to_cpu(cl->cl_next_free_rec) || + le16_to_cpu(cl->cl_next_free_rec) > le16_to_cpu(cl->cl_count)) { + status = ocfs2_error(ac->ac_inode->i_sb, + "Chain allocator dinode %llu has invalid next " + "free chain record %u, but only %u total\n", + (unsigned long long)le64_to_cpu(fe->i_blkno), + le16_to_cpu(cl->cl_next_free_rec), + le16_to_cpu(cl->cl_count)); + goto bail; + } victim = ocfs2_find_victim_chain(cl); ac->ac_chain = victim;