mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: liubaolin <liubaolin12138@163.com>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>,
	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
Subject: Re: [PATCH] ntfs: map a read past the end of the runlist as a hole
Date: Wed, 2 Dec 2026 19:28:05 +0800	[thread overview]
Message-ID: <883dccb6-044c-4628-8692-c48648e09c5c@163.com> (raw)
In-Reply-To: <1115389a-15a0-4871-974e-9353b0f27af2@163.com>



在 2026/12/2 19:17, liubaolin 写道:
> 
> 
> 在 2026/12/2 15:24, Zhan Xusheng 写道:
>> From: Zhan Xusheng <zhanxusheng@xiaomi.com>
>>
>> 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 <zhanxusheng@xiaomi.com>
>> ---
>> 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 <liubaolin@kylinos.cn>


      reply	other threads:[~2026-12-02 11:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  7:24 Zhan Xusheng
2026-12-02 10:38 ` liubaolin
2026-12-02 11:17 ` liubaolin
2026-12-02 11:28   ` liubaolin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=883dccb6-044c-4628-8692-c48648e09c5c@163.com \
    --to=liubaolin12138@163.com \
    --cc=ernest.borowski.git@proton.me \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=syzbot@syzkaller.appspotmail.com \
    --cc=zhanxusheng1024@gmail.com \
    --cc=zhanxusheng@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®