Received: from eggs.gnu.org ([2001:4830:134:3::10]:41168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3lxJ-0002Yd-PS for qemu-devel@nongnu.org; Mon, 07 Nov 2016 10:35:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3lxJ-0007oF-0r for qemu-devel@nongnu.org; Mon, 07 Nov 2016 10:35:29 -0500 References: <1478511214-31045-1-git-send-email-pbonzini@redhat.com> <1478511214-31045-2-git-send-email-pbonzini@redhat.com> <20161107145804.GC12471@stefanha-x1.localdomain> From: Paolo Bonzini Message-ID: <6a9b8288-503b-90ea-e827-5e7779154253@redhat.com> Date: Mon, 7 Nov 2016 16:35:19 +0100 MIME-Version: 1.0 In-Reply-To: <20161107145804.GC12471@stefanha-x1.localdomain> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/2] aio-posix: avoid NULL pointer dereference in aio_epoll_update List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org On 07/11/2016 15:58, Stefan Hajnoczi wrote: > 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 >> --- >> 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, >> =20 >> /* 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 =3D 1; >> - node->pfd.revents =3D 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 =3D true; >> - } >> + if (node =3D=3D NULL) { >> + return; >> + } >> + >> + node->pfd.events =3D 0; >=20 > ^--- is this left over from debugging... No, it's left over from solving conflicts. This is an old patch that got lost. Will send v2, thanks for the review! Paolo >> + 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 =3D 1; >> + node->pfd.revents =3D 0; >=20 > ...the original code clears revents here? >=20