From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Fam Zheng <famz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL for-2.5 5/7] aio-epoll: Fix use-after-free of node
Date: Tue, 17 Nov 2015 19:17:26 +0800 [thread overview]
Message-ID: <1447759048-25772-6-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1447759048-25772-1-git-send-email-stefanha@redhat.com>
From: Fam Zheng <famz@redhat.com>
aio_epoll_update needs the fields in node, so delay the free.
Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-id: 1447655534-13974-1-git-send-email-famz@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
aio-posix.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/aio-posix.c b/aio-posix.c
index 06148a9..482b316 100644
--- a/aio-posix.c
+++ b/aio-posix.c
@@ -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,
--
2.5.0
next prev parent reply other threads:[~2015-11-17 11:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 11:17 [Qemu-devel] [PULL for-2.5 0/7] Block patches Stefan Hajnoczi
2015-11-17 11:17 ` [Qemu-devel] [PULL for-2.5 1/7] docs: update bitmaps.md Stefan Hajnoczi
2015-11-17 11:17 ` [Qemu-devel] [PULL for-2.5 2/7] tests: Ignore recent test binaries Stefan Hajnoczi
2015-11-17 11:17 ` [Qemu-devel] [PULL for-2.5 3/7] tpm: avoid clang shifting negative signed warning Stefan Hajnoczi
2015-11-17 11:17 ` [Qemu-devel] [PULL for-2.5 4/7] disas/arm: " Stefan Hajnoczi
2015-11-17 11:17 ` Stefan Hajnoczi [this message]
2015-11-17 11:17 ` [Qemu-devel] [PULL for-2.5 6/7] block: make 'stats-interval' an array of ints instead of a string Stefan Hajnoczi
2015-11-17 11:17 ` [Qemu-devel] [PULL for-2.5 7/7] virtio-blk: Fix double completion for werror=stop Stefan Hajnoczi
2015-11-17 12:33 ` [Qemu-devel] [PULL for-2.5 0/7] Block patches Peter Maydell
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=1447759048-25772-6-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=famz@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).