]> git.karo-electronics.de Git - karo-tx-linux.git/commit
nilfs2: potential integer overflow in nilfs_ioctl_clean_segments()
authorHaogang Chen <haogangchen@gmail.com>
Fri, 16 Dec 2011 04:49:23 +0000 (15:49 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 19 Dec 2011 07:19:12 +0000 (18:19 +1100)
commitad7008b8dd2ed2ef8c724384208594841e6b5c7d
tree069cd4d72de6ce65e48a665fdffa4eac8e9c5b87
parentf33fb1397d311acb17de029e1b1257b0896c7153
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>
fs/nilfs2/ioctl.c