Received: from eggs.gnu.org ([2001:4830:134:3::10]:38001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c50Gx-0002Qs-8h for qemu-devel@nongnu.org; Thu, 10 Nov 2016 20:04:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c50Gu-0007cI-KX for qemu-devel@nongnu.org; Thu, 10 Nov 2016 20:04:51 -0500 Date: Fri, 11 Nov 2016 10:52:17 +1100 From: David Gibson Message-ID: <20161110235217.GF18868@umbus.fritz.box> References: <1478808961-27379-1-git-send-email-thuth@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7mxbaLlpDEyR1+x6" Content-Disposition: inline In-Reply-To: <1478808961-27379-1-git-send-email-thuth@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 for-2.8] spapr-vty: Fix bad assert() statement List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: qemu-ppc@nongnu.org, Alexander Graf , qemu-devel@nongnu.org, Paolo Bonzini --7mxbaLlpDEyR1+x6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 10, 2016 at 09:16:01PM +0100, Thomas Huth wrote: > When using the serial console in the GTK interface of QEMU (and > QEMU has been compiled with CONFIG_VTE), it is possible to trigger > the assert() statement in vty_receive() in spapr_vty.c by pasting > a chunk of text with length > 16 into the QEMU window. > Most of the other serial backends seem to simply drop characters > that they can not handle, so I think we should also do the same in > spapr-vty to fix this issue. >=20 > Buglink: https://bugs.launchpad.net/qemu/+bug/1639322 > Signed-off-by: Thomas Huth > --- > v2: > - Do not increase the buffer size since this breaks migration. > (We should figure out a better solution for the size of the > buffer once 2.8 is released) Applied to ppc-for-2.8. since actually hitting the assert is clearly bad. I still think this smells like a bug on the other side of the chardev, feeding in more characters than the can_receive() hook says can be supplied. >=20 > hw/char/spapr_vty.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c > index 31822fe..06b9b39 100644 > --- a/hw/char/spapr_vty.c > +++ b/hw/char/spapr_vty.c > @@ -1,4 +1,5 @@ > #include "qemu/osdep.h" > +#include "qemu/error-report.h" > #include "qapi/error.h" > #include "qemu-common.h" > #include "cpu.h" > @@ -37,7 +38,15 @@ static void vty_receive(void *opaque, const uint8_t *b= uf, int size) > qemu_irq_pulse(spapr_vio_qirq(&dev->sdev)); > } > for (i =3D 0; i < size; i++) { > - assert((dev->in - dev->out) < VTERM_BUFSIZE); > + if (dev->in - dev->out >=3D VTERM_BUFSIZE) { > + static bool reported; > + if (!reported) { > + error_report("VTY input buffer exhausted - characters dr= opped." > + " (input size =3D %i)", size); > + reported =3D true; > + } > + break; > + } > dev->buf[dev->in++ % VTERM_BUFSIZE] =3D buf[i]; > } > } --=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 --7mxbaLlpDEyR1+x6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYJQgxAAoJEGw4ysog2bOS4LQP/0YxbFCwannQsjY8tTK9JBvK hjkvalbN8rmthusR3+AgFwRbnsuGp4+BHJB0FJbCYnjCDXrgPistMMT9DAQ1ffEd 5s765p9HCz55y69FhSzFoJ43t7f6CROjOsbbTu9pE2AqlRBEnxeErHurXMdZA0Up gZ8WjkavBDAKh0Mc/Y3thrlK5GpyZQMXhSJ2Vl2/VaFagQlXcUBG6hZ626euiu5E 48fyzIOrXlbtPhtQO0VWDdxCJGgP1qCQ0FJEuTsLDJY5c91lU+CDmDHg/7kQpVLh UBy8Tg1zjK6ZLAnIqbuevInHGH+X8Ot7zCU948AuZWfVpj/DZgMgeSVYqAUpr7WK 2CZDwTZ/yPv9ap4iy6ZnO4zOQtpbuxnDmHvK1loqeWs+RK9UFh6UkSzV0ii9D5Yv vjqCbXv0rrB7dWxoJH1EiNQbdt4omTNrv04OG493NOs8JBnX0KQr/hgdBped8aW/ 4bzbznleacWrhgEqAnOARRLYL/qYkDSTNevAKMGoDHe4jBxjbGaP9yit5qxhLhD1 XcAWQ/xx21Zjal+y9+/GWqh7+O1+z3V7JFnCX8pRgMWCjn4IL8kgDbw2ZZCbIzNq tQ0dWFnE4Y7m/ElacKyLkUgVQQp4lMemWX7sWE/MFNLDI1TXBPfPYI6OOUEZnHC3 0EiOenNAliwM6c5w/h1t =daV4 -----END PGP SIGNATURE----- --7mxbaLlpDEyR1+x6--