From nobody Sat Feb 7 09:59:02 2026 Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.72]) (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 0A8362C1585 for ; Sun, 4 Jan 2026 12:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767529585; cv=none; b=kNeS1cM02zAl5dD1Z1xYBu9wA2coiKlj6aE+xKZ6ybhX2E60hI4kIS2gQmGqD5fHJfjHILA4GXKpml0aU9uQc5wqiIJUVfsqIZ2XrU+bRa1nIzyQXR0Rf+VTL45pSzlWPXApl9LLtqVjRTlYZwPWVn+Qn9JmGUFqzZksQFQ0BbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767529585; c=relaxed/simple; bh=WW+bBTQtKpWdk7NQnG5oBDHa4p+oT8ad2pTCR/Tje2E=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=RSm8/kW4qFYcLqQVbKvVXSuLxkOyJZvrPfs6b3vZRAsXcJkVkOWkN1wC066gh0mHNSNxpqMX8MeEHmWYd8IdFGX31LDLYNeAr6wbE765Dgygz+dtyNmwSGPfOaJmDRKnXcvZc+qxfY3MvTA6duYyMfNlUBenttV/TCLBUikLcVQ= 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.160.72 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-oa1-f72.google.com with SMTP id 586e51a60fabf-3fef084337fso3897353fac.1 for ; Sun, 04 Jan 2026 04:26:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767529583; x=1768134383; 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=sZOnwfWMqSWGPUJCoUDVXGcEg0VM95ATIFIemt5UN6g=; b=g20Z5nmKTziPido5vzqm++ocmK66a918GzX6q7rDXvC09gPVEM8gtBV2xEjc1MIZCw NOGsIV/43p5gzT4jSfU8oVwI+Zlsyg2T3UBcIXCoK23stA4UJS4Ld+Mb0v/yhb/n3txC qj+lrFpHxfUVaATo2Fs1NrNi3hMPmqWz22spJKGvKwR5RBDUjH2Bc9DuGbUFilBTLIE0 TWBT966UfNtUycF4lyEu8wOboFY9VvgaDK8gNPcWuV//AjSw54vyfSG+zCNctfI5ryrT 6dOPhGgFTJ83CcQagJZDkH95DQfjlRm2gEm4xaehP3FS7eC0s4yjUUiQrQszxLi0fyxS 77nw== X-Gm-Message-State: AOJu0Yzlj3qh1N0aqx+Kyrm+whwbe96ticFWFL/4EapvE/RxOnpMScJU U+9QBz+2aDD5Q+a5+VZVisKuY2sltUOxZZfS51krqcDVgn96lnsVtDpMybngFZReSjC9uSIrfaC mMrBGNEX8k72O5lS/B4ak3Uu7bPu6JmC2z2nb5nY4CBU4OsAtk6GAU1UB3XU= X-Google-Smtp-Source: AGHT+IE8b7/nbo+274OiKCBM1rrmW3qbJx94UZmlM45jDXhHvWwCtoSyBGcb6JYy2r8dyqEsbKSN5eyMgSEmWerOVfVb9mxCYiVx Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a4a:df09:0:b0:65b:c34c:456a with SMTP id 006d021491bc7-65d0e9e8032mr15088892eaf.8.1767529582801; Sun, 04 Jan 2026 04:26:22 -0800 (PST) Date: Sun, 04 Jan 2026 04:26:22 -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: <695a5c6e.050a0220.a1b6.038c.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/torvalds/linux.git= 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() right after ocfs2_find_victim_alloc_group(), we return -ENOSPC gracefully instead of crashing the kernel. This also avoids unnecessary work in ocfs2_probe_alloc_group() and __ocfs2_move_extent() when the allocation will fail. Reported-by: syzbot+7960178e777909060224@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D7960178e777909060224 Link: https://lore.kernel.org/all/20251231115801.293726-1-kartikey406@gmail= .com/T/ [v1] Signed-off-by: Deepanshu Kartikey --- v2: - Fixed missing '<' in commit message (Joseph) - Moved check right after ocfs2_find_victim_alloc_group() to fail early and avoid unnecessary work (Joseph) --- fs/ocfs2/move_extents.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c index 99637e34d9da..c037fb34b1e3 100644 --- a/fs/ocfs2/move_extents.c +++ b/fs/ocfs2/move_extents.c @@ -662,6 +662,12 @@ static int ocfs2_move_extent(struct ocfs2_move_extents= _context *context, goto out_commit; } =20 + gd =3D (struct ocfs2_group_desc *)gd_bh->b_data; + if (le16_to_cpu(gd->bg_free_bits_count) < len) { + ret =3D -ENOSPC; + goto out_commit; + } + /* * probe the victim cluster group to find a proper * region to fit wanted movement, it even will perform @@ -682,7 +688,6 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_= context *context, goto out_commit; } =20 - gd =3D (struct ocfs2_group_desc *)gd_bh->b_data; ret =3D ocfs2_alloc_dinode_update_counts(gb_inode, handle, gb_bh, len, le16_to_cpu(gd->bg_chain)); if (ret) { --=20 2.43.0