From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 BF73219E992 for ; Tue, 7 Jul 2026 01:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783389285; cv=none; b=cx5AyOvsQqV3lZhgzZ2GLenb5T+HuILNh0WhQrSOzmaADOo4baGP/proj4Eqhyb8MR2lgp7pZSW7qoB65TfFx9R4PeKOsMzQnPg19kGGbuRidvOrVjVNcgpuZ/skc4TDbtIsV+NiipzzK/okPY06qCPWRQRQijwEUxnVCL5yr2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783389285; c=relaxed/simple; bh=0VNxjwMBbTsaGDD/XsLcIDBGMzsr+w4yjDvYAEOxj4g=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FGmQ3UZkwJAueXtNuDYd5hrjD6yaBtbxnPeuYeI6hgKYBNcaN2t6/60W3f5Kd7Mu8zzBU/GhQbRXHFVZs0UBXlVU6rz/0F8nxLAysJCUFOLailLm6fJQxjR4713yX7ByvjJUKzjgV7lkp/CfC+jb5x2Ik5bX08cAHra9Y+caNjs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu; spf=pass smtp.mailfrom=asu.edu; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b=PHgojsjz; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b="PHgojsjz" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2cca0c5799eso15402515ad.0 for ; Mon, 06 Jul 2026 18:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu.edu; s=google; t=1783389283; x=1783994083; 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:content-type; bh=s6x0rchg7luTyAcY+EvagpUgJxh15LjPhci+G9ftIjQ=; b=PHgojsjzyW1dTCctrTMvzv5Y0QAQZ1AE35THJhUZwzltH5oHKW8BkM6P/HTBYrKsp4 AzrEqev6RmHfbusIUO5TSa9Z8GLAR4lqBvLFpuEC3WTZ3/XilzuI1RfSIXlj+l9/nZE/ PnRSj4QZQRFdh20lbt92NVocLzIrERVfhng4qkBYgQ8qLMgYVUY32t+quMo2FEKVehzO CcwI+/m+KdxKav4cX/RliNmjnvYS/fs0z74D3C1swmOPTe+iQdWYPqWfU6HBaGbU2z/N IBNt5usKCrxx+m7F86cNqh/HK6FT7lR/4AbAO++j72BXdV+juEAlnhBW1kj3s1NQxOdF PvCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783389283; x=1783994083; 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:content-type; bh=s6x0rchg7luTyAcY+EvagpUgJxh15LjPhci+G9ftIjQ=; b=lJ4ALlgz99XGHr/nT95Ua+Nk6nOXwfs5cOGUeWZc7GFBayHpaWvbpPzcpznGdkAXLl EOSFycQHtys/O0mtlXewZWxQ0bX6mPRQUbdUq6o/TFCUrtt4PmFnlRCg9IZrXSLnZE9z 4Ur6NRs1ewwoxS9wBzBKlnUiV2XJtFpPYd+UGoMlQ2UAiVD2lgNOBnwveprNlLBHinTg m8mp1Njv0uXdUhdpZVFczTdCLjO4LYO8XVKSlGzDa/54+A8S2slzugUwHi4XBOcN5QY6 Vkd5ElpbTsHIsXHPr4AlghxPVlTQ3N39w360F00Sx49RxD+xa5tXe/qYcOTFfQMQDSHS ysiA== X-Forwarded-Encrypted: i=1; AHgh+Rop4/v5j0cqyhqdmVlDDbjcbNvZ3UaZthIlh/XIVMjlwOSfo0X66yGgyNAspQRW7mW7dUOa3J/eDxKa2Rc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1ZY/cCFwI0q+AFL6uW49vRI8wQgiB8S/w7hQ5OJR9NZAIvdCy zAKXZggWaP4rC7CSq4tF+C8zmwn+RAIQp4kcYK+LrfIJRJark+ye9VSNF2ay8LDf6TZAe11I2R/ knps= X-Gm-Gg: AfdE7cl6jmkyQJppqZDatWa5ovAHZsMNu1qlcDg2B7MBWcQd1wWV2ZDnv3WsH5J5L1b LNR/vwieFiugjO7Y6+wnuTUib9cb/La2Sqa8CZVU3Uwb3NGuGGPw2IT7KF0lWDi4gqu/xvqOzMW xCPVYfCmmLXW2TwuEHLlHPiQwbRZp5Go0JT7i6pQUc3JKei1FZX1A6Fxnqt7hQjuhtlRkvGuTZL 7nui6NsFrqMqnGc25LN3QlO8RWlF5qiBMeTk1fvgkD6Dat9SkzDWnLSljBlvd6oPebrg1/zwc5s S0kHVeoW4Gt2MeVao3P6FARye2JJDtggFA5Q6RByQwCUOfSCuWkJdXjKAETAyvoTNt03ARxp0uD mSa+Sfmfzn5goRYwM3I9txqiC72hRy+TaAxSaBmLMyTuBXyaWBS6KHxggDyU0aXzpfPfC7RZJj0 c2ybNzahV55jNlxKrMfDn7v0207k55 X-Received: by 2002:a05:6a20:c5a7:b0:3b4:b24e:27a2 with SMTP id adf61e73a8af0-3c08ee3631bmr3895348637.31.1783389283166; Mon, 06 Jul 2026 18:54:43 -0700 (PDT) Received: from xiang.tailc0aff1.ts.net ([20.171.14.70]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-31174a9e2f2sm2028442eec.25.2026.07.06.18.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 18:54:42 -0700 (PDT) From: "Xiang Mei (Microsoft)" To: Konstantin Komarov Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, AutonomousCodeSecurity@microsoft.com, tgopinath@linux.microsoft.com, kys@microsoft.com, "Xiang Mei (Microsoft)" Subject: [PATCH] fs/ntfs3: check INDEX_ROOT resident size before use in ntfs_read_mft() Date: Tue, 7 Jul 2026 01:54:40 +0000 Message-ID: <20260707015440.3420673-1-xmei5@asu.edu> 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: 8bit When ntfs_read_mft() parses an ATTR_ROOT attribute it computes root = Add2Ptr(attr, roff); using the on-disk resident data offset (roff = attr->res.data_off) and then dereferences root->type and root->rule, and later passes root on to indx_init(). Unlike the ATTR_STD and ATTR_NAME cases, which validate that the resident data is large enough (asize >= sizeof(struct X) + roff and rsize >= sizeof(struct X)) before accessing it, the ATTR_ROOT case has no such check. mi_enum_attr() only guarantees data_off + data_size <= attribute size, so a crafted image can set data_off such that root lands at (or past) the end of the MFT record's slab allocation while still passing that check (e.g. data_size == 0). The subsequent read of root->type is then a slab-out-of-bounds read, reported by KASAN when mounting the image: BUG: KASAN: slab-out-of-bounds in ntfs_iget5 (fs/ntfs3/inode.c:283) Read of size 4 at addr ffff88800c06a400 by task exploit/142 Call Trace: ... [KASAN report internals] ntfs_iget5 (fs/ntfs3/inode.c:283 fs/ntfs3/inode.c:542) ntfs_fill_super (fs/ntfs3/super.c:1690) get_tree_bdev_flags (fs/super.c:1634) vfs_get_tree (fs/super.c:1694) fc_mount (fs/namespace.c:1198) path_mount (fs/namespace.c:3765 ...) __x64_sys_mount (fs/namespace.c:4174 ...) do_syscall_64 (arch/x86/entry/syscall_64.c:63) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) The buggy address is located 0 bytes to the right of allocated 1024-byte region [ffff88800c06a000, ffff88800c06a400) which belongs to the cache kmalloc-1k of size 1024 Validate the resident data size in the ATTR_ROOT case the same way the neighbouring cases do, so that a truncated or mis-offset INDEX_ROOT is rejected before root is dereferenced. Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block") Reported-by: AutonomousCodeSecurity@microsoft.com Signed-off-by: Xiang Mei (Microsoft) --- fs/ntfs3/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index c43101cc064d..efb6a855c5ad 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -271,7 +271,9 @@ static struct inode *ntfs_read_mft(struct inode *inode, break; case ATTR_ROOT: - if (attr->non_res) + if (attr->non_res || + asize < sizeof(struct INDEX_ROOT) + roff || + rsize < sizeof(struct INDEX_ROOT)) goto out; root = Add2Ptr(attr, roff); -- 2.43.0