Skip to contentSkip to conversation

f2fs: fix to avoid overflow while left shift operation

PATCH In review Rajani Kantha 2 participants 2 messages Nov 14, 2025 – Nov 16, 2025 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: fix to avoid overflow while left shift operation

From: Chao Yu <[email protected]>

[ Upstream commit 0fe1c6bec54ea68ed8c987b3890f2296364e77bb ]

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")

[ Modification: Using rpages[i]->index instead of folio->index due to it was changed since commit:1cda5bc0b2fe ("f2fs: Use a folio in f2fs_truncate_partial_cluster()") on 6.14 ]

---
 fs/f2fs/compress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/compress.c +1 -1
index b05bb7bfa14c..fcd21bb060cd 100644
@@ -1236,7 +1236,7 @@ int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock)
 		int i;
 
 		for (i = cluster_size - 1; i >= 0; i--) {
-			loff_t start = rpages[i]->index << PAGE_SHIFT;
+			loff_t start = (loff_t)rpages[i]->index << PAGE_SHIFT;
 
 			if (from <= start) {
 				zero_user_segment(rpages[i], 0, PAGE_SIZE);
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Subject: f2fs: fix to avoid overflow while left shift operation

Thanks!