Skip to content

Commit 660b982

Browse files
error27namjaejeon
authored andcommitted
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>
1 parent dacc180 commit 660b982

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/ntfs/compress.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,8 @@ static int ntfs_write_cb(struct ntfs_inode *ni, loff_t pos, struct page **pages,
13741374
bio_size = insz;
13751375
}
13761376

1377-
new_vcn = ntfs_bytes_to_cluster(vol, pos & ~(ni->itype.compressed.block_size - 1));
1377+
new_vcn = ntfs_bytes_to_cluster(vol,
1378+
pos & ~((loff_t)ni->itype.compressed.block_size - 1));
13781379
new_length = ntfs_bytes_to_cluster(vol, round_up(bio_size, vol->cluster_size));
13791380

13801381
err = ntfs_non_resident_attr_punch_hole(ni, new_vcn, ni->itype.compressed.block_clusters);

0 commit comments

Comments
 (0)