From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.3 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796210331; b=Yb1ox7tSWH7tLD33mzWFsrAqKS8oe2vaZobUiP2/XkVkKDeffznpPqVZ6whjjzLpt7kf SWPafEKGn7Q8uOvehNF9aR/DTSgeMRcdAozkz7KnMoZnOaL0a508Z/a0Zn+L1duN2IGvR jYtfhWXQgE+D1pgktEf3/QEj0czAw9Zn+mBf06U8Y8f6IlTmP0ntkPqY/7D+H1tFFI0Fp /s+PdjuVNqFMUMdpYjRdr6cEmEp1vnUX1yQKrPBG7o1zNT71v025kmNt+Cm0HOKRmHbSm 67nj+fchdq3FXXT6zQUDs57JE4N0l5PeUSGourW74gkkcaVYjib8fWviKQhkGYsJ1xA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796210331; 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=gi/xjoAeVQdt7Ge1uMSGkJs6H+05GVpYiLuWfnVmQkQ=; b=OxuvTOZ6FyMRdf9/EYzq0lWIUjB6Xp2ZpwZbB18H4q2bKKH+n9GK+xFecOTYuJF2DPM2 +lirKO1IY7B3YLfIQtEq8mYGELvYeZDTFVBd2uRZZvvw2sCdALiH73n4kgYRHPLOmjdJ6 /IajF3lFTQrCg6t76+xRvcqX0nIPYiseuU5XuCRsX1/503kAi0Bbh/t/xG6cipLwehyoy YPEKeeRywUXzw1XLGyVf7cU/Ng0oQwNbD6gCSL3xa4SZpZNLSO2Juv8TKh6fCAg8QgDOF idqHqgSAMJnmHn4Wc/hu5YnnwfVALYXqKHtvKORGP1XjImFlZM97//t+8EcDSEBr6hg== 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=V2CTF0fX; arc=none smtp.remote-ip=220.197.31.3 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.3]) (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 7F65C606A322; Wed, 2 Dec 2026 11:18:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7F65C606A322 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=V2CTF0fX 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=gi/xjoAeVQdt7Ge1uMSGkJs6H+05GVpYiLuWfnVmQkQ=; b=V2CTF0fXXXNO33dOSxz+5Ej8TnAEduSZZWX5RAZZO/A7KabDNbKlZd/n/OdcyV imSsNtjBVl7e62tqmTLO9oeGV5dfGzJK06SC1uEMvvOru6kkO7gxssdfx4SHoGFu bFORcrwYpBfw2gxXjauJQASm4+NyRTHamkZy2o5PdWRLc= Message-ID: <1115389a-15a0-4871-974e-9353b0f27af2@163.com> Date: Wed, 2 Dec 2026 19:17:46 +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:QCgvCgCHjo5a_g9rL6G6JQ--.2726S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxGF15Ww4DCw1DJrWftF45GFg_yoW5Wr4kp3 9akFy7Kw4vqryDurn7WF45tFW0vr4FkFW5GrW8Jw1a9345J3W7KF10kayFq3srtr95CF1U AFn0v347Ar4UZFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UOqXdUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbC6R11QGsP-l3PYgAA3r 在 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.