From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Stefano Garzarella <sgarzare@redhat.com>, qemu-devel@nongnu.org
Cc: Hanna Reitz <hreitz@redhat.com>,
qemu-block@nongnu.org, John Snow <jsnow@redhat.com>,
Kevin Wolf <kwolf@redhat.com>
Subject: Re: [PATCH 1/2] block/backup: avoid integer overflow of `max-workers`
Date: Tue, 5 Oct 2021 19:25:34 +0300 [thread overview]
Message-ID: <ab53f4f8-da8a-df72-37b7-36714bd17f43@virtuozzo.com> (raw)
In-Reply-To: <20211005161157.282396-2-sgarzare@redhat.com>
10/5/21 19:11, Stefano Garzarella wrote:
> 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
I glad to see that someone experiments with my experimental API :)
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
> block/backup.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block/backup.c b/block/backup.c
> index 687d2882bc..8b072db5d9 100644
> --- a/block/backup.c
> +++ b/block/backup.c
> @@ -407,8 +407,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
> return NULL;
> }
>
> - if (perf->max_workers < 1) {
> - error_setg(errp, "max-workers must be greater than zero");
> + if (perf->max_workers < 1 || perf->max_workers > INT_MAX) {
> + error_setg(errp, "max-workers must be between 1 and %d", INT_MAX);
> return NULL;
> }
>
>
--
Best regards,
Vladimir
next prev parent reply other threads:[~2021-10-05 18:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-05 16:11 [PATCH 0/2] block: avoid integer overflow of `max-workers` and assert `max_busy_tasks` Stefano Garzarella
2021-10-05 16:11 ` [PATCH 1/2] block/backup: avoid integer overflow of `max-workers` Stefano Garzarella
2021-10-05 16:25 ` Vladimir Sementsov-Ogievskiy [this message]
2021-10-05 16:11 ` [PATCH 2/2] block/aio_task: assert `max_busy_tasks` is greater than 0 Stefano Garzarella
2021-10-05 16:28 ` Vladimir Sementsov-Ogievskiy
2021-10-05 16:38 ` [PATCH 0/2] block: avoid integer overflow of `max-workers` and assert `max_busy_tasks` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ab53f4f8-da8a-df72-37b7-36714bd17f43@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).