]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - fs/f2fs/file.c
f2fs: fix overflow of size calculation
authorChao Yu <chao2.yu@samsung.com>
Fri, 11 Sep 2015 06:43:52 +0000 (14:43 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 9 Oct 2015 23:20:50 +0000 (16:20 -0700)
commit9edcdabf36422d15d01db73b0fa5487e418beff6
tree0a0cf8522db1e617ef6cf9379ae9b5fd89e8a3bd
parent100136acfb4023ab7dc899192e95aca9aedfe98a
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>
fs/f2fs/data.c
fs/f2fs/debug.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/recovery.c