Haogang Chen 481fe17e97 nilfs2: potential integer overflow in nilfs_ioctl_clean_segments()
There is a potential integer overflow in nilfs_ioctl_clean_segments().
When a large argv[n].v_nmembs is passed from the userspace, the subsequent
call to vmalloc() will allocate a buffer smaller than expected, which
leads to out-of-bound access in nilfs_ioctl_move_blocks() and
lfs_clean_segments().

The following check does not prevent the overflow because nsegs is also
controlled by the userspace and could be very large.

		if (argv[n].v_nmembs > nsegs * nilfs->ns_blocks_per_segment)
			goto out_free;

This patch clamps argv[n].v_nmembs to UINT_MAX / argv[n].v_size, and
returns -EINVAL when overflow.

Signed-off-by: Haogang Chen <haogangchen@gmail.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-20 10:25:04 -08:00
..
2011-03-23 19:46:18 -07:00
2011-05-10 22:21:56 +09:00
2010-07-23 10:02:14 +09:00
2010-10-23 09:24:38 +09:00
2011-03-08 14:58:30 +09:00
2010-07-23 10:02:14 +09:00
2011-11-02 12:53:43 +01:00
2010-10-23 09:24:38 +09:00
2011-11-02 12:53:43 +01:00
2011-05-10 22:21:56 +09:00
2011-05-10 22:21:56 +09:00
2011-05-10 22:21:46 +09:00
2011-05-10 22:21:46 +09:00