From nobody Sun Feb 8 15:34:48 2026 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 201892E92B3 for ; Fri, 12 Dec 2025 04:04:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765512251; cv=none; b=hhZaQABb9NWq0peqf4XsQFBCpwFOee+CaKjCA9ajhdhHmNe/37XAeprXyUS0zSaDWuKaB4LqI/TkuzS3208ZXfDC6pH3Sa3PufuTqjPi0pr23R0iG4yCVqfsLEcsNAX+8dmKk4pCtAfRyK715mKBGgpm/Ujh/3dmXFGqYR06Bdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765512251; c=relaxed/simple; bh=KdDZ6W3VRrAwMnJ2DhTgc8C7kWnotA8raPuWE0OaeRk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gkuJOK4fJtyxlVdrcHcJgACQPtd6Q2xGDnU9EwZrpgiS44CQiUNjtl8CIZXklkovZB+AF5QibND+FDKAHypLvMN4V3WF+2BsXtCzar/CsZ0Jcz2h0UGNg2eQY7Y37mpYGOZ6Dar2OQz/aw7Y2eZfaCSPxQdHhyLocDQB2yJ2L1w= 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=YUNFaSpp; arc=none smtp.client-ip=209.85.214.175 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="YUNFaSpp" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-297ec50477aso3361975ad.1 for ; Thu, 11 Dec 2025 20:04:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765512249; x=1766117049; 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=4Ya6S7/tWoBQ5tlm6IYlGn88u04M1bv/FGjazh0al2U=; b=YUNFaSpp8ApaR2lkvULAZOpFolLb0k+Nt2qVHBcvgdYeoTjMfRygKuwSKvcyfwAIvL N7gUnM0huDl3zdKbxYaNdTeg7EN2ed3mq2c0+3WerHYrQBkIqjWQM8ILTlmdj3knEIhD ZVqBAEPOUnKA92FDAeRW26OtFdYf8EDEJY7vWM6cUfW7uuYyov3Bc7krZ4B2ldI9Sb8D J/Xc51tM+Aj7oYVlQrWp2CDzpLh6AThqatha7bAWEF9UWT201zzTso8WsHqpme7tU9PY 1Nr9tQVq5b0cah27V5xw/m4IdurUu/fJtXb4SvzC2lRh4ITvjefewZdrNW63LqAGhcyu oO+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765512249; x=1766117049; 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=4Ya6S7/tWoBQ5tlm6IYlGn88u04M1bv/FGjazh0al2U=; b=qAXJfolB1oLwQaBsR69a6DpHRFEw5A98UgUkxOUL35Ft103tCYjbjeFxb46xFc7oPL ZZSxp3opL9S2LuJOIW8fTReps1vhHwt59muJg9fbvT4Md7sngyEpBy0e4qc1a78WKKtc CwRZ5OFOyWjg353p5bvzW6Xjz/4SlnGou3JetljdymDc77yuYaY/iMywgRn5cVXNoc+0 vdomUoClyPvt5DgJifn7Onqpe/OYfKFgq3Tz9qwuP15xkLfsL5KMkFxuh0nfVQWW6Nv2 N363SEssiuoYsX4eZkARapRmiJkj+OHjFFQzLeIOamJgQucLGRiSrPFGdCtpYWz7wzI1 UwKw== X-Forwarded-Encrypted: i=1; AJvYcCViFYaNHqzvcTMCz0WdSyOzVtl2CfmudEMtdvI+XtsnyUBBSdWDi1lqlGk9LTVGDGcavdIgkYql6jV3TPw=@vger.kernel.org X-Gm-Message-State: AOJu0YwNL4iW2YqlZpvUPUq7/OvjN04bxzDiXzNUmHBo7N+y4kbKM8x+ 5XEGDOocbPSQ5nRVA8/bcN7Q6JVt2V6hDQ4cc5/TWQZjaD88ADAIZqW3 X-Gm-Gg: AY/fxX4gH4v2GeWZEj4aZAGgNhtHccgouu1kAoJyVuP34IkTriGvyDTTO0Lcff3u6aH 4ddd4oQpGBCQFdp+C0qkyx1GYVPPlaMzD95Iy935yxt70mFS/W92TWbQqSxsGHBJNGX1KFEsg4R 5x8eM2LMBqt4CTcvaVBEI4VroTYNiRVms+TLa4DJHr45eAx6XazHjafm+G08m7MJ8vsu4FhvC+y FJx050qwUKA39RVeq4z0Cbg+J0E8grhRB7XOcX2+QFtzW1AiL5puUdoVqhDT+JTARfu5bcwHjlX DYQVWbSeWp23jCv/RxEbEXOd1du/4IOHNBXRYx47eV3JkyWjuyuNnyM3q9hsglbhGmeY0FPfbu3 EzUQI9X65friHwViPmorAcNX44HuAtmjFNglXGV4Yz8pQgJV/8ppinxpwP/HR4dtizCKWvq3udE /1neiFZvTTwKHk3RT9GE8x9hSs59iawFUs2JORLdcCpk7KXah7JlC1eqzHZl+T8loCCQ== X-Google-Smtp-Source: AGHT+IFfW5AV/DoTBRTZbv83eJQ4iRTeVwQvR1CH731mPh4G85inpcR/toLkcas9Z6gZklPDTYFTGQ== X-Received: by 2002:a17:902:f60a:b0:297:e1f5:190b with SMTP id d9443c01a7336-29eeebf3167mr45838765ad.22.1765512249300; Thu, 11 Dec 2025 20:04:09 -0800 (PST) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:754:daba:87be:a6b2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29ee9b376e2sm39346985ad.14.2025.12.11.20.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 20:04:08 -0800 (PST) From: Deepanshu Kartikey To: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, heming.zhao@suse.com Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Deepanshu Kartikey , syzbot+c897823f699449cc3eb4@syzkaller.appspotmail.com Subject: [PATCH v2] ocfs2: validate inline data i_size during inode read Date: Fri, 12 Dec 2025 09:34:00 +0530 Message-ID: <20251212040400.6377-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" When reading an inode from disk, ocfs2_validate_inode_block() performs various sanity checks but does not validate the size of inline data. If the filesystem is corrupted, an inode's i_size can exceed the actual inline data capacity (id_count). This causes ocfs2_dir_foreach_blk_id() to iterate beyond the inline data buffer, triggering a use-after-free when accessing directory entries from freed memory. In the syzbot report: - i_size was 1099511627576 bytes (~1TB) - Actual inline data capacity (id_count) is typically <256 bytes - A garbage rec_len (54648) caused ctx->pos to jump out of bounds - This triggered a UAF in ocfs2_check_dir_entry() Fix by adding a validation check in ocfs2_validate_inode_block() to ensure inodes with inline data have i_size <=3D id_count. This catches the corruption early during inode read and prevents all downstream code from operating on invalid data. Reported-by: syzbot+c897823f699449cc3eb4@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dc897823f699449cc3eb4 Tested-by: syzbot+c897823f699449cc3eb4@syzkaller.appspotmail.com Signed-off-by: Deepanshu Kartikey --- v2: - Removed unnecessary S_ISDIR() check since OCFS2_INLINE_DATA_FL applies to both directories and regular files (Heming Zhao) - Fixed checkpatch.pl warnings - Updated commit message to say "inline data" instead of "inline directory" --- fs/ocfs2/inode.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 8340525e5589..1fac457cb04a 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c @@ -1521,6 +1521,23 @@ int ocfs2_validate_inode_block(struct super_block *s= b, } } =20 + /* + * Validate inline data size. If the inode has inline data, + * i_size must not exceed the inline data capacity. + */ + if (di->i_dyn_features & cpu_to_le16(OCFS2_INLINE_DATA_FL)) { + struct ocfs2_inline_data *data =3D &di->id2.i_data; + + if (le64_to_cpu(di->i_size) > le16_to_cpu(data->id_count)) { + rc =3D ocfs2_error(sb, + "Invalid dinode #%llu: inline data i_size %llu exceeds id_count %u\n= ", + (unsigned long long)bh->b_blocknr, + (unsigned long long)le64_to_cpu(di->i_size), + le16_to_cpu(data->id_count)); + goto bail; + } + } + rc =3D 0; =20 bail: --=20 2.43.0