summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2026-04-11 00:24:49 +0900
committerNamjae Jeon <linkinjeon@kernel.org>2026-04-18 11:33:21 +0900
commit660b982305cebd242df52fe87adf6b203a12f9be (patch)
tree0c86d77909206128225604e893e2e03a27ec3704
parentdacc18029ef69ed225fdb4d7c3215c285e9e8ef4 (diff)
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 <error27@gmail.com> Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
-rw-r--r--fs/ntfs/compress.c3
1 files changed, 2 insertions, 1 deletions
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);