From: Chao Yu Date: Wed, 25 Jan 2017 02:52:39 +0000 (+0800) Subject: f2fs: fix to avoid overflow when left shifting page offset X-Git-Tag: v4.11-rc1~34^2~64 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=dba79f38bc60d98b605bdbbf5613aa3fb8f8ff7c;p=karo-tx-linux.git f2fs: fix to avoid overflow when left shifting page offset We use following method to calculate size with current page index: size = index << PAGE_SHIFT If type of index has only 32-bits size, left shifting will incur overflow, which makes result incorrect. So let's cast index with 64-bits type to avoid such issue. Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim --- diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index 4fb4471a3206..e93316ea8d1b 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -428,8 +428,9 @@ retry_dn: } if (!file_keep_isize(inode) && - (i_size_read(inode) <= (start << PAGE_SHIFT))) - f2fs_i_size_write(inode, (start + 1) << PAGE_SHIFT); + (i_size_read(inode) <= ((loff_t)start << PAGE_SHIFT))) + f2fs_i_size_write(inode, + (loff_t)(start + 1) << PAGE_SHIFT); /* * dest is reserved block, invalidate src block