Files
linux/fs/f2fs
Wei Fang 0678adf8f8 f2fs: fix a dead loop in f2fs_fiemap()
commit b86e33075e upstream.

A dead loop can be triggered in f2fs_fiemap() using the test case
as below:

	...
	fd = open();
	fallocate(fd, 0, 0, 4294967296);
	ioctl(fd, FS_IOC_FIEMAP, fiemap_buf);
	...

It's caused by an overflow in __get_data_block():
	...
	bh->b_size = map.m_len << inode->i_blkbits;
	...
map.m_len is an unsigned int, and bh->b_size is a size_t which is 64 bits
on 64 bits archtecture, type conversion from an unsigned int to a size_t
will result in an overflow.

In the above-mentioned case, bh->b_size will be zero, and f2fs_fiemap()
will call get_data_block() at block 0 again an again.

Fix this by adding a force conversion before left shift.

Signed-off-by: Wei Fang <fangwei1@huawei.com>
Acked-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-16 10:06:51 +02:00
..
2018-05-16 10:06:51 +02:00
2015-10-09 16:20:56 -07:00
2015-08-21 22:43:32 -07:00
2015-10-12 14:03:43 -07:00
2015-10-12 14:03:43 -07:00
2015-08-20 09:00:06 -07:00
2015-11-13 20:34:34 -05:00