]> git.ipfire.org Git - thirdparty/qemu.git/commit
util/async.c: Forbid negative min/max in aio_context_set_thread_pool_params()
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 23 Jul 2024 15:09:27 +0000 (16:09 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Sat, 27 Jul 2024 19:20:09 +0000 (22:20 +0300)
commitf043f7d8be6e4d9cdf4db075deca13d1ab773642
tree451691ff1668d5ef168271d3ab3cb9d71485d1e4
parentca834bcc4da868bc8890fbe8bfc7f2648cd527fc
util/async.c: Forbid negative min/max in aio_context_set_thread_pool_params()

aio_context_set_thread_pool_params() takes two int64_t arguments to
set the minimum and maximum number of threads in the pool.  We do
some bounds checking on these, but we don't catch the case where the
inputs are negative.  This means that later in the function when we
assign these inputs to the AioContext::thread_pool_min and
::thread_pool_max fields, which are of type int, the values might
overflow the smaller type.

A negative number of threads is meaningless, so make
aio_context_set_thread_pool_params() return an error if either min or
max are negative.

Resolves: Coverity CID 1547605
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20240723150927.1396456-1-peter.maydell@linaro.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
(cherry picked from commit 851495571d14fe2226c52b9d423f88a4f5460836)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
util/async.c