From: Stefan Hajnoczi <stefanha@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, famz@redhat.com,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/2] aio-posix: avoid NULL pointer dereference in aio_epoll_update
Date: Mon, 7 Nov 2016 14:58:04 +0000 [thread overview]
Message-ID: <20161107145804.GC12471@stefanha-x1.localdomain> (raw)
In-Reply-To: <1478511214-31045-2-git-send-email-pbonzini@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1775 bytes --]
On Mon, Nov 07, 2016 at 10:33:33AM +0100, Paolo Bonzini wrote:
> aio_epoll_update dereferences parameter "node", but it could have been NULL
> if deleting an fd handler that was not registered in the first place.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> aio-posix.c | 33 ++++++++++++++++++---------------
> 1 file changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/aio-posix.c b/aio-posix.c
> index 4ef34dd..ec908f7 100644
> --- a/aio-posix.c
> +++ b/aio-posix.c
> @@ -217,21 +217,24 @@ void aio_set_fd_handler(AioContext *ctx,
>
> /* Are we deleting the fd handler? */
> if (!io_read && !io_write) {
> - if (node) {
> - g_source_remove_poll(&ctx->source, &node->pfd);
> -
> - /* If the lock is held, just mark the node as deleted */
> - if (ctx->walking_handlers) {
> - node->deleted = 1;
> - node->pfd.revents = 0;
> - } else {
> - /* Otherwise, delete it for real. We can't just mark it as
> - * deleted because deleted nodes are only cleaned up after
> - * releasing the walking_handlers lock.
> - */
> - QLIST_REMOVE(node, node);
> - deleted = true;
> - }
> + if (node == NULL) {
> + return;
> + }
> +
> + node->pfd.events = 0;
^--- is this left over from debugging...
> + g_source_remove_poll(&ctx->source, &node->pfd);
> +
> + /* If the lock is held, just mark the node as deleted */
> + if (ctx->walking_handlers) {
> + node->deleted = 1;
> + node->pfd.revents = 0;
...the original code clears revents here?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2016-11-07 14:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 9:33 [Qemu-devel] [PATCH for-2.8 0/2] aio-posix: epoll cleanups Paolo Bonzini
2016-11-07 9:33 ` [Qemu-devel] [PATCH 1/2] aio-posix: avoid NULL pointer dereference in aio_epoll_update Paolo Bonzini
2016-11-07 14:58 ` Stefan Hajnoczi [this message]
2016-11-07 15:35 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2016-11-07 9:33 ` [Qemu-devel] [PATCH 2/2] aio-posix: simplify aio_epoll_update Paolo Bonzini
2016-11-07 15:01 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-11-07 10:08 ` [Qemu-devel] [PATCH for-2.8 0/2] aio-posix: epoll cleanups Fam Zheng
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=20161107145804.GC12471@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.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).