From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50664) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHmam-0007Zq-WF for qemu-devel@nongnu.org; Tue, 28 Jun 2016 02:33:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHmaj-0000gd-NE for qemu-devel@nongnu.org; Tue, 28 Jun 2016 02:33:52 -0400 Date: Tue, 28 Jun 2016 16:24:22 +1000 From: David Gibson Message-ID: <20160628062422.GF4242@voom.fritz.box> References: <146704489509.8607.12236848738501803903.stgit@bahia.lan> <20160628025507.GS4242@voom.fritz.box> <20160628072416.2c1f2286@bahia.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qpqR4wE1CEr+Roqx" Content-Disposition: inline In-Reply-To: <20160628072416.2c1f2286@bahia.lan> Subject: Re: [Qemu-devel] [PATCH] spapr: fix write-past-end-of-array error in cpu core device init code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Alexander Graf , bharata@linux.vnet.ibm.com --qpqR4wE1CEr+Roqx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 28, 2016 at 07:24:16AM +0200, Greg Kurz wrote: > On Tue, 28 Jun 2016 12:55:07 +1000 > David Gibson wrote: >=20 > > On Mon, Jun 27, 2016 at 06:28:15PM +0200, Greg Kurz wrote: > > > This fixes a potential QEMU crash introduced by commit 3b542549661. > > >=20 > > > Signed-off-by: Greg Kurz > > > --- > > > hw/ppc/spapr_cpu_core.c | 3 +-- > > > 1 file changed, 1 insertion(+), 2 deletions(-) =20 > >=20 > > Ugh. The existing code is wrong in the case where the failure happens > > after the loop. > >=20 > > But this version is wrong in the case it happens during the loop - it > > will fail to clean up the last object created. > >=20 >=20 > Hmm... unless I'm missing something, if object_property_add_child() fails= to > add object i, we don't want to unparent it, and we should start rollback > at index i-1. Good point, my mistake. I'll apply this fix. >=20 > Another weirdness is that I see no rollback for the object_child_foreach() > loop: in case of failure, we will unparent realized objects... is it > okay ? Um.. I have no idea. Bharata? Alex? >=20 > > > diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c > > > index 3a5da09b9902..8b802a6fcf0b 100644 > > > --- a/hw/ppc/spapr_cpu_core.c > > > +++ b/hw/ppc/spapr_cpu_core.c > > > @@ -309,10 +309,9 @@ static void spapr_cpu_core_realize(DeviceState *= dev, Error **errp) > > > } > > > =20 > > > err: > > > - while (i >=3D 0) { > > > + while (--i >=3D 0) { > > > obj =3D sc->threads + i * size; > > > object_unparent(obj); > > > - i--; > > > } > > > g_free(sc->threads); > > > error_propagate(errp, local_err); > > > =20 > >=20 >=20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --qpqR4wE1CEr+Roqx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXchgWAAoJEGw4ysog2bOSpGsQAJ1g3rdYwmib5xlwJK9pjWSw DJAK8L4gCX7RZzLM9Vu8Xt9rQwsBwQjAKIsvhgj4tN65BHKWYu8nY8NSveFKn18u WvNwEeLsakiEPnW0X9aIUn/t6FH/H+JPsG61dIM+KinwJUa8XjxqVMPX54jd93KP 0bL/WPEeyi0x4gdcpAsurZNZrsdBzqhdsRiPwBXpV5E8BHo/l59O7vxEhZ2L4ECu hNt5POneENpEBx7V3XFDcSVfnOLmrI8FMQi8V/c6pY0isP8I7pTlmQNwAKakJWPJ L6m7YSndQs/xnGqrDL5OlevehUNC/0MOPlUqmYjVvwmGQ2Y991xa5eA3T6PtuniV yz6wbkWvnaZ4t/kJuBaztRf2ib2olfnNXKwaY8xl5KGEVWehvoUoJhsQJ5PWtE1s kYZqRKBBu/FJfIkXwhOIGeMslWF/pPnrugoK8aVHzbZQlvpkvJjhMzYOH1GFMMYX VP/0bXAGSol6TKibteGvoKr0eToyFnl40Ur4GTTDnqC5ay0flsWhLi8wLF9OKYWx N6JyNqAU+vV46AQW2UzisTo5h0E+LR4LWltwaxV4ytvcAUyPjmVIiOZ2wW5wEIg/ feO81gMcuN3jvNUKyl8I1wSEO1laZEmbJBuLnkh9hTby6WR11aEietRx9YnHfyo1 wUgXa7VGkTyNku0KuF6J =dZO5 -----END PGP SIGNATURE----- --qpqR4wE1CEr+Roqx--