From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 E3EE9387369 for ; Fri, 24 Apr 2026 09:20:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777022429; cv=none; b=VgBVKCjE1oSAXh/SykXQrM8fZ//9WehEIEABex/B0TvfWAnuiZTWqgLrrTzUXlvU91r8VPnPDKXVZexcRMrYC/2CMxyk4KXanpkAmEBFSpzUenedRKFg5S2el1IsOdSUJiqIEOd2JB0TNcPuwdjlcInzdeNHwCgUdt1w8fBd+wg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777022429; c=relaxed/simple; bh=BjkeU1V2UzslQucBONpJ/daTyFTXJfe7M1QmNNRmP2Y=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G7QvzyCl2P28Ff488QntgmqtX4E290RLaAJS5nNhDFgbeuT+sDftlEi/BoFHWhlaJklSnDWCXXGEYl5GA/VE8m3nL9b1sQlUvttBkBZgQfBew7VexYLNuFLKrBoB965J4M6fi0Z6XEQGVFJP3VsoYV1xEnNqrk6GWmc9UZjvHn4= 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=Ax3QB0Ya; arc=none smtp.client-ip=209.85.128.51 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="Ax3QB0Ya" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-488ab2db91aso103982185e9.3 for ; Fri, 24 Apr 2026 02:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777022426; x=1777627226; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=GParuhlyDn4lz5anDtORYnU6WvL4Ixih5AojPVDT8kg=; b=Ax3QB0YaIRUQ4Gz2LAMreKh9xExa5wApYZPi4lAJgCMzaq2zaFurVJwqgjNi2dy3J3 WHz+9peKdY4P+roS86Z7IMrIVcT1u2C1est2MoTEzREiZp4mdjczQl4LRC/KQsjucZxL RpXa1dzKf0ItMA279dO4u8kWwEJ9O7gxyruSHnq3j2rMLIeui6EXUfB02MfACc5dU5FW t+x441OFjIndaDwy2GdT1Zi+Erc1k07EKdQY4vkocYrFYaBdTWPzGtWaEqiVWqBdR2K8 4HZKg7c5AUVMQQn7WwjfDCjY3lKY0cSl0PGrDuNCR0vq5pU9OaLlu+6hXagX3glzNln6 4cNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777022426; x=1777627226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=GParuhlyDn4lz5anDtORYnU6WvL4Ixih5AojPVDT8kg=; b=suljP8sszfUj1UAnKtcgVs5cckQ0CIbRZzlO65d9yumkVdKaHjjgDqfUbAQbbPwSjL z8ncCbXYHl4WnD6JLFxYuFyl/ibeC3ynJz/VWZSKIu3BWNJllc4wumA/W/kGkevmSL43 kXZn6Pg+5Pia9vHIVIMwKrmPIk5NhPxe1DEmvQNRAjnW2jQ5uEQF5DzzjEOMrXjkJktT ifBkEHpWB32YilMBPkrY2ssU3+oaf07NU3ziZCTiY8/nq2syGdx1Ob7Py3NVPb1J0GDQ 17MYAWHhr/pk7vChcowMQab2reA2pVzDhpsCg2ZQfJRuZabWEHR+3Nj48Y/nX2hJJdky D88g== X-Forwarded-Encrypted: i=1; AFNElJ+EV34cn4S8UzNfY3mgZzjusyeAyotOabHTxUezqW0+8fd1anxo3NMT2Gk2VRaBh/wkuozgfRIIZ6Tw++U=@vger.kernel.org X-Gm-Message-State: AOJu0YySJcn8WihwHM46NlPrLf1K8oiYOSguXcuW4B3pkkXCFmLMkDCo XmTTYa4L/6OAiWctHHqBqojiBegPr8tExXWwggxmoKs+Yg3/jocKStr+tGsLo+Bi X-Gm-Gg: AeBDies+zEAeXn7pCFjXaGYlsFOPIq9MlF/oGhCIfHpTQVQ3q6FZPpV+h8DczEC0ono ZEmIec72LSBm+QaASYxJH5OVMuwTVJy+tOj7Q2advr/DtVCbJK96181R0II/quBmeGZy8sTqYN3 3YrLpHW1xW99d/CF5zh5yn4UXRu9tMitmsy2iZFeOUux5zVfaj+tqDWYruKF1Fa8BVx9D4il63Q giEL3ktcPdP16YhKpYT15Tk56CucLdrUAPRPs+LRDccWUuouMg+SyM70UlM+4TPrR4hYsYWyPCK BFeVrPmnSpJj/YVPPN1zfRE/N1luFOaIPUCA6afvtLVrz/0Yg9KnpOshkXtCQLo7H9ZU7MxrDOp MRHBbnSUJcWyomu70LpUVGeYLUxusgWEs/NNJ35dQIq8GTIyee3HjJhAHUQyUGd2+zyBYa3Ouik 2avUKTVxjlmeUqLzYPayqibsHseVV+Y7yd834M8U2/FXX/DQkjoo3SLUETDbZkitjwt4KfF8rBA No= X-Received: by 2002:a05:600c:1e28:b0:483:7903:c3b1 with SMTP id 5b1f17b1804b1-488fb77fbf3mr441215205e9.20.1777022426211; Fri, 24 Apr 2026 02:20:26 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc10019bsm590195955e9.4.2026.04.24.02.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 02:20:25 -0700 (PDT) Date: Fri, 24 Apr 2026 10:20:24 +0100 From: David Laight To: Zhan Xusheng Cc: Konstantin Komarov , linux-kernel@vger.kernel.org, Zhan Xusheng Subject: Re: [PATCH] fs/ntfs3: reject evcn == U64_MAX in mi_enum_attr() Message-ID: <20260424102024.74d20552@pumpkin> In-Reply-To: <20260424024619.285630-1-zhanxusheng@xiaomi.com> References: <20260424024619.285630-1-zhanxusheng@xiaomi.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 24 Apr 2026 10:46:19 +0800 Zhan Xusheng wrote: > In mi_enum_attr(), the start/end VCN validation for non-resident > attributes is: > > if (svcn > evcn + 1) goto out; > > When on-disk evcn is 0xFFFFFFFFFFFFFFFF (U64_MAX), the addition > evcn + 1 wraps to 0, and the check becomes "if (svcn > 0)" which > incorrectly accepts svcn == 0 with evcn == U64_MAX. > > mi_enum_attr() is the core attribute iterator used throughout ntfs3. > Allowing this malformed VCN range to pass the initial validation can > feed a bogus 64-bit extent span into downstream code that computes > evcn + 1 - svcn (producing 0 due to wrap) or uses evcn as a loop > bound. > > A crafted NTFS image can trigger this on mount or file access. > > Fix by explicitly rejecting evcn == U64_MAX before the addition. > > Fixes: 013ff63b6494 ("fs/ntfs3: Add more attributes checks in mi_enum_attr()") > Signed-off-by: Zhan Xusheng > --- > fs/ntfs3/record.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c > index 32bdb034c2a3..2ff28bfbedad 100644 > --- a/fs/ntfs3/record.c > +++ b/fs/ntfs3/record.c > @@ -311,7 +311,8 @@ struct ATTRIB *mi_enum_attr(struct ntfs_inode *ni, struct mft_inode *mi, > goto out; > > /* Check start/end vcn. */ > - if (le64_to_cpu(attr->nres.svcn) > le64_to_cpu(attr->nres.evcn) + 1) > + if (le64_to_cpu(attr->nres.evcn) == (u64)-1 || > + le64_to_cpu(attr->nres.svcn) > le64_to_cpu(attr->nres.evcn) + 1) Isn't that just: if (le64_to_cpu(attr->nres.svcn) >= le64_to_cpu(attr->nres.evcn)) David > goto out; > > data_size = le64_to_cpu(attr->nres.data_size);