From nobody Mon Dec 1 22:05:07 2025 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1FF01DFDB8 for ; Sun, 30 Nov 2025 10:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764499621; cv=none; b=oaqjgiO9qtzqNPWx9zCoNEBo6Oq+FXWspSEmb0VHanTz182q1mmdFWFiMMJtVPAFiEOFMRQtgQS4KQLrUhLp2IBX9FBMRobNE9LOJkr0Nk34kkM0ZsbTGzvb6BFCiWzB3TEqjfxtZ3rGjsLa3K8ofkxKo4EnafIg80FVzz2kztI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764499621; c=relaxed/simple; bh=rlIrI/UmoKYEL0vlVjf1XS3AzQOskSjVa2f/87hoTwQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Q0SiTJ3LlONfzZx27zcDpUWbAcIOzbZBaRyjYajdY18VV7RXzPHq5HOGPM8kjMM2QdkFU21UsrUQ+Ey/3SxireZEjFBov3wu9VWYOyrFQ0415IesBnZUKokk3EIxGWXqzvzprOrbE1aG2tlTd4Ft66OaGZB4W5VihWyHk0GndJs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y6uchbDi; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y6uchbDi" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-29853ec5b8cso39494835ad.3 for ; Sun, 30 Nov 2025 02:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764499619; x=1765104419; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qTNLxP/M5VH8d16ArvNC5jrTL5Ks/32ppFB8c0OA9Rk=; b=Y6uchbDiB4uvfX6+LRmJXtOvsJHNYqXKpFZZLCXKcTYTVwjbLmgAjtC9iBLC48satq dRJxCQmUV1XlxvxV+Ixv0u1E/3QFcQrQ8f+NDGBaQNaYGG8p0yso2xqCvDm0IEzM80h7 AWSNZEUDzMmeVXGqa/61EH4pZqzW9Ld+BaMjJmjLMKx31n9tpi2W98CyiOly9vrVsdBR 8Isp68uhwD32sykuGtTrnfrKs3iuGvxkWCUFPO6QB+w2RC4aQwPA1KNAL/E+iaPBsFFf wZF/rtJjGX8Bik+dA9pMzrGf5plvDrglziaPQ3Q7jl21irh40Ep2u6cibLLdtH9+nCVQ uq7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764499619; x=1765104419; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qTNLxP/M5VH8d16ArvNC5jrTL5Ks/32ppFB8c0OA9Rk=; b=aNOoasKkzZ96SRv1mrZbvt1l5olEO7yVFDNDam6KEww/LG1I+LydPH6h6X47IM/pF/ kjHkwTmkzCrOu9PcNYzhOberhrTp/wz2yypD240RTiuNPNg4n2GmEbGuDXGaVzUhSFlI qFVHdyTXfK8tUTFPP5ik4J0AjCCTBunbgrMy93XO7FlakZMkF+0glVut6voFdRjHtJPI RVR3phVDT5zuYbkY8DbXhmC6pceLPx/+uP1f1Cudl3NqV2ZhhZKlQnzGTq0ioQPHwHaL rnE6ryqKIKXjFIwBVv8/2KT0JxC4rPyUgZsq3MMTWkXSwKFfbAdrn92bIo9hXgwqQw12 n26g== X-Forwarded-Encrypted: i=1; AJvYcCW5sNmRAOtj4/OY3yK46UNiLllyfS4QlKAXXthwajtak46TADoUyVFmi4XL+AIbQ7ZPXAEZkHu91X8Wtq8=@vger.kernel.org X-Gm-Message-State: AOJu0YyjLCfTn4ncLJw9s46FfKmWsADfgJY6EQg7YAiEv48/9MiPE6Hs grb1DS4SCr3QbcSJdl9JNxW/6e44AUkrMmTK4tdpLeIpYMq/2qmp+V6R X-Gm-Gg: ASbGncu2FDOCfMVV3ozfclALme7r2Ksct2XExLc0nWQIUr+PVEtjIaDh/iT661g9k1J 7wCxFIwc97kp8v0F+0HI+0J6/5w8Vwvtzx3rBQpOB9fEP6pywNqkMyqcjhhLExLYt0Nk2AncBx6 JT9ZBZN5htGdaVivGSAkWxH2J0xdwB/f+vYOMV4G9Xi/h4OwX3llBVqOp+crnCGi9qkEixqJjF5 PvrisSt1mXXWJGO+CfPtdR6yVeU0KyI+Mh6FF5gyWpwm88iCC6CvTc5TeiYVNXDC15x2GX8iXG8 zU4so+YLtceFF76gNZfHlP6dtX6Eb76KDsQapWkZO0RcE26Dg3U8k+rzE7TVMBoEBftqHNT0bfN vMe+JO/VawvoGdTF3QeqoMZqe5ix8+U5XJmOKB2Tp9urDYKG3NPYctrCf5xW9sdsaBTAGPugWSy ngl0wVm0o/IRrq/Pil+3eq5IPZSWU= X-Google-Smtp-Source: AGHT+IERaLvmsksXdm4uqqeOPDAGOjVLAPcWW+DVufQ2i3ULjffRh0sjXfMbZt3b4sdgIKb56s8bhw== X-Received: by 2002:a17:903:2b07:b0:290:c94b:8381 with SMTP id d9443c01a7336-29b6c3db606mr396664675ad.7.1764499618952; Sun, 30 Nov 2025 02:46:58 -0800 (PST) Received: from localhost.localdomain ([114.79.136.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29bceb471c6sm91492475ad.79.2025.11.30.02.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Nov 2025 02:46:58 -0800 (PST) From: Prithvi Tambewagh To: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org, david.hunter.linux@gmail.com, khalid@kernel.org, Prithvi Tambewagh , syzbot+96d38c6e1655c1420a72@syzkaller.appspotmail.com, stable@vger.kernel.org Subject: [PATCH] fs: ocfs2: fix kernel BUG in ocfs2_find_victim_chain Date: Sun, 30 Nov 2025 16:16:37 +0530 Message-Id: <20251130104637.264258-1-activprithvi@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" syzbot reported a kernel BUG in ocfs2_find_victim_chain() because the `cl_next_free_rec` field of the allocation chain list is 0, triggring the BUG_ON(!cl->cl_next_free_rec) condition and panicking the kernel. To fix this, `cl_next_free_rec` is checked inside the caller of ocfs2_find_victim_chain() i.e. ocfs2_claim_suballoc_bits() and if it is equal to 0, ocfs2_error() is called, to log the corruption and force the filesystem into read-only mode, to prevent further damage. Reported-by: syzbot+96d38c6e1655c1420a72@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D96d38c6e1655c1420a72 Tested-by: syzbot+96d38c6e1655c1420a72@syzkaller.appspotmail.com Cc: stable@vger.kernel.org Signed-off-by: Prithvi Tambewagh --- fs/ocfs2/suballoc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 6ac4dcd54588..84bb2d11c2aa 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -1993,6 +1993,13 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_al= loc_context *ac, =20 cl =3D (struct ocfs2_chain_list *) &fe->id2.i_chain; =20 + if (le16_to_cpu(cl->cl_next_free_rec) =3D=3D 0) { + status =3D ocfs2_error(ac->ac_inode->i_sb, + "Chain allocator dinode %llu has 0 chains\n", + (unsigned long long)le64_to_cpu(fe->i_blkno)); + goto bail; + } + victim =3D ocfs2_find_victim_chain(cl); ac->ac_chain =3D victim; =20 base-commit: 939f15e640f193616691d3bcde0089760e75b0d3 --=20 2.34.1