From nobody Sat Feb 7 09:59:29 2026 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (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 AE58D2F83A7 for ; Wed, 31 Dec 2025 07:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767167536; cv=none; b=TiIqN1IYIKf4kmiBcyfUEaMIwVDP8MMixpnOZ8fzN03SMz5CqC2aQptWrUGbRt/Wwc/fk7TFA89kVTQ3yS69Tk9Adbhyc2084qIPMGBf28mjY2/gIBD144lDNXkpt7wZSuHm0pO86br4WyP+J7OuqpJc2+HatRy2RbB9st+/Zsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767167536; c=relaxed/simple; bh=OjuWSO5R6mFhMH+uWX0lmj30pRXlyMTb4xzrnMFJVjs=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=MlFMSJKc3QQaiWnJaC/9vPoQNxf3JWv5EuNrot+zEhLLLfYqGYWCG+FMZyAMirSTKwtE9xB6P7tLPF9M4S/QNuQmYKS1XSXI+Qv3XnseSUKhjJ7gTSm88tMOUNJBcheX8LL6nmXnpO2mXSKM7N8FjlDDm+IQ1PFtfhFBfx1CA9E= 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.167.198 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-oi1-f198.google.com with SMTP id 5614622812f47-450d5d26c0fso12327432b6e.3 for ; Tue, 30 Dec 2025 23:52:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767167533; x=1767772333; 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=bUSCapPwJaKA7AMsCmxCjpSt9JA1xbtV8sa4axaEupU=; b=JDJnCLKs9fxq0Z34fhAquL8fg+AESHT2x9rrkGUvdrzzC0MRpjsB3hEbIwDNKNwhCM ZQf5/6n+inW7NKiDWCqeZFFhLwhRnkYggmLoWukdTaioNVOku5xVf5hYQAxjhO+A/Yv9 H2GjyLYTLOzYXDkE3SWIpkOTccCVhR+vtvbKi91kEOUnoIX0Jbs8rSGu0khgz4HdTx97 B8fRbxuOCW3bpIrtv/rK1/3BYX+D9LY9Z3ZbnweRJUmkYoN8EHoaNu16spd1YIyQhfNl SGmZH+acJ6vnw8EsGXWo0ho41opi8STf1/pxtZcbk5nqQRvrm/SAw58jc1CMWlIigmYc 3YUQ== X-Gm-Message-State: AOJu0YxnGGZUwBT5Iu2Rhb3YctTGYoyBncLz8YVRzlw1Wkvn7ugMdPtv wREYabD1lK23QptroXzHo/Q3gtGFSjCw0BqGQ46o4d2bR7Hpn2uW55TIoWbK1wGqZ2Iwzd1wlam 0mGXz8fH47eOa4+Yt2eYrmFCGDShDDtAczgizWhdAn0ZD+L4cvG1nMYObuuI= X-Google-Smtp-Source: AGHT+IFxkyT6gy+PdpB9ynIU0GZBOBAtoohW9A05EKU41kZwhk0bQP2z3W+9XjQe3IafA6Tl7nyGaIP+XUY8OP6m+7qw6VtuiqtJ 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:f028:b0:659:9a49:8df6 with SMTP id 006d021491bc7-65d0eb53f79mr17948571eaf.56.1767167533663; Tue, 30 Dec 2025 23:52:13 -0800 (PST) Date: Tue, 30 Dec 2025 23:52:13 -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: <6954d62d.050a0220.a1b6.0315.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() 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