aio-epoll: Fix use-after-free of node
PATCH 1/1 aio-epoll: Fix use-after-free of node
aio_epoll_update needs the fields in node, so delay the free.
Reported-by Paolo Bonzini <[email protected]>
Signed-off-by Fam Zheng <[email protected]>
--- aio-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
aio-posix.c +5 -1
@@ -210,6 +210,7 @@ void aio_set_fd_handler(AioContext *ctx, {AioHandler *node;bool is_new = false; +bool deleted = false; node =find_aio_handler (ctx, fd);
@@ -228,7 +229,7 @@ void aio_set_fd_handler(AioContext *ctx,* releasing the walking_handlers lock. */ QLIST_REMOVE (node, node); -g_free (node); + deleted = true; } } }else {
@@ -253,6 +254,9 @@ void aio_set_fd_handler(AioContext *ctx,aio_epoll_update (ctx, node, is_new);aio_notify (ctx); +if (deleted) { +g_free (node); + } } void aio_set_event_notifier(AioContext *ctx,
Signature · 1 line
2.4.3
Stefan Hajnoczi
AppliedQuoted 7 lines · Fam Zheng
aio_epoll_updateneeds the fields in node, so delay the free.Reported-by Paolo Bonzini <[email protected]>Signed-off-by Fam Zheng <[email protected]>--- aio-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan