[ Sasha's backport helper bot ] Hi, ✅ All tests passed successfully. No issues detected. No action required from the submitter. The upstream commit SHA1 provided is correct: c380b52f6c5702cc4bdda5e6d456d6c19a201a0b WARNING: Author mismatch between patch and upstream commit: Backport author: <miguelgarciaroman8@xxxxxxxxx> Commit author: Konstantin Komarov<almaz.alexandrovich@xxxxxxxxxxxxxxxxxxxx> Status in newer kernel trees: 6.13.y | Present (exact SHA1) 6.12.y | Present (exact SHA1) 6.6.y | Present (exact SHA1) Note: The patch differs from the upstream commit: --- 1: c380b52f6c570 ! 1: d24d9a62db4cb fs/ntfs3: Change new sparse cluster processing @@ Metadata ## Commit message ## fs/ntfs3: Change new sparse cluster processing + commit c380b52f6c5702cc4bdda5e6d456d6c19a201a0b upstream. + + This patch is a backport. Remove ntfs_sparse_cluster. Zero clusters in attr_allocate_clusters. Fixes xfstest generic/263 + The fix has been verified by executing the syzkaller reproducer test case. + + Bug: https://syzkaller.appspot.com/bug?extid=f3e5d0948a1837ed1bb0 + Reported-by: syzbot+f3e5d0948a1837ed1bb0@xxxxxxxxxxxxxxxxxxxxxxxxx + Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@xxxxxxxxxxxxxxxxxxxx> + Signed-off-by: Miguel Garcia Roman <miguelgarciaroman8@xxxxxxxxx> + (cherry picked from commit c380b52f6c5702cc4bdda5e6d456d6c19a201a0b) ## fs/ntfs3/attrib.c ## @@ fs/ntfs3/attrib.c: static int run_deallocate_ex(struct ntfs_sb_info *sbi, struct runs_tree *run, @@ fs/ntfs3/attrib.c: int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST struct mft_inode *mi, *mi_b; - CLST hint, svcn, to_alloc, evcn1, next_svcn, asize, end; + CLST hint, svcn, to_alloc, evcn1, next_svcn, asize, end, vcn0, alen; -+ unsigned fr; ++ unsigned int fr; u64 total_size; - u32 clst_per_frame; - bool ok; @@ fs/ntfs3/file.c: static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vb -{ - struct address_space *mapping = inode->i_mapping; - struct ntfs_sb_info *sbi = inode->i_sb->s_fs_info; -- u8 cluster_bits = sbi->cluster_bits; -- u64 vbo = (u64)vcn << cluster_bits; -- u64 bytes = (u64)len << cluster_bits; +- u64 vbo = (u64)vcn << sbi->cluster_bits; +- u64 bytes = (u64)len << sbi->cluster_bits; - u32 blocksize = 1 << inode->i_blkbits; - pgoff_t idx0 = page0 ? page0->index : -1; - loff_t vbo_clst = vbo & sbi->cluster_mask_inv; @@ fs/ntfs3/file.c: static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vb - - zero_user_segment(page, from, to); - -- if (!partial) -- SetPageUptodate(page); -- flush_dcache_page(page); -- set_page_dirty(page); +- if (!partial) { +- if (!PageUptodate(page)) +- SetPageUptodate(page); +- set_page_dirty(page); +- } - - if (idx != idx0) { - unlock_page(page); @@ fs/ntfs3/file.c: static int ntfs_zero_range(struct inode *inode, u64 vbo, u64 vb - } - cond_resched(); - } +- mark_inode_dirty(inode); -} - /* @@ fs/ntfs3/file.c: static long ntfs_fallocate(struct file *file, int mode, loff_t u32 frame_size; loff_t mask, vbo_a, end_a, tmp; -- err = filemap_write_and_wait_range(mapping, vbo, LLONG_MAX); +- err = filemap_write_and_wait_range(mapping, vbo, end - 1); +- if (err) +- goto out; +- +- err = filemap_write_and_wait_range(mapping, end, LLONG_MAX); + err = filemap_write_and_wait_range(mapping, vbo_down, + LLONG_MAX); if (err) @@ fs/ntfs3/file.c: static long ntfs_fallocate(struct file *file, int mode, loff_t goto out; if (is_supported_holes) { -- CLST vcn_v = bytes_to_cluster(sbi, ni->i_valid); +- CLST vcn_v = ni->i_valid >> sbi->cluster_bits; CLST vcn = vbo >> sbi->cluster_bits; CLST cend = bytes_to_cluster(sbi, end); + CLST cend_v = bytes_to_cluster(sbi, ni->i_valid); --- Results of testing on various branches: | Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.1.y | Success | Success |