OSDN Git Service

block/backup: avoid integer overflow of `max-workers`
authorStefano Garzarella <sgarzare@redhat.com>
Tue, 5 Oct 2021 16:11:56 +0000 (18:11 +0200)
committerVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Tue, 5 Oct 2021 16:56:20 +0000 (18:56 +0200)
commit8fc898ce0b3e7fea8c7c2a8d8977f2a9b77ecebf
tree9bc76e1402ddc47d2c6741ff3d226dccfe37d74c
parent9618c5badaa8eed25259cf095ff880efb939fbe7
block/backup: avoid integer overflow of `max-workers`

QAPI generates `struct BackupPerf` where `max-workers` value is stored
in an `int64_t` variable.
But block_copy_async(), and the underlying code, uses an `int` parameter.

At the end that variable is used to initialize `max_busy_tasks` in
block/aio_task.c causing the following assertion failure if a value
greater than INT_MAX(2147483647) is used:

  ../block/aio_task.c:63: aio_task_pool_wait_one: Assertion `pool->busy_tasks > 0' failed.

Let's check that `max-workers` doesn't exceed INT_MAX and print an
error in that case.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2009310
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20211005161157.282396-2-sgarzare@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
block/backup.c