From nobody Sat Feb 7 19:45:38 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 8224B1E1A17 for ; Sun, 4 Jan 2026 01:40:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767490839; cv=none; b=ehMMV7Ilm54thXjtaHHfOCVk8OsQxDJW9A/+u9HhNNZThX3OFYeL9JjIV7p6FcArFtKdeB69KPTB14FkKhueeWOAaRFrpJgFmFEXEZkaq0ZCwxJjg4C9OMjbf9fLXn9o2PXivGoWYOClSLzzabv+WVAq4Uo5GwmEBEpc+9L4txc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767490839; c=relaxed/simple; bh=y7/MyBJ/9luYBjLqkeIXsQQJWFW1iw7+OxRG6AiXpEY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mDCcmVYcemyjpBLFfDb7eboDhRl2wgu3/fQGOAWF8WfF+KyfFHQhrfCrH9P8Znj3iOPvPRAGnD2umAvKXdKbSGTKyiAbCYTniLjGxA+nF9HTnQFQWKCmCHCBnzev6G9+xMphti92Iukey/0mWg4UUJzZs4ZNwszr+YPrvXmJJhI= 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=WDjmb7Xa; arc=none smtp.client-ip=209.85.214.177 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="WDjmb7Xa" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2a0d5c365ceso173768705ad.3 for ; Sat, 03 Jan 2026 17:40:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767490838; x=1768095638; 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=u/tXdSO3fVx76Ok1kJAIyCPe7HRmB+07nRH72tLtOlU=; b=WDjmb7Xa1vaRIDKOuIVmOxjssCLBw55jN/j9DREyfo+TcW+PiqauAvsY8Bm2j8HwwM rTrOyTgqj7UAy/+MG8pm8+E695UF/Py5HaKxS5fUaNEKShThibXghXf8ikzqiFtejO0l X0UEUpxDJPaLY6tCL9lSsMAol1EB6ZXjvrzW20BUhMhQcARkl0pUuPzlLwpHF4NbmLcU aEvZt8tvsP5qcYAe35cHSIG/0B0kPH0+ylhAYIdfe58CCxP6jcLr/DiZk0EMtyUgELsi HmbDtQ2GHf97XtRJgo4iPjx3EA5Cz1VH1a3QpxHv2PIM+zALU2Sfn0IJF7UljKNYpzUl 2xuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767490838; x=1768095638; 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=u/tXdSO3fVx76Ok1kJAIyCPe7HRmB+07nRH72tLtOlU=; b=iplQ9+sAU/t1bk/EZtDXjLQgzTNpCRGE/BQd6uEbTLNaHRcmwmKTGIpiHOYCGkVYQ6 5JYfIKYkr6tVm7/67RS+0srHgpYOB1yhlcBdvcEOSrsm/z3aD5KSSEib5+mX818zCTPS IX2+4pUqAsK3L/s9wvItdlPHcXkz4HkaV5MlN/RiTQtRfBbHatQo4gapBzigmEbuoyh0 uGLHZEi11wBHc9z2XabUf/qWowr7e5bchqNwQcUy+kGWVgu9qH6FL6Jz8jf/0TUoYwo3 xUoEe67ktImSIcfK+agJ0FDdgr5oZEvtVyIB5k+/WuRAsAsG6Z2h+r0Ihkyp3dVvfzMH L4Ug== X-Forwarded-Encrypted: i=1; AJvYcCXUiVuQTeKjxAcu4XYp5/SaXRp+TCuXsewPsIVdX0lk0vFBcygSoi78Xrjp/QnVUkG65y2eUdSXgckXSrI=@vger.kernel.org X-Gm-Message-State: AOJu0YwHY9G2kzDf8QJAzUDqI/gR7TdTlH+jLVz1dF/7/uU0Ood6p9Pv DWaaXBAqLnpWWpzClochzrfFO+0il2jyTbHy9mvn50fJc7dTN84jrye3 X-Gm-Gg: AY/fxX7WvzZEirOmZpuBZcAtPonMeQ0T6Z7ArM6Ajy7Ms9w2I3qlRK1vJzYgy1gPdfo 2JC28rzJt1JtjpfnjV5mwhkqjUtAJcuzBMDbapdiIJBaQOx+RBA8Sbn1FxyF7RlnSknKh/L6ArQ kumOJUVj+27pip0RGN3TxbhzZ8+a7pqSr4BdX3bOowJEHff0OwPWolvHQpkVY8RNMJxMSJeZOfl kM73w+wTlU8/BjQu9WkjYi1uMRC/7GZzTq/Rq7rqrBsux/7CsEIM1nFdUZ69yWu4sovlyifuYTU zww6tK/JqT57AqPfs9oZfy1IQ3e6MfyrhcM+bsaUB1lWYQKaAszVuP0sybXCbIexu0rl8COm6uE EZYsJXEg4gzicY2kdhzpSYwCwcxr+al4PHXmf4n7CKbSTtfALkgnTLCiMWXHgF2nxIGmV2sNbah W7/QfNS8G/pJPzivnr4JXgfI9UYDK014HaRLh5FVzlzy2un8OIk46gDf5lUhNasO4qVsw= X-Google-Smtp-Source: AGHT+IHXVUVm6YVAUnC0nMuF0Hqoyzfgg7VE2iGfV1T56h0OA80JwuYzPsH3OTKdGoZ1FH7DMWcazw== X-Received: by 2002:a17:903:38c7:b0:2a0:c1ca:20f7 with SMTP id d9443c01a7336-2a2f2214973mr418825005ad.15.1767490837646; Sat, 03 Jan 2026 17:40:37 -0800 (PST) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:273c:63ea:24a7:bc91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a2f3c83325sm416486585ad.34.2026.01.03.17.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Jan 2026 17:40:36 -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] ocfs2: validate allocator type to prevent BUG_ON in ocfs2_block_group_search Date: Sun, 4 Jan 2026 07:10:28 +0530 Message-ID: <20260104014028.305029-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" A corrupted filesystem image can have an inode allocator with the OCFS2_BITMAP_FL flag incorrectly set, making ocfs2_is_cluster_bitmap() return true. 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 have OCFS2_BITMAP_FL flag set - Other allocators (inode, extent) must NOT have OCFS2_BITMAP_FL set 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 Signed-off-by: Deepanshu Kartikey --- 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