From nobody Wed Jun 17 07:35:23 2026 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.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 E3FBE370D54 for ; Mon, 27 Apr 2026 03:50:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777261843; cv=none; b=QtAotjFVDsBbvn8XX0CCD0IiF7+GzmxA6a+RMOh0kCA6Y6+g/hWJlNBnev6sGbQl95PyiCFVA4OjF3Lm+6miGSgewcWjphQxJolLdunPYBmJRD0osstqVwJIsHUwKDNQbinZzg/QNapZFVrpal1T4meDso4LhSC9SUvlfksU3w0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777261843; c=relaxed/simple; bh=UcQ+Ia0PLtka5ONr65AtIknvE0yeUBMwuQBj2YcvYwA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TQ1NX7EVerCR0M8uogy1BmGLgLaWPTtzWQHZoooL0zshT3auPzkJQrZdA0KnlL9ZM29g4zHomeGvlGWpunt8jbcOOPk4iLI+DmNIJbuTgJ7hCf5mjNIjanqqKL4I/HbMC/gF/Upueh79iuji0B0xeuo1kVFJGbn4Qm7X8hDJtyM= 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=bGri1SwW; arc=none smtp.client-ip=209.85.215.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="bGri1SwW" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-c76c60c7502so3875004a12.0 for ; Sun, 26 Apr 2026 20:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777261830; x=1777866630; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SITHK9cFEZ3EPl8tO8lZTNnorh5KMZPHbK8HM1ECYfQ=; b=bGri1SwW5VZBgIRhItoBIeYLztse4pUpuUaAhFM6emjYLnjKxmFfupeCZ0PIOrUnaJ zPVFLVThrzHn6r22flYcSl7KxF3CmGTfR+tJ4nWI10maSDOZLi/MAR6epwnc+d6UGw10 L5h2aPWmHUL3pI8KkimMDbgUo/QSkk/M22KQ1vDlMwP27wfpnNLTc0DL3PD9zIcyhBKU cgGcQedWWLJQxE4kJKRdTnkv60ZtRNmgf2daiPHjxqjrNlx/4b2KC15L3lNBcxrwhRHk MGO7WIqMAWWUrzSSAuTD5Qgx1U0eM5nDDLPlQA0gA0C7JpaJmoSf5u9oYeISVubPS9Pk TJeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777261830; x=1777866630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SITHK9cFEZ3EPl8tO8lZTNnorh5KMZPHbK8HM1ECYfQ=; b=aUUUbpkO79PfQYkhGn7NdJYz2//oCSgzdDu25D+8Te9BTOHi90lRsGcdUoAkzyO+a/ hnjyQJX/kQo4TIYvQoFXYLoo+R9gBOSoPxWqDiLRwCmStgBkyJ0Je0NpRY1bo4jw61UA CBD5d/H82poPH1q6/BsQj9RiRed7g2pzzMbFIc/alxjM8bNHYS+13pzdvckFDJTTwflG G5Z6avTThGMby0fDXkXIhL6wF4Sk+LDIVi2t8dzY02x/PjzqLFBnk8mblthPLFBwmAjn rwdstnuGEIZ99gBc7SdyAhZcBWT45TFtOwtEJep0J9XrRbI5PZQrhielrP44Z6fVr+Bv iTQA== X-Forwarded-Encrypted: i=1; AFNElJ9Y5xVtczGbeIOVB/ydEX1q7W0taweZJQhG4ezNRl/N8kzol3JjFRBUsLQzTIyPpfCf4cYpOv0Rya4v/Jg=@vger.kernel.org X-Gm-Message-State: AOJu0YwZRJ2g/r3/WA3SDhlFCRQb08q8MuLvOXjiTE4L/s2toGUNs5vW 7o/G3IMMP8cE0B5Hau2bw4m7SijhP4nphIdGYDcv8k2z3IApQ6/hs5Ma X-Gm-Gg: AeBDietpRLJhQ1a2QrMUBMv0muIYe5WgmFVLSOj3wYFOctqctJ8QWWiQUHga39QrEG7 O04oH0Zv6vJcvGAsGv7RHwou1Z0lpEwUZFltKGZ82vNFWyP/jExld1lZdNJEZfnc1Iig19jEdu0 rpaMd7C9iT0JVW0H6YdQWtTbhZwB2DzUkFHfVMF6PtT3QgNtgi+IXZ+ZyWquHNtfM6+S2J6zUzA 87CtsvnqKmlOCWJrYkcDqZ61JzYb4j9UdmcPCaYrE/8PiwqFgdQxNjxjLWR8thwCur+6hFE6Nwt v8WShguPbZsZQ7HDIxqY42HQZqdTZ2MQEz2VS5w1X/Rsxge+ewKtFIqy/SyfMVtCGeq3ZEqZOsh 3nIUvGTfzFk+o4oGlccPavvafjXEGbUd69c1nSe8205fkKjUODauDy0S8Io/qUeWkSsHfj2SVAT +qb19nH4/DQYuzU4zBQ+z3GmOwgYSwByYmpS55zVBLprlftNHVeYFBde5+Sj2CP14/nAXt X-Received: by 2002:a17:902:ebca:b0:2ae:4d6b:b2c7 with SMTP id d9443c01a7336-2b5f9df38c9mr338928735ad.9.1777261830303; Sun, 26 Apr 2026 20:50:30 -0700 (PDT) Received: from DESKTOP-MOQC9AF.mioffice.cn ([43.224.245.246]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fab288aesm278135805ad.65.2026.04.26.20.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 20:50:29 -0700 (PDT) From: Zhan Xusheng X-Google-Original-From: Zhan Xusheng To: David Laight Cc: Konstantin Komarov , linux-kernel@vger.kernel.org, Zhan Xusheng Subject: [PATCH v3] fs/ntfs3: reject invalid evcn == (u64)-1 in mi_enum_attr() Date: Mon, 27 Apr 2026 11:50:25 +0800 Message-ID: <20260427035025.38158-1-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260425114246.545866b6@pumpkin> References: <20260425114246.545866b6@pumpkin> 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" In mi_enum_attr(), the start/end VCN validation for non-resident attributes is: if (svcn > evcn + 1) goto out; This relies on evcn + 1 arithmetic, which overflows when evcn is (u64)-1 and wraps to 0, breaking the intended range check. In that case, malformed on-disk metadata such as: svcn =3D=3D 0, evcn =3D=3D (u64)-1 may incorrectly pass validation. VCN (virtual cluster number) represents cluster indices within a NTFS volume and is bounded by the physical size of the filesystem. Therefore, values near or equal to (u64)-1 are not valid on-disk VCN values and should be treated as malformed metadata. Reject this case to prevent arithmetic overflow while preserving the original semantics of allowing svcn <=3D evcn + 1. Fixes: 013ff63b6494 ("fs/ntfs3: Add more attributes checks in mi_enum_attr(= )") Signed-off-by: Zhan Xusheng --- fs/ntfs3/record.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 32bdb034c2a3..ad752bebb66c 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -202,7 +202,7 @@ struct ATTRIB *mi_enum_attr(struct ntfs_inode *ni, stru= ct mft_inode *mi, u32 used =3D le32_to_cpu(rec->used); u32 t32, off, asize, prev_type; u16 t16; - u64 data_size, alloc_size, tot_size; + u64 svcn, evcn, data_size, alloc_size, tot_size; =20 if (!attr) { u32 total =3D le32_to_cpu(rec->total); @@ -311,7 +311,10 @@ struct ATTRIB *mi_enum_attr(struct ntfs_inode *ni, str= uct mft_inode *mi, goto out; =20 /* Check start/end vcn. */ - if (le64_to_cpu(attr->nres.svcn) > le64_to_cpu(attr->nres.evcn) + 1) + svcn =3D le64_to_cpu(attr->nres.svcn); + evcn =3D le64_to_cpu(attr->nres.evcn); + /* evcn =3D=3D (u64)-1 is invalid on-disk VCN */ + if (evcn =3D=3D (u64)-1 || svcn > evcn + 1) goto out; =20 data_size =3D le64_to_cpu(attr->nres.data_size); --=20 2.43.0