Received: from eggs.gnu.org ([2001:4830:134:3::10]:58131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3lND-00052X-CH for qemu-devel@nongnu.org; Mon, 07 Nov 2016 09:58:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3lNA-0002Zr-9z for qemu-devel@nongnu.org; Mon, 07 Nov 2016 09:58:11 -0500 Date: Mon, 7 Nov 2016 14:58:04 +0000 From: Stefan Hajnoczi Message-ID: <20161107145804.GC12471@stefanha-x1.localdomain> References: <1478511214-31045-1-git-send-email-pbonzini@redhat.com> <1478511214-31045-2-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dkEUBIird37B8yKS" Content-Disposition: inline In-Reply-To: <1478511214-31045-2-git-send-email-pbonzini@redhat.com> 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: Paolo Bonzini Cc: qemu-devel@nongnu.org, kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org --dkEUBIird37B8yKS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 07, 2016 at 10:33:33AM +0100, Paolo Bonzini wrote: > aio_epoll_update dereferences parameter "node", but it could have been NU= LL > if deleting an fd handler that was not registered in the first place. >=20 > Signed-off-by: Paolo Bonzini > --- > aio-posix.c | 33 ++++++++++++++++++--------------- > 1 file changed, 18 insertions(+), 15 deletions(-) >=20 > 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 aft= er > - * releasing the walking_handlers lock. > - */ > - QLIST_REMOVE(node, node); > - deleted =3D true; > - } > + if (node =3D=3D NULL) { > + return; > + } > + > + node->pfd.events =3D 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 =3D 1; > + node->pfd.revents =3D 0; =2E..the original code clears revents here? --dkEUBIird37B8yKS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJYIJZ8AAoJEJykq7OBq3PI0wYH/0+HfvZ9f+wtXZ9SJtBT5oCH ek0BqjsBaQ4yDYl3V34fgN9f85YHu+NFw1+wxbuYXkopTBOXnW3WX9TStll86UrT j2i2v02NC/4uuKGsUH/TkoYNiTmGRvG78VS6cmhvgd1r5dE8lkBD1Tfjrl2Hg3/7 2Kqvl7ddsS85DDXLoZoyVG/HE6fP5k8HENltpY2ESQmQ/nS9CNaNLfabe29+IXVE nMv3n5QxGWin4mslnlxyeQb9CMBOm6IfeBWzdqkLoRGyfenRDRvWDaKmhrKgCiUG MakMlUicCaowrnBW22XUOZuzSlhSvtSEzJttYFk3qO0jxa4wSK9Xdwy9ni8U4Go= =jHuY -----END PGP SIGNATURE----- --dkEUBIird37B8yKS--