]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
f2fs: fix to avoid overflow while left shift operation
authorChao Yu <chao@kernel.org>
Tue, 5 Aug 2025 06:29:10 +0000 (14:29 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 11 Aug 2025 17:03:54 +0000 (17:03 +0000)
Should cast type of folio->index from pgoff_t to loff_t to avoid overflow
while left shift operation.

Fixes: 3265d3db1f16 ("f2fs: support partial truncation on compressed inode")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/compress.c

index 5c1f47e45dab47d4c8b3c52e3171cc3b060d867e..6cd8902849cf6efb2f4cad57050bedd414e3adb2 100644 (file)
@@ -1245,7 +1245,7 @@ int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock)
 
                for (i = cluster_size - 1; i >= 0; i--) {
                        struct folio *folio = page_folio(rpages[i]);
-                       loff_t start = folio->index << PAGE_SHIFT;
+                       loff_t start = (loff_t)folio->index << PAGE_SHIFT;
 
                        if (from <= start) {
                                folio_zero_segment(folio, 0, folio_size(folio));