From nobody Sun Feb 8 04:12:43 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 DE0BB2494FF for ; Sat, 10 Jan 2026 05:44:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768023894; cv=none; b=bschOr6+K7ydvljEWu8t2+DedmLXFpWFsQhW/87DInSADJd6tnCD5juss6Lj8f3JHG9AyMVprD8pg3Y0H8KXo9dirIE7AsqwjloQbnXqjayT+kFJjvoQeDA9mmNA+aywAB6nyHPnwxMCBDUtEOCUmdLIx9Ij+jOY1q+QZRJ+qQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768023894; c=relaxed/simple; bh=qjXsV1fXF5mWIQD1Y6+NHCIHSXg93dSjO27lRy6uUHI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=LWSu0weOFTIHnviafGiyCcpmaUryZ+MLU6eHETpaH0KP3jPtUQWVYg5kMfVATTAupLWSmJxBO0neo2l26oUcm1RTvkjDPqIWZIPDzicq8oZD+v8cNf0uLO6FGUTZ/XRrCimB3AQdmGePXaUWwlg5DxmK8Yil8MO4POWGo6uJl74= 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=FE00FqBj; arc=none smtp.client-ip=209.85.216.48 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="FE00FqBj" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-34cf1e31f85so3055371a91.1 for ; Fri, 09 Jan 2026 21:44:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768023892; x=1768628692; 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=Z68BN0cZI5QOdu/wL2wyS5FUbf7T2hnqvJbeV5WVky4=; b=FE00FqBjDUJCGea3NBEmYRj9vpfcbnY6pvZSrVc2RsveInykwvX8Gv9+YzEAdbd2Ax CsZUiKaGC/fTwjaIX8t3BvJfPpdeM2A/JwmMpNLPe+EsTKRYA6lLDN5T4qK70AFwq05Y Ps1ZAY5B7Z59m20UGEfAgHbKmJ5PPnm7ZPWborFouMbEs03OSaQbvZGvMZQLf1uR9Kel YV7/a2d4iO6XV5x8Z4UxXZfWhP1FgyocEWyqnrox2g2y7Kpf+h56nq5NJQGTl+Ztafvc jv4hFuh+HG94n5E8vSG6wnMhzimXqFTMj/u5lXBlppigGu1AVVGm5GhKj56v0O98UpAR J/Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768023892; x=1768628692; 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=Z68BN0cZI5QOdu/wL2wyS5FUbf7T2hnqvJbeV5WVky4=; b=P3nDruB5enKEdOI0Hw2eCx2OYndoV/IHUV5K8pAWWte0lCr+9PyCb07ZMHLvyVdwlv rU0gXraJJMfP/+rTSk11bnyqmSG+zDR46wxUr2vwantN3UYP4CRFdstbkVCTNphMIpAP d7upxAWI+pRROjDd/ODdbTva97odVtpBCOSxfgTRaFZghTU5+TxWtXhUztP/aadymaAI +sr0GZThXnK7ittf8ycFeU5U0kqzhYjRpw+OpKlnbyYdNiSQLqz991P/QmcAdE+DGefQ nxSN5khT2B4UQaG4pElFhmmhQQJqtuUQYAW0JJrIPOygl6gn9xv3Yh2tG3vvLxa7tazp XEkw== X-Forwarded-Encrypted: i=1; AJvYcCVRNS9SdqEvOnBWRs7wzgZ/DDTAYhOcvGQNIu+L4aEbyvg+sJ1DfAYU9SXlsNGZXMT55jHJ1rxN95rluj0=@vger.kernel.org X-Gm-Message-State: AOJu0YxlJF6TTP7L6XBGP+5+/xa1NASue+wnb6kZO+so1tad5r9rW0YC VOJIPyFc4K5omHnNV4ENa2zWCFtyrsI9mchLMgKEaB3h7nmoiOu+Xwvl X-Gm-Gg: AY/fxX6kAx4fUXxx5TwvfIOEr5pxWAVSAWP+roq+3Et7gjakOZvDsMJfGV0vZ1I63tD CZgANYNg/uTDtYqpb4llNme8xU3XmII6+7bvRfq0B8WZQok013JdeWdN9AgftLw88aHu7W1cyfU olNPdKeUI+CiJgmTQz/JR1CNGdr+qR3/Jlmc1ZydgUHtlO4ZbKDVvAgUhGIXS4f0wh6S6MoAkWB WeV2kjmvLMQ1Lote1IcJGFIaqHZeWO5C3ASVNzCMMxfi1JpLPx6fqjRgPhrzCZLSCSs/Qjc16hC gS410MlTaCdybmlrbAlMCFs9WGR+mKLZPKfkMWwV3SPlgWCVIEx5LAjgiyLAh2Z/N6NIpAUoHKP mtBAICfDAaiQYiGP1PaNPbGFGSax78gBJTMk6vHFL9mt9JCmKFyfnYm8NjFEgucVzsYltVJSqgC bf/gpgmIDyJfE3v7RYan543ZFILl72ZaJ6d9n0a8NWYKO0L9i2Gib2HfwdHZF4G4Cc2u0= X-Google-Smtp-Source: AGHT+IHt4ahIAGUhI8Zd0S/hBWvFKtfcny7KZw1sYUfxMZ2BkCeyItEV4H34gSk1f1CpeVUJNiZdUg== X-Received: by 2002:a17:90b:2587:b0:340:c179:365a with SMTP id 98e67ed59e1d1-34f68a29d18mr10132869a91.0.1768023891988; Fri, 09 Jan 2026 21:44:51 -0800 (PST) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:3fae:1049:5d45:ed6a]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34f6b29e117sm4221799a91.2.2026.01.09.21.44.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 21:44:51 -0800 (PST) From: Deepanshu Kartikey To: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Deepanshu Kartikey , syzbot+44c564a3cb08605f34a1@syzkaller.appspotmail.com Subject: [PATCH v2] ocfs2: validate allocator type to prevent BUG_ON in ocfs2_block_group_search Date: Sat, 10 Jan 2026 11:14:43 +0530 Message-ID: <20260110054443.604944-1-kartikey406@gmail.com> X-Mailer: git-send-email 2.43.0 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" ocfs2_is_cluster_bitmap() checks whether an inode is the global bitmap by comparing ip_blkno with osb->bitmap_blkno. A corrupted filesystem can have either the superblock's bitmap_blkno field corrupted to point to the inode allocator block, or the inode allocator's i_blkno field corrupted to match bitmap_blkno. In either case, ocfs2_is_cluster_bitmap() returns true for the inode allocator. When the code later calls ocfs2_block_group_search(), it triggers BUG_ON(ocfs2_is_cluster_bitmap(inode)) causing a kernel panic. Call trace: ocfs2_block_group_search+0x1c7/0x2c0 fs/ocfs2/suballoc.c:1611 ocfs2_search_chain+0x38a/0x1010 fs/ocfs2/suballoc.c:1764 ocfs2_claim_suballoc_bits+0x3a4/0x650 fs/ocfs2/suballoc.c:1978 ocfs2_claim_new_inode+0x95/0x130 fs/ocfs2/suballoc.c:2137 ocfs2_mknod_locked+0x129/0x510 fs/ocfs2/namei.c:568 ocfs2_mknod+0x5c7/0x11d0 fs/ocfs2/namei.c:802 ocfs2_create+0x136/0x170 fs/ocfs2/namei.c:852 Add validation in ocfs2_reserve_suballoc_bits() to check that the allocator inode type matches the expected type: - Global bitmap allocator must be the cluster bitmap - Other allocators (inode, extent) must NOT be the cluster bitmap This follows the existing pattern of validating OCFS2_CHAIN_FL in the same function and uses ocfs2_error() for graceful error handling. Reported-by: syzbot+44c564a3cb08605f34a1@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D44c564a3cb08605f34a1 Tested-by: syzbot+44c564a3cb08605f34a1@syzkaller.appspotmail.com Link: https://lore.kernel.org/all/20260104014028.305029-1-kartikey406@gmail= .com/T/ [v1] Signed-off-by: Deepanshu Kartikey --- v2: Fix commit message - ocfs2_is_cluster_bitmap() checks ip_blkno against bitmap_blkno, not a flag (Joseph Qi) --- fs/ocfs2/suballoc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 8e6e5235b30c..fb72c062a8d5 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c @@ -813,6 +813,26 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_su= per *osb, goto bail; } =20 + /* + * Validate allocator type matches expected bitmap type. + * Global bitmap must have BITMAP flag, other allocators must not. + * This prevents a corrupted filesystem from triggering BUG_ON + * in ocfs2_block_group_search() or ocfs2_cluster_group_search(). + */ + if (type =3D=3D GLOBAL_BITMAP_SYSTEM_INODE) { + if (!ocfs2_is_cluster_bitmap(alloc_inode)) { + status =3D ocfs2_error(alloc_inode->i_sb, + "Global bitmap %llu missing bitmap flag\n", + (unsigned long long)le64_to_cpu(fe->i_blkno)); + goto bail; + } + } else if (ocfs2_is_cluster_bitmap(alloc_inode)) { + status =3D ocfs2_error(alloc_inode->i_sb, + "Allocator %llu has invalid bitmap flag\n", + (unsigned long long)le64_to_cpu(fe->i_blkno)); + goto bail; + } + free_bits =3D le32_to_cpu(fe->id1.bitmap1.i_total) - le32_to_cpu(fe->id1.bitmap1.i_used); =20 --=20 2.43.0