From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 B9CBA3EDAA0 for ; Wed, 10 Jun 2026 11:57:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781092675; cv=none; b=JIzArnPZE51OXqe/7w3KoqGLpVh8gfi0JLVHzyMCLV1Ffjd+fdwghgFsJlZ6NykPxlsm8PQY4gQeic1M91wZmi/C+AoNdrZxbWFWervbSZWLd582qTQKVdevAaMdcGrbJdhGE709B+3Szcr/MO0tn5l/NUlEklhDaItaUKMcSyY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781092675; c=relaxed/simple; bh=E1gf/cK0eXaYUala4re8eqJWzK8pok2qz6inJc5Q9b0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hf6qF/v8GtVX+at8lrvcA0cEi+lCD2SXe4uy+tg4tflhjSke49jMewAAwLkVVjQOF/J9Q6PMJco4YxsOS4hMb/s/uAfWM8TNOeETisNKfAV6sOwZu+/3Ok9B/my35g18e6PGoFwx8lQvWi5jn1BYWU7/q+K24Wg4MKpVGKTBrIg= 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=f8pLJ7Fd; arc=none smtp.client-ip=209.85.214.169 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="f8pLJ7Fd" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2c0b9328c4aso46345425ad.0 for ; Wed, 10 Jun 2026 04:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781092674; x=1781697474; 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=WI6Jo9PJbir9yuEY2m2j5zC+fMIlRWudCHlrzG9V0QY=; b=f8pLJ7FdM6vfplTmrWn2XJP6VECRQe0+PQ9pg1Fr/L3o7C5D0jCSFy4ij95xhYdRy5 L1mUuCstHhLqHxrJPgPT3WQfLayvPZhhohvB4Z2rqzO30VGWkQiRv0B4hptZb7SAxG9O 2uxjrKgI1OPH1LUVNqAia//hFJiaAgW6M47N4U5KHOMdSZgp99MwwKBE7YhwrB2C4hHp dbuYMDJO+Bmz018+5UywQOQ+QT/k7VKTulxNpUugXHjfCw1HqJGQBFirpejfTj39uS5f VlBLhJhnTfOlK25I09aKEhAjs0vROrlu+7bpiZ3n+AhYEAlI5aTRKPgRZe96i1d+LOwT 2hxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781092674; x=1781697474; 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=WI6Jo9PJbir9yuEY2m2j5zC+fMIlRWudCHlrzG9V0QY=; b=f19o7hD71KRPEgZ86UisbZ5UwNXUcuSm3WvclVhKzoPqHA8oQgoFQCYWrvhouVOPHP vpAmUZNeIRdnwkBKoqJ1UWAYmvkHCPEE1yd0S/JRUW99Wm9LUAyXOZH3qILvY41+tH7U DeJHIuZ45JjCttg+op1Az7BAuKZZ1m//z5mmmg1FvnmJ97vs9jHs2bzsAbiTZiBwPdGA gJMkfx/MDwSgy6Qs4RqLK8X8qiErAXMu3cPN9wyrcsvaud8wxi3caf/tGGfhun8rzH4k +q+u2eHSZXwRIQdPg5WRojbRLBMa7pz+7BzPtqzA5nt+SAC3SPb2or//x2e3aDj/O6sc QLog== X-Forwarded-Encrypted: i=1; AFNElJ9mp2RUXWZG44ySGEscvjC1gwEPCoTr9gWNVWQ3xs/16tmPDEe8t3ked+QJCApW8mgsXZQV0+zFWJ8pxsg=@vger.kernel.org X-Gm-Message-State: AOJu0YyxaAGgp3gT1ju1NHLR2xBpRgH2gklR2Mzx6E6LsQ06BFHBbirQ R/nyi6A+Ya1hgsaoz/Z3AuVjc0LoAmNRBox56Wj1qdMd61iDH0fsPSTTPIU51KUi4Y0= X-Gm-Gg: Acq92OGIsolmq4yBhUTxd+hGC48Xj6z5pO+0XiLygVBQ1FYuycFKkHIRaO/MPr5PRkS zH5iTmTfElXqaoUsRHdbrrrLYXTLN5WxWrIO73uWDirjrlT64G0DIWQTNCNm2pqfS9dySjb9iGk atxzUPcY2uAOm5KPqH5Kr0zybO8Nx2wy97UCk/si/3+FiXY7lbNHixMcGWJ4u8yEAW3tAEl1ZBv sTUU9GbKe40u/HLZsvl9nIlUVb3HIUQNJaSeOSql8bfJ8pOV5bHe62F7YYeYn4kGg33/7zJA3wr zDsmc6D0y0L2omaY8eBuSYSvIJQxZ1KH+Ogs4pAB390m9gdnZ1RBJAB5RH34ch3XZt/PfRJHGh9 LfnMFImmJ2sOALM9Q+/t+YV9foXvDJpmjIhBU/WGcklANDhXGoaSaqKiU1CL/Yk+6+UpKNmmBwe BV0ZmyAAc6IiPDYqpPEf6W93J2scGECYu5tmH89IxBqQhNWCq15D0HmEkdCI8FBF6ee3drwFJic od8dCggcMuZA73EgwxEcwUP92tCkmajuA== X-Received: by 2002:a17:903:22d2:b0:2bd:8395:fedd with SMTP id d9443c01a7336-2c2a1cb92f6mr82753155ad.37.1781092674045; Wed, 10 Jun 2026 04:57:54 -0700 (PDT) Received: from SLSGDTSWING002.tail0ac356.ts.net ([129.126.109.177]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16629d240sm258026025ad.58.2026.06.10.04.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 04:57:53 -0700 (PDT) From: Weiming Shi To: Konstantin Komarov Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, Xiang Mei , Weiming Wu , Weiming Shi Subject: [PATCH] fs/ntfs3: fix out-of-bounds read of INDEX_ROOT in reparse/objid init Date: Wed, 10 Jun 2026 19:57:25 +0800 Message-ID: <20260610115724.1813176-2-bestswngs@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: 8bit From: Weiming Wu ntfs_reparse_init() and ntfs_objid_init() parse the index root of the $Extend/$Reparse and $Extend/$ObjId metafiles (the INDEX_ROOT attributes named $R and $O). They read its type and rule fields through resident_data(), which does not check that the resident attribute is large enough to hold them. mi_enum_attr() accepts a resident attribute with data_off == asize and data_size == 0. For such an attribute placed last in its MFT record, resident_data() returns a pointer to the end of the record_size buffer, so reading root->type / root->rule reads past the allocation. Use resident_data_ex(attr, sizeof(struct INDEX_ROOT)) and bail out when it returns NULL, as ntfs_security_init() already does for $SDH / $SII. The attribute is only parsed while mounting a crafted image, so this needs CAP_SYS_ADMIN. BUG: KASAN: slab-out-of-bounds in ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306) Read of size 4 at addr ffff88801219dc00 by task mount ntfs_reparse_init (fs/ntfs3/fsntfs.c:2306) ntfs_fill_super (fs/ntfs3/super.c:1604) get_tree_bdev_flags (fs/super.c:1703) vfs_get_tree (fs/super.c:1758) path_mount (fs/namespace.c:4131) __x64_sys_mount (fs/namespace.c:4360) Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block") Reported-by: Xiang Mei Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Weiming Shi --- fs/ntfs3/fsntfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index d0434756029b6..42493a2da24ef 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -2302,8 +2302,8 @@ int ntfs_reparse_init(struct ntfs_sb_info *sbi) goto out; } - root_r = resident_data(attr); - if (root_r->type != ATTR_ZERO || + root_r = resident_data_ex(attr, sizeof(struct INDEX_ROOT)); + if (!root_r || root_r->type != ATTR_ZERO || root_r->rule != NTFS_COLLATION_TYPE_UINTS) { err = -EINVAL; goto out; @@ -2340,8 +2340,8 @@ int ntfs_objid_init(struct ntfs_sb_info *sbi) goto out; } - root = resident_data(attr); - if (root->type != ATTR_ZERO || + root = resident_data_ex(attr, sizeof(struct INDEX_ROOT)); + if (!root || root->type != ATTR_ZERO || root->rule != NTFS_COLLATION_TYPE_UINTS) { err = -EINVAL; goto out; -- 2.43.0