From: Bin Meng <bmeng.cn@gmail.com>
To: qemu-devel@nongnu.org
Cc: Bin Meng <bin.meng@windriver.com>, Fam Zheng <fam@euphon.net>,
Stefan Hajnoczi <stefanha@redhat.com>,
Stefan Weil <sw@weilnetz.de>,
qemu-block@nongnu.org
Subject: [PATCH 2/2] util/aio-win32: Correct the event array size in aio_poll()
Date: Fri, 5 Aug 2022 22:56:17 +0800 [thread overview]
Message-ID: <20220805145617.952881-2-bmeng.cn@gmail.com> (raw)
In-Reply-To: <20220805145617.952881-1-bmeng.cn@gmail.com>
From: Bin Meng <bin.meng@windriver.com>
WaitForMultipleObjects() can only wait for MAXIMUM_WAIT_OBJECTS
object handles. Correct the event array size in aio_poll() and
add a assert() to ensure it does not cause out of bound access.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
util/aio-win32.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/util/aio-win32.c b/util/aio-win32.c
index 44003d645e..8cf5779567 100644
--- a/util/aio-win32.c
+++ b/util/aio-win32.c
@@ -326,7 +326,7 @@ void aio_dispatch(AioContext *ctx)
bool aio_poll(AioContext *ctx, bool blocking)
{
AioHandler *node;
- HANDLE events[MAXIMUM_WAIT_OBJECTS + 1];
+ HANDLE events[MAXIMUM_WAIT_OBJECTS];
bool progress, have_select_revents, first;
int count;
int timeout;
@@ -369,6 +369,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
if (!node->deleted && node->io_notify
&& aio_node_check(ctx, node->is_external)) {
+ assert(count < MAXIMUM_WAIT_OBJECTS);
events[count++] = event_notifier_get_handle(node->e);
}
}
--
2.34.1
next prev parent reply other threads:[~2022-08-05 14:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-05 14:56 [PATCH 1/2] util/main-loop: Fix maximum number of wait objects for win32 Bin Meng
2022-08-05 14:56 ` Bin Meng [this message]
2022-08-05 15:09 ` [PATCH 2/2] util/aio-win32: Correct the event array size in aio_poll() Stefan Weil via
2022-08-09 16:38 ` Bin Meng
2022-08-08 15:53 ` [PATCH 1/2] util/main-loop: Fix maximum number of wait objects for win32 Bin Meng
2022-08-08 22:00 ` Philippe Mathieu-Daudé via
2022-08-09 13:15 ` Marc-André Lureau
2022-08-09 16:38 ` Bin Meng
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=20220805145617.952881-2-bmeng.cn@gmail.com \
--to=bmeng.cn@gmail.com \
--cc=bin.meng@windriver.com \
--cc=fam@euphon.net \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
/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).