From mboxrd@z Thu Jan 1 00:00:00 1970 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 C7F3914F70 for ; Sat, 25 Apr 2026 02:03:16 +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=1777082597; cv=none; b=hXMrcSEdU3VzW4Hth3J7nlJgkh7H2a7h8+nfj3ZfO7LhCuRnhXcYAsXOptLSyzKOpmcxiAlZMiprWEoonKoybqz0Qi5o1ltDzVDQurrGnXWvvmwPvybOw9RDC8ckAayko0/1D4MU4FIM1tqvERCCLeA8RLrLmSZ0cga2fCqnygg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777082597; c=relaxed/simple; bh=L3N/bDyKRKF4lvmMKS4Ohkvg0zngdtGbWb2PBh1/OOU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bdvLm4exuO5D7DwQwFr+G2M4DBaymkZMbrKFrjf8TII1nySDRv60b34++cqncrb4pu91GGtXVVmAF6EBZ5mdUoN1oW2wLwIcI5Sz0+I2VKPeBXmCoFIxenbUbKfITDf379MvZdGNqe9mhH14vZonb95GzGyoWuuONBx15DhiXbo= 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=i66PoCLl; 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="i66PoCLl" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2adbfab4501so41604995ad.2 for ; Fri, 24 Apr 2026 19:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777082596; x=1777687396; 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=kEX/Sa5gKOT6mtek9R9cODl7dzOLk9YVVTNcH3LN7P0=; b=i66PoCLlxZkW7gNjuk+ccbGB1UxjwgkrXC94Z857Z3ZYL8CRDuEX9qA+SQesRSwdZo 7frxv6g7XD4rNT/t99r3aO7LN9LA3MsUYAkp9v+7jHsv49NP+3hL899h4xN2Qjqsbv0t 0cWXUJrVZZqYF5EeOX3mjT4qq5Ng9UwyG2SSYQXMzeysJmLz5r5JfqzOu29bminkqSw/ 4y0hH+bWSeeEpOA110afNG/K3tGTeITru6pbLfJx/p/jgX1ezAZLNQBfk27Ig6Hu3wB+ EqVjJ0zMsek3MexuyDjP8T7/9GFZgaA4rblCcGEgkT5KQ0FkbARt/zpmMKsz5dIwmKnW x22A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777082596; x=1777687396; 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=kEX/Sa5gKOT6mtek9R9cODl7dzOLk9YVVTNcH3LN7P0=; b=fV/VSTvdDOIVr98MtN5o+xGweXVE+9ShAvNslU50NK08Ry0Qg7vZj9y2zV6LBWrzTo cfywgdzvuEkEfnYg0f7RJq/VeZAVPxHQhoxlri9H75IYjtRu5fZSjFXVbmiwttrI0D7q 0qU9c2PilUiD0ejlMRoN8+ZDpExp0tQ0/EQ3ltln+3WUAFsYCsp886TMu701bRh6TZlt N6AS/1sVtIcHl1ADZemLRhi7yQamDjzu/jCE5ZPfqG1/pzui3CIIACqgx1xVR7wZUK/s bUuLW3JM3jObUjG3HaVng0h2h6X/PeWJBv9F+0eeTM9meV+62mAIVETyrhPIAgTP/I8q ZfWw== X-Forwarded-Encrypted: i=1; AFNElJ9UGec5ABcpfeTXBoNvlVvkSHFQMdgfwKKMxFfhd2nNta+KfZ6FChyKYGxDzxE0dkM/BUqVXOs97KWR17s=@vger.kernel.org X-Gm-Message-State: AOJu0Yzap6EySbNfycijKnfPUxU+iVVGG2dzbnozDZaoEcfB/4Mc89it gyVVryh391DtUd1fbDGfSjAgWm+hlAdihnAg/xW5nP3qFdzeqrUwxwuw X-Gm-Gg: AeBDievf8ezWDoZnyvfWXXCG8Rl/gbPfsJqmzlxWwStPp5IaModwEzHci/w1KqnasLT /hwfL+PPLxxQi0U8GHTokPbT/uFImIWmsdFNwn5o0pFd3xne0LacSc3zJBVVh6dTp6WSY+7Pkss /d0BBrV2MyQu9EPP+p9jdGJgpDr2mk6LS2mnEyaSSSWnHRnflnP2qi/hCGjy81ws1VydZpcYZ8g vOevFAIPqdTnVjawXuQ56m9b45ODRp//YOwg8IJ6VsMeohLArbzE3kplcbFQI4UuvQ1DPirQm1Q 7HWTczFzT+xynA+C+Piccucg8VsWBFKArGyRYbfCI7aqpSWICsQXjLnFgTW8ww0AectVpeDFxAK zU6So09sjAA3Wct5J1vn6SABE7lJ7c7tMP0AjQRxK5sBZO005Mr2ilAQx3SbnCCGJNfxh+e1FwS bJ9ETMwXWF1fsl9dbLfg3EgTfzrWvGVP9+NpHpFSQblZsLflyddr3ZNZUBsQ== X-Received: by 2002:a17:903:200d:b0:2b2:5597:bad4 with SMTP id d9443c01a7336-2b5f9ffa730mr262424665ad.30.1777082596049; Fri, 24 Apr 2026 19:03:16 -0700 (PDT) Received: from DESKTOP-MOQC9AF.mioffice.cn ([43.224.245.246]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fa9ff734sm230820245ad.10.2026.04.24.19.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 19:03:15 -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: Re: [PATCH] fs/ntfs3: reject evcn == U64_MAX in mi_enum_attr() Date: Sat, 25 Apr 2026 10:03:09 +0800 Message-ID: <20260425020309.1663-1-zhanxusheng@xiaomi.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260424161558.2d21b624@pumpkin> References: <20260424161558.2d21b624@pumpkin> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Fri, 24 Apr 2026 16:15:58 +0100 David Laight wrote: > Is that analysis correct? with the current code: > If evcn is 2 then everything except 0, 1, 2 and 3 are errors. > If evcn is -3 then only -1 is an error. > If evcn is -2 no values are errors. > If evcn is -1 then all svcn values except 0 are errors. > > Clearly this doesn't make sense if evcn is -1. > > But there isn't an obvious reason why svcn == -4, evcn == -1 > shouldn't be a valid range. > (There might be a sanity upper limit is evcn for other reasons.) Thanks for looking into this, David. The on-disk svcn/evcn fields are __le64 (ntfs.h:339-340), and ntfs3 uses them as u64 throughout -- the internal VCN type CLST is typedef'd to u32 or u64 (ntfs.h:73-78). NTFS VCNs are unsigned by definition; there is no such thing as a negative VCN. So the signed interpretation doesn't apply here. In the unsigned domain, 0xFFFFFFFFFFFFFFFF is simply the maximum u64 value, not -1. The only issue is the arithmetic wrap: (u64)0xFFFFFFFFFFFFFFFF + 1 == 0. Regarding a separate upper bound: yes, evcn is also bounded by the volume's total cluster count, but mi_enum_attr() validates on-disk MFT records before the superblock fields are necessarily available to every caller, so the U64_MAX check is the minimal fix for the overflow. Thanks, Zhan Xusheng