From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.2 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796207974; b=lI6qOHGK3pdaqVCr19gG4xO3SkbPuZJRbbHHtZPi6g5OjEVfcNShw/RhTrOLmvVB5yS0 XiP7qWHFAsbcGKaIjm1KWAnLara6E1+NmUhlQWKDidCawIUfN9cewos5HEem6rDxPRKK7 YKg1h5QABXzyQ8pdtggifP8+G5K88K/PADioplfsFnm2erbMxq9+C+NHmArKRDGoNnAMD cIzUID3QAEbCV6QInjw48dSQiotFBXLtjZUhVPnUlxhRvraJco+FXX00OCBpUIXi6a/cj wT2j7ctkhD+Nf/aXeXuWrLPYmxEN2fA52lHitVM9DErcPge8HNJVfWhGKGcWoEbLJUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796207974; h=DMARC-Filter:DKIM-Signature: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-CM-SenderInfo; bh=YZZIBnrBWuIDrHaMoS0sacUFbF7rZGQmtyz9FB9k4as=; b=dDvLQVJAwZAr/ryHYZgsSQh91qLdsOw/YBpngDCggrxM+vE0Y8PGoepf0iFXaT9ZQWYe dB8EO+Gl+uy2eUFHsnj7ouIM37JZEeU4FFwHP4pSfsSr+ZNtaRPQaS4gueoz5TAmHZ5+q zR7Pi7DmgOicRUNW2Yjyrr4KpO/NFDph1524Yqrwp48Z1GCIqqMY5RZgX9MAqnZn/UcB9 kLSzLUaEa6XxtcYmLqmhNL9r+KGTfl9w96CFcj8zuG1GS/m05Rst7+S2/mLlDfUk48cDq lFoZllLBOdR10Y/xUcCTfuHXCm/W8YjKXO5UjgTV1QB7E/OuPza7wc4yXuopHB3hGJQ== 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=CRP0ZhEm; arc=none smtp.remote-ip=117.135.210.2 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.2]) (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 E3586606A690; Wed, 2 Dec 2026 10:39:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3586606A690 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=CRP0ZhEm 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=YZZIBnrBWuIDrHaMoS0sacUFbF7rZGQmtyz9FB9k4as=; b=CRP0ZhEmzvwKBR/SJ9ZiW5tDx39fdaKgN+OypgLg5dNVQ83BTubHJ97uU7XLC+ tsNA6lsBU/+bK4P3puUk2BhxMVmhGH74rxbqhAtug/QTLSB+HeJh5gdaUlrAW1oV mWk21r0XHdsdjbLAVLjaa5uLegIk2kfrz/f8d+iyV3040= Message-ID: <3f3cad17-9430-4159-b2f3-58b0fd1d1706@163.com> Date: Wed, 2 Dec 2026 18:38:44 +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 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> Content-Language: en-US From: liubaolin In-Reply-To: <20261202072445.1975205-1-zhanxusheng1024@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:PygvCgD3f5w09Q9rcmHwJQ--.24108S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxGF15Ww4DCw1DJrWftF45GFg_yoW5Gr15p3 9akFy7Kw4vvryUurnrWF45tF40vr4fKFW5GrWkJw1a93sxt3W7KF10kayFq3srtryrAF1U Ar90v347Ar4UZFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UOF4iUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6Rgq9GsP9Tg-cAAA3J 在 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; Looks good to me. Reviewed-by: Baolin Liu