summaryrefslogtreecommitdiff
path: root/tools/lib/python/feat
diff options
context:
space:
mode:
authorNanzhe Zhao <zhaonanzhe@xiaomi.com>2026-10-13 18:56:28 +0800
committerJaegeuk Kim <jaegeuk@kernel.org>2026-10-13 18:45:00 +0000
commitc04f209773ecb31e592cababce0d6658ee0b8d58 (patch)
treefadc790ae6e54f62b0be9c5f943d75adf7e7298d /tools/lib/python/feat
parent2eebc31ae5f53e1066bb6238c8087c23b688ad17 (diff)
f2fs: read i_size once in f2fs_vm_page_mkwrite
f2fs_vm_page_mkwrite() reads i_size twice: once to check whether the folio is partially beyond EOF, and once to calculate the offset for folio_zero_segment(). But a concurrent buffered write can extend isize and cause the following race condition to corrupt data: buffered write writes [0,3500) CPU0 (write fault) CPU1 (buffered write) ---- ---- f2fs_vm_page_mkwrite() folio_lock(folio) if (((loff_t)(folio->index + 1) << PAGE_SHIFT) > i_size_read(inode)) /* i_size_read() = 3500 */ write(fd, buf, 200, 4096) /* writes into page1, does not wait for folio lock */ i_size_write(inode, 4296) offset = i_size_read(inode) & ~PAGE_MASK /* i_size_read() = 4296, offset = 200 */ folio_zero_segment(folio, offset, folio_size(folio)) /* valid data [200, 3500) is zeroed */ Fix this by reading i_size once and using the same value for both the EOF check and the zeroing offset. Reported-by: Sashiko <sashiko-bot@kernel.org> Closes: https://sashiko.dev/#/patchset/20261012030315.978375-1-zhaonanzhe%40xiaomi.com Fixes: fbfa2cc58d53 ("f2fs: add file operations") Cc: stable@vger.kernel.org Signed-off-by: Nanzhe Zhao <zhaonanzhe@xiaomi.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'tools/lib/python/feat')
0 files changed, 0 insertions, 0 deletions