dm table: fail dm_table_create on dm_round_up overflow
authorMikulas Patocka <mpatocka@redhat.com>
Sat, 23 Nov 2013 00:52:06 +0000 (19:52 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Dec 2013 15:45:11 +0000 (07:45 -0800)
commit135949c10b4f97eaf9da90535e18c6a2a0e2993a
treed5f012c6939d14f65e7eb5ebcce7d695a566a9b3
parent2c54d62aa894ff2675272e0570abcb0ab76a3aa4
dm table: fail dm_table_create on dm_round_up overflow

commit 5b2d06576c5410c10d95adfd5c4d8b24de861d87 upstream.

The dm_round_up function may overflow to zero.  In this case,
dm_table_create() must fail rather than go on to allocate an empty array
with alloc_targets().

This fixes a possible memory corruption that could be caused by passing
too large a number in "param->target_count".

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-table.c