From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796378237; b=rBrBx5p+tpu6JDun2ABWs6NhUxpPuAXL7KUe2hFxYjHHiLfiA5ir6doHMVFF/WrhXpU3 Tmm5dddKx/jJ71PUBfg4FODQsnd/sL9RsErc/vwy+ccLFuIn5UL1Ea4is+oxjvNGlVkx5 42PLGT3C3ZgFyZh9snH8Z3+Tl/22omPCi0OkP9ERvv7/W7fhYuywb8YFsHuyzo9bCthL0 UOupr+5GMtrZUEzpXEjeSTutAY0OTeubBNJ9rit9K34RIT/40Qv9uPSDhJcwEfllWQmds YLDEpAx7v+oLfdj0phl5tomDZhNyAx7t95VmeNy8s/2EImhn8SO1l/pzmmwPPdyhEtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796378237; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo; bh=yWXmhgt77NkXSlRzfe/h8DgsllUCryFWFlbNezREe3w=; b=4fy+pSyWc1o383UIYIGl/Xh/jTVQYltWVGj4d4lzUkZBa5P3I8qZNjsDyS4hY8Og3C0M 6VFJX/9M/Dld83dq2nyJXhlmWyYlgsoicTI++af1hQ/2lWRp60BsbTIQOyrw5tuSwvkB7 voEUd0I8f1/3BpXZ7+gJd9J/20gKFK+yYuTTq2AJGAuI7ttASJpc1Dx7zMRV3hbRUI+Mb ZaoqivWtqPAhKLiT6Lc99/jhza9MJmkG36Ws1nrmmkTxUb4pA755NpsNP4HFjAlSulk/9 DmYZUkzz+5kK28PCHzhqbXvYU1+ohmjWEJjNdQtnHS5yORuii0Q00WmbGhy/vuQPi2A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=AkwPf6rk; arc=none smtp.remote-ip=220.197.31.5 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CDD6606A32C for ; Fri, 4 Dec 2026 09:57:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0CDD6606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=AkwPf6rk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:To:From: Content-Type; bh=yWXmhgt77NkXSlRzfe/h8DgsllUCryFWFlbNezREe3w=; b=AkwPf6rkkjz45QiC/QF+do63s4IezqBYNKwvNWltOSDj7/xgkSuY5xBAceTrSK fSLKVZhsbgR5eXDRM4nOUxMTWrjkB3VulLULzGA2DAuPhwNTCYHC+L+od0ZOK4IF SNFmX2kkTlMKAIcM5bqsNYPFimnZM9658CZf0p8xiJVQ4= Received: from [IPV6:2409:8900:1fc7:c434:7504:5cc7:aed1:e845] (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wD3P41ljhJrsGIzMA--.62394S2; Fri, 04 Dec 2026 17:56:55 +0800 (CST) Message-ID: <5b126fe9-7bde-4712-8efa-e1cacca08033@163.com> Date: Fri, 4 Dec 2026 17:56:53 +0800 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/4] ntfs: validate phrase output before advancing To: Hyunchul Lee , Namjae Jeon Cc: Baolin Liu , ntfs@lists.linux.dev, stable@vger.kernel.org References: <20261204055442.3619912-1-hyc.lee@gmail.com> Content-Language: en-US From: liubaolin In-Reply-To: <20261204055442.3619912-1-hyc.lee@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3P41ljhJrsGIzMA--.62394S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7tr1UCr1UZF4fKF1kJF1UZFb_yoW8ZF4rpr 9rGa9aqr18Xrn7K3ZFyr4ftFyI9ayfJw4UGrnFya15Zan0qwnrKF18KFWvqw4fAa90vF1D XF45tF9rAFy5AFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U2zuZUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6gcc5msSjmcMtQAA3+ 在 2026/12/4 13:54, Hyunchul Lee 写道: > The LZNT1 phrase-token path advanced *dest_ofs before checking that the > result fit in the current sub-block. On malformed input, > ntfs_decompress() therefore returned with the caller's cur_ofs beyond > the failed sub-block even though no phrase bytes had been copied. > > Check the phrase length against the sub-block bound first, copy it, and > update *dest_ofs only after the copy succeeds, so a failure never leaves > the destination position past the failed sub-block. > > Fixes: 1e9ea7e04472 ("Revert "fs: Remove NTFS classic"") > Cc: stable@vger.kernel.org > Signed-off-by: Hyunchul Lee > --- > fs/ntfs/compress.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c > index 2f11206b7428..86381ca2b878 100644 > --- a/fs/ntfs/compress.c > +++ b/fs/ntfs/compress.c > @@ -408,9 +408,8 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[], > /* Now calculate the length of the byte sequence. */ > length = (pt & (0xfff >> lg)) + 3; > > - /* Advance destination position and verify it is in range. */ > - *dest_ofs += length; > - if (*dest_ofs > do_sb_end) > + /* Verify destination is in range. */ > + if (*dest_ofs + length > do_sb_end) > goto return_overflow; > > /* The number of non-overlapping bytes. */ > @@ -432,11 +431,14 @@ static int ntfs_decompress(struct page *dest_pages[], int completed_pages[], > memcpy(dp_addr, dp_back_addr, max_non_overlap); > dp_addr += max_non_overlap; > dp_back_addr += max_non_overlap; > - length -= max_non_overlap; > - while (length--) > + i = length - max_non_overlap; > + while (i--) > *dp_addr++ = *dp_back_addr++; > } > > + /* Advance destination offset after the copy succeeds. */ > + *dest_ofs += length; > + > /* Advance source position and continue with the next token. */ > cb += 2; > } Looks good to me. Reviewed-by: Baolin Liu