aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/debug.c
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2015-09-11 02:43:52 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2015-10-09 19:20:50 -0400
commit9edcdabf36422d15d01db73b0fa5487e418beff6 (patch)
tree0a0cf8522db1e617ef6cf9379ae9b5fd89e8a3bd /fs/f2fs/debug.c
parent100136acfb4023ab7dc899192e95aca9aedfe98a (diff)
f2fs: fix overflow of size calculation
We have potential overflow issue when calculating size of object, when we left shift index with PAGE_CACHE_SHIFT bits, if type of index has only 32-bits space in 32-bit architecture, left shifting will incur overflow, i.e: pgoff_t index = 0xFFFFFFFF; loff_t size = index << PAGE_CACHE_SHIFT; size: 0xFFFFF000 So we should cast index with 64-bits type to avoid this issue. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/debug.c')
-rw-r--r--fs/f2fs/debug.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index d013d8479753..ebfcc4039057 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -198,9 +198,9 @@ get_cache:
198 198
199 si->page_mem = 0; 199 si->page_mem = 0;
200 npages = NODE_MAPPING(sbi)->nrpages; 200 npages = NODE_MAPPING(sbi)->nrpages;
201 si->page_mem += npages << PAGE_CACHE_SHIFT; 201 si->page_mem += (unsigned long long)npages << PAGE_CACHE_SHIFT;
202 npages = META_MAPPING(sbi)->nrpages; 202 npages = META_MAPPING(sbi)->nrpages;
203 si->page_mem += npages << PAGE_CACHE_SHIFT; 203 si->page_mem += (unsigned long long)npages << PAGE_CACHE_SHIFT;
204} 204}
205 205
206static int stat_show(struct seq_file *s, void *v) 206static int stat_show(struct seq_file *s, void *v)
@@ -333,13 +333,13 @@ static int stat_show(struct seq_file *s, void *v)
333 333
334 /* memory footprint */ 334 /* memory footprint */
335 update_mem_info(si->sbi); 335 update_mem_info(si->sbi);
336 seq_printf(s, "\nMemory: %u KB\n", 336 seq_printf(s, "\nMemory: %llu KB\n",
337 (si->base_mem + si->cache_mem + si->page_mem) >> 10); 337 (si->base_mem + si->cache_mem + si->page_mem) >> 10);
338 seq_printf(s, " - static: %u KB\n", 338 seq_printf(s, " - static: %llu KB\n",
339 si->base_mem >> 10); 339 si->base_mem >> 10);
340 seq_printf(s, " - cached: %u KB\n", 340 seq_printf(s, " - cached: %llu KB\n",
341 si->cache_mem >> 10); 341 si->cache_mem >> 10);
342 seq_printf(s, " - paged : %u KB\n", 342 seq_printf(s, " - paged : %llu KB\n",
343 si->page_mem >> 10); 343 si->page_mem >> 10);
344 } 344 }
345 mutex_unlock(&f2fs_stat_mutex); 345 mutex_unlock(&f2fs_stat_mutex);