From: liubaolin <liubaolin12138@163.com>
To: Hongling Zeng <zenghongling@kylinos.cn>,
linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
zhongling0719@126.com, stable@vger.kernel.org
Subject: Re: [PATCH 6/6] ntfs: read initialized_size under size_lock in the mmap prepare path
Date: Wed, 25 Nov 2026 22:08:36 +0800 [thread overview]
Message-ID: <29998421-6c86-4130-a3b9-57aec80bc327@163.com> (raw)
In-Reply-To: <20261125073547.154150-7-zenghongling@kylinos.cn>
在 2026/11/25 15:35, Hongling Zeng 写道:
> ntfs_file_mmap_prepare() reads ni->initialized_size without the
> size lock when deciding whether a shared writable mapping needs
> its initialized size extended before the faults start. The field
> is published under size_lock, so the read is a data race on the
> protocol the other readers follow: a stale low value causes a
> redundant call that __ntfs_extend_initialized_size() re-checks
> under the lock, and a stale high value skips the extension and
> leaves it to the write faults.
>
> Take the snapshot under size_lock like the other readers.
>
> Fixes: 9c87959601e8 ("ntfs: update file operations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
> fs/ntfs/file.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
> index 70a86d6fee6b..1f08fe679a86 100644
> --- a/fs/ntfs/file.c
> +++ b/fs/ntfs/file.c
> @@ -1044,14 +1044,20 @@ int ntfs_file_mmap_prepare(struct vm_area_desc *desc)
>
> if (vma_desc_test_all(desc, VMA_SHARED_BIT, VMA_MAYWRITE_BIT)) {
> struct inode *inode = file_inode(file);
> + struct ntfs_inode *ni = NTFS_I(inode);
> loff_t from, to;
> + loff_t initialized_size;
> + unsigned long flags;
> int err;
>
> from = ((loff_t)desc->pgoff << PAGE_SHIFT);
> to = min_t(loff_t, i_size_read(inode),
> from + desc->end - desc->start);
>
> - if (NTFS_I(inode)->initialized_size < to) {
> + read_lock_irqsave(&ni->size_lock, flags);
> + initialized_size = ni->initialized_size;
> + read_unlock_irqrestore(&ni->size_lock, flags);
> + if (initialized_size < to) {
> err = ntfs_extend_initialized_size(inode, to, to);
> if (err)
> return err;
Looks good to me.
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
prev parent reply other threads:[~2026-11-25 14:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 7:35 [PATCH 0/6] ntfs: synchronize the in-memory size handling Hongling Zeng
2026-11-25 7:35 ` [PATCH 1/6] ntfs: mark the record dirtied by a resident write at iomap begin Hongling Zeng
2026-11-25 7:35 ` [PATCH 2/6] ntfs: roll back the size update when the attribute lookup fails Hongling Zeng
2026-11-25 14:05 ` liubaolin
2026-11-25 7:35 ` [PATCH 3/6] ntfs: read initialized_size under size_lock in the iomap paths Hongling Zeng
2026-11-25 14:07 ` liubaolin
2026-11-25 7:35 ` [PATCH 4/6] ntfs: update the in-memory sizes under the size lock Hongling Zeng
2026-11-25 14:08 ` liubaolin
2026-11-25 7:35 ` [PATCH 5/6] ntfs: serialize the mmap write fault initialized size update Hongling Zeng
2026-11-25 14:08 ` liubaolin
2026-11-25 7:35 ` [PATCH 6/6] ntfs: read initialized_size under size_lock in the mmap prepare path Hongling Zeng
2026-11-25 14:08 ` 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=29998421-6c86-4130-a3b9-57aec80bc327@163.com \
--to=liubaolin12138@163.com \
--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=zenghongling@kylinos.cn \
--cc=zhongling0719@126.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®