From: Dan Carpenter Date: Fri, 10 Apr 2026 15:24:49 +0000 (+0900) Subject: ntfs: fix potential 32-bit truncation in ntfs_write_cb() X-Git-Tag: v7.1-rc1~14^2~2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=660b982305cebd242df52fe87adf6b203a12f9be;p=thirdparty%2Fkernel%2Flinux.git ntfs: fix potential 32-bit truncation in ntfs_write_cb() Smatch warned that the bitwise negation in ntfs_write_cb() might lead to unintended truncation. Casting the block size to loff_t before bitwise negation prevents the upper 32 bits of pos from being incorrectly zeroed out during the calculation of new_vcn. Signed-off-by: Dan Carpenter Reviewed-by: Hyunchul Lee Signed-off-by: Namjae Jeon --- diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c index 71a8d9c42674..76bd806b41ed 100644 --- a/fs/ntfs/compress.c +++ b/fs/ntfs/compress.c @@ -1374,7 +1374,8 @@ static int ntfs_write_cb(struct ntfs_inode *ni, loff_t pos, struct page **pages, bio_size = insz; } - new_vcn = ntfs_bytes_to_cluster(vol, pos & ~(ni->itype.compressed.block_size - 1)); + new_vcn = ntfs_bytes_to_cluster(vol, + pos & ~((loff_t)ni->itype.compressed.block_size - 1)); new_length = ntfs_bytes_to_cluster(vol, round_up(bio_size, vol->cluster_size)); err = ntfs_non_resident_attr_punch_hole(ni, new_vcn, ni->itype.compressed.block_clusters);