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=1796210953; b=OH7a+ZUDH0tM0/XDQ3lOLrRiNf7TRwuX9r76japVE7du1iy37Z3pS/MrPkZ26CNKXZi+ vDNqLNbKHqUrbaa+R585umXMXHsJmVDu/v59NU7xi27kuxmzlMXP0qC0nrARoeKRwk4R5 fZhBqIc8gTkaNHZ29chfbdgQDACjyfvtPDKjIssceDF5hJPOoAzCZFNfcwSrLEP7xtUnJ w/abZW7r3Eklfp2j0tis7+WzhyB4+uCerN9AiNNK5ZRDgP2ExPEoX9s/3z1vO/ArJmFM8 hREwtE8n/UBwyYvsPktWyNrtrfhftnNlxwqRsHNyHtVY/W5U4trsZpAPdAbyVUc+Y3Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796210953; h=DMARC-Filter:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:From:To:Cc:References:Content-Language:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=gCDqzpLr8/kGyWAbE5/UdnIFF3wux4W9Ax0MZyMBJpU=; b=zeZdBT0ZTmFloKu6vAHcD9JDTeTNASn7Vc7QbDqISBJpxDeYlP1YMr36AAB65kWiIZDC /FwITFPTEq2/Vp+ZMcJFxt/p3950/+m6tHC7xpGwQ7ppSR6o3enDVn1Y6zAGvLHHhp1cX ZGIdCWRTBzz8oczd/VEQa7NyTR0K4pD/kUk4RZcVNQNh/75d5ROjPnv5IM5sdE56GwiVs 4TIMgMNYzKDRtoyi33mJMZKmK8xQamEeUFT3531q0qTIkvYPL5nfYIp+8+f9qbnX9FcfN RXzNMxaaqUZPn6YiP/ORYGDRnGszdONnWLRy/9kzDBbSw9/NejOxCbZlFy8Q6a2wk9A== 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=lGha9SsN; 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 C1FD5606A6A7; Wed, 2 Dec 2026 11:29:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C1FD5606A6A7 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=lGha9SsN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:From:To: Content-Type; bh=gCDqzpLr8/kGyWAbE5/UdnIFF3wux4W9Ax0MZyMBJpU=; b=lGha9SsN+yMK7R2CR3p6Kimba8LhK0G2jbPfN4QUoVrpkjHTQNTOK7INPXaBkv gc90yPEhsvUVo75/7OYmdF9vKYJAgRJb24q0t+a4y5De0CXcg1L9M8mz0hFxJ06A kVVzTzJLdLIf1GpbM3LD5kquxDEfx/e4DTo8bVXXFahhU= Message-ID: <883dccb6-044c-4628-8692-c48648e09c5c@163.com> Date: Wed, 2 Dec 2026 19:28:05 +0800 X-Mailing-List: linux-kernel@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] ntfs: map a read past the end of the runlist as a hole From: liubaolin To: Zhan Xusheng , linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ernest.borowski.git@proton.me, ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, zhanxusheng@xiaomi.com, syzbot@syzkaller.appspotmail.com, stable@vger.kernel.org References: <20261202072445.1975205-1-zhanxusheng1024@gmail.com> <1115389a-15a0-4871-974e-9353b0f27af2@163.com> Content-Language: en-US In-Reply-To: <1115389a-15a0-4871-974e-9353b0f27af2@163.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3H+DFABBrjiiJLQ--.55254S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJFWDXry8Jw13tr47Gr1DGFg_yoW5Zw4kp3 97K3WUKw4ktryDurn2gF45tFW0vws5KFW5JrWUXw4a93s8JF17KF40kFWFv3srJryrCF1U ZF1qv347Ar15ZaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UY385UUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6gcQ2msQAMcnTgAA3y 在 2026/12/2 19:17, liubaolin 写道: > > > 在 2026/12/2 15:24, Zhan Xusheng 写道: >> From: Zhan Xusheng >> >> ntfs_read_iomap_begin_non_resident() maps at most the rest of the run >> holding the offset.  At or past the allocated size, >> ntfs_attr_vcn_to_rl() returns the end of the runlist, whose length is 0, >> so the rest of the run comes out negative and is returned as the length >> of the mapping: >> >>    WARNING: fs/iomap/iter.c:39 at iomap_iter >>     iomap_readahead >>     ntfs_readahead >>     read_pages >>     page_cache_ra_unbounded >>     do_page_cache_ra >>     page_cache_ra_order >>     filemap_fault >> >> Readahead gets there when the file shrinks after the readahead window >> was sized from i_size.  "ntfs: trim the sizes after a short write" >> makes that easy to hit: a write that runs out of space is rolled back >> to what it wrote while a MAP_POPULATE mmap() of the file faults it in. >> >> Map the range past the end of the runlist as a hole. >> >> Fixes: b041ca562526 ("ntfs: update iomap and address space operations") >> Tested-by: syzbot@syzkaller.appspotmail.com >> Cc: stable@vger.kernel.org >> Signed-off-by: Zhan Xusheng >> --- >> Found by syzbot ci on "ntfs: trim the sizes after a short write": >> https://ci.syzbot.org/series/9c5fb049-3646-4d3b-8f57-43553c5c1bb0 >> >> Tested in a VM on ntfs-next 329758f9d73b with the reproducer's image, >> the reproducer's mmap() and write() in a loop of 30 runs: the WARNING >> fires within 12 runs without the patch, in 5 of 5 boots, and not in 4 >> boots of 30 runs with it.  The read mapping of 19cc08c1a6a6, the base >> syzbot ci tested, has the same code.  fsx (buffered and O_DIRECT), mmap, >> partial O_DIRECT, insert/collapse range and the short write cases give >> the same results with and without the patch.  No lockdep or KASAN >> reports. >> >>   fs/ntfs/iomap.c | 7 ++++++- >>   1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/fs/ntfs/iomap.c b/fs/ntfs/iomap.c >> index ce916707f69b..8124c5f62700 100644 >> --- a/fs/ntfs/iomap.c >> +++ b/fs/ntfs/iomap.c >> @@ -248,7 +248,12 @@ static int >> ntfs_read_iomap_begin_non_resident(struct inode *inode, loff_t offset >>           return -EIO; >>       } >> -    if (rl_length && length > rl_length - vcn_ofs) >> +    /* >> +     * At or past the allocated size, ntfs_attr_vcn_to_rl() returns the >> +     * end of the runlist and rl_length is not positive: map the rest >> as a >> +     * hole. >> +     */ >> +    if (rl_length > 0 && length > rl_length - vcn_ofs) >>           iomap->length = rl_length - vcn_ofs; >>       else >>           iomap->length = length; > > Hi Xusheng, >    This patch looks good to me. >    Since "ntfs: trim the sizes after a short write" makes this existing > issue easier to trigger, would you consider submitting the two patches > together as a series, with this fix first? >     That would make the intended merge order clear and allow CI to test > both changes together. > > Thanks, > Baolin. Hi Xusheng, Sorry, I forgot that "ntfs: trim the sizes after a short write" has already been merged into ntfs-next. Please disregard my previous email. Apologies for the confusion. I've reviewed this patch and it looks good to me. Thanks for submitting it. Thanks, Baolin. Reviewed-by: Baolin Liu