From nobody Sat Feb 7 07:24:08 2026 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (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 EA84C3A1E82 for ; Wed, 31 Dec 2025 07:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767167470; cv=none; b=K47w+wueQN9iNPXSWOHqj5qDPngFZYXrhZFoYwncFBC1jfkEFF7nliEtXJN4P61qIuE8CEMXcvnfpRLwiypF2FLhHl14YFKXMXGusgpVT5Jj9q6413/d7GNHXEBZ+ZmWktO1WitwewLymFMQyNvgVCdRfk95RrrCkySr7nbEP6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767167470; c=relaxed/simple; bh=tmWmtvJWwBqo1O8EXtM6MwHD56J6Bh9EsvFZcTkWkkQ=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=e+T3YywANR99gza7QiP9g2EABM7q7KKeaAzVZHXgMM4e4QrjtA+HFgBgtQobfgLJLDHXU3g97zR0GnvBMjMAhHOjaK7RPQLBgMzk4yiT9vjN6xwEg1ZLW7sHCgaA9GxrJ1zTSEH2sMs3kqRegFihQ1MZzVchODEqPbqrY6ZxHxM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-7c765a491bdso11561156a34.2 for ; Tue, 30 Dec 2025 23:51:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767167467; x=1767772267; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NpcT7mMpXekba4HZU5EkdgVwxkH8+3ta0WuoKjpGBHM=; b=f54WAAt8K1N4tJBcfTJwsnPsQMzsSWMBS2RddJBSHZO7oCM0TecJtCtv9drnaBylWk nA6QFq0wIJacI7nOA7Syqy555PeIodKz4CEiO8xZ08Fr4DgAyIyHKIQVPuukqqwO/kcU bbe45UnkCyC9M3SlFjFCsOhWtaJCzTzGTohmPa8+0fbj0cO1oS7GeVQND7SaH25eIcAH b3Xe9p4kJJahjHByOZc0Fv0SlqmAEiGM67EgIVcspbapN593A9CcCXbnRHy1dTOnCCgH xcT1RJRQAHTTjZd8FzQPYzNkfa2zanCU6pwifkC89D1d0E6xlM53Pwm+kj7xjeO6ABJp xCAA== X-Gm-Message-State: AOJu0Yzc8Tj7Fr/qgDalq8gOYyYyIT0IKESKlXkismexZhgFu3P0ZhFj qxdbnTG5tKpQ79A8g2S3h50xVMUWs25MvRx+4KA90z+8ynkjrHPI5pkf9a0D9HyPZ7ObQz6Cc9L Kz5O287zw8hasYFAyKsqXoAr6CnBLH+yZrlMVoL7NeQYwl5A0VMQnvYlGZVE= X-Google-Smtp-Source: AGHT+IHLFvywhXJjAQZp1/SyXHz1mbtH0l5FeZdbzyXak59iS6Iv72y/qp5MUV7Q9WIpyWH2E5EW47YSpU3GdkL5wJ6+LBdk1yIs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:1ca1:b0:65b:387a:8362 with SMTP id 006d021491bc7-65d0eb56659mr16343585eaf.55.1767167466843; Tue, 30 Dec 2025 23:51:06 -0800 (PST) Date: Tue, 30 Dec 2025 23:51:06 -0800 In-Reply-To: <69441a92.a70a0220.207337.00e4.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6954d5ea.050a0220.a1b6.0314.GAE@google.com> Subject: Forwarded: [PATCH] ocfs2: add check for free bits before allocation in ocfs2_move_extent() From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] ocfs2: add check for free bits before allocation in ocfs2_= move_extent() Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.gi= t master Add a check to verify the group descriptor has enough free bits before attempting allocation in ocfs2_move_extent(). This prevents a kernel BUG_ON crash in ocfs2_block_group_set_bits() when the move_extents ioctl is called on a crafted or corrupted filesystem. The existing validation in ocfs2_validate_gd_self() only checks static metadata consistency (bg_free_bits_count <=3D bg_bits) when the descriptor is first read from disk. However, during move_extents operations, multiple allocations can exhaust the free bits count below the requested allocation size, triggering BUG_ON(le16_to_cpu(bg->bg_free_bits_count) num_bits). The debug trace shows the issue clearly: - Block group 32 validated with bg_free_bits_count=3D427 - Repeated allocations decreased count: 427 -> 171 -> 43 -> ... -> 1 - Final request for 2 bits with only 1 available triggers BUG_ON By adding an early check in ocfs2_move_extent() before calling ocfs2_block_group_set_bits(), we return -ENOSPC gracefully instead of crashing the kernel. Reported-by: syzbot+7960178e777909060224@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D7960178e777909060224 Signed-off-by: Deepanshu Kartikey --- fs/ocfs2/move_extents.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c index 99637e34d9da..2548a8908a1b 100644 --- a/fs/ocfs2/move_extents.c +++ b/fs/ocfs2/move_extents.c @@ -690,6 +690,11 @@ static int ocfs2_move_extent(struct ocfs2_move_extents= _context *context, goto out_commit; } =20 + if (le16_to_cpu(gd->bg_free_bits_count) < len) { + ret =3D -ENOSPC; + goto out_commit; + } + ret =3D ocfs2_block_group_set_bits(handle, gb_inode, gd, gd_bh, goal_bit, len, 0, 0); if (ret) { --=20 2.43.0