OSDN Git Service

block: Catch integer overflow in bdrv_rw_co()
authorKevin Wolf <kwolf@redhat.com>
Mon, 14 Apr 2014 13:39:36 +0000 (15:39 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 22 Apr 2014 09:57:02 +0000 (11:57 +0200)
commitda15ee5134f715adb07e3688a1c6e8b42cb6ac94
tree5f33a291e25b374e131f2c4f375a3524183accf3
parent1dd3a44753f10970ded50950d28353c00bfcaf91
block: Catch integer overflow in bdrv_rw_co()

Insanely large requests could cause an integer overflow in
bdrv_rw_co() while converting sectors to bytes. This patch catches the
problem and returns an error (if we hadn't overflown the integer here,
bdrv_check_byte_request() would have rejected the request, so we're not
breaking anything that was supposed to work before).

We actually do have a test case that triggers behaviour where we
accidentally let such a request pass, so that it would return success,
but read 0 bytes instead of the requested 4 GB. It fails now like it
should.

If the vdi block driver wants to be able to deal with huge images, it
can't read the whole block bitmap at once into memory like it does
today, but needs to use a metadata cache like qcow2 does.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
tests/qemu-iotests/084.out