Received: from eggs.gnu.org ([2001:4830:134:3::10]:59487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBbNT-0000zW-Ky for qemu-devel@nongnu.org; Tue, 22 Dec 2015 23:50:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBbNQ-0003YR-Fd for qemu-devel@nongnu.org; Tue, 22 Dec 2015 23:50:19 -0500 Received: from mail-pa0-x230.google.com ([2607:f8b0:400e:c03::230]:36810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBbNQ-0003Y7-A2 for qemu-devel@nongnu.org; Tue, 22 Dec 2015 23:50:16 -0500 Received: by mail-pa0-x230.google.com with SMTP id q3so106681453pav.3 for ; Tue, 22 Dec 2015 20:50:16 -0800 (PST) Date: Wed, 23 Dec 2015 12:50:12 +0800 From: Stefan Hajnoczi Message-ID: <20151223045012.GD5149@stefanha-x1.localdomain> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SO98HVl1bnMOfKZd" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH v2] net: rocker: fix an incorrect array bounds check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: P J P Cc: Jiri Pirko , jasowang@redhat.com, qemu-devel@nongnu.org, Qinghao Tang , Scott Feldman , Paolo Bonzini --SO98HVl1bnMOfKZd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 23, 2015 at 12:54:18AM +0530, P J P wrote: > Hello Paolo, all >=20 > Please see an updated patch below, as per suggestion in > -> https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg04057.html Adding Jason Wang (net maintainer) on CC. > =3D=3D=3D > >From 344a487d637be20b3fb110bec36cb703e7f6ecaa Mon Sep 17 00:00:00 2001 > From: Prasad J Pandit > Date: Wed, 23 Dec 2015 00:40:13 +0530 > Subject: [PATCH v2] net: rocker: fix an incorrect array bounds check >=20 > While processing transmit(tx) descriptors in 'tx_consume' routine > the switch emulator suffers from an off-by-one error, if a > descriptor was to have more than allowed(ROCKER_TX_FRAGS_MAX=3D16) > fragments. Fix an incorrect bounds check to avoid it. >=20 > Reported-by: Qinghao Tang > Signed-off-by: Prasad J Pandit > --- > hw/net/rocker/rocker.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) >=20 > diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c > index c57f1a6..2e77e50 100644 > --- a/hw/net/rocker/rocker.c > +++ b/hw/net/rocker/rocker.c > @@ -232,6 +232,9 @@ static int tx_consume(Rocker *r, DescInfo *info) > frag_addr =3D rocker_tlv_get_le64(tlvs[ROCKER_TLV_TX_FRAG_ATTR_A= DDR]); > frag_len =3D rocker_tlv_get_le16(tlvs[ROCKER_TLV_TX_FRAG_ATTR_LE= N]); >=20 > + if (iovcnt >=3D ROCKER_TX_FRAGS_MAX) { > + goto err_too_many_frags; > + } > iov[iovcnt].iov_len =3D frag_len; > iov[iovcnt].iov_base =3D g_malloc(frag_len); > if (!iov[iovcnt].iov_base) { > @@ -244,10 +247,7 @@ static int tx_consume(Rocker *r, DescInfo *info) > err =3D -ROCKER_ENXIO; > goto err_bad_io; > } > - > - if (++iovcnt > ROCKER_TX_FRAGS_MAX) { > - goto err_too_many_frags; > - } > + iovcnt++; > } >=20 > if (iovcnt) { > --=20 > 2.4.3 > =3D=3D=3D >=20 >=20 > Thank you. > -- > Prasad J Pandit / Red Hat Product Security Team > 47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F >=20 --SO98HVl1bnMOfKZd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWeigEAAoJEJykq7OBq3PIkTcH/0pBPeke9AUTiG+7ZFdL138n RbhQJgcI6hwXf1o1wNmIIIxMnQSsttR36uuKiIkbL0UPb+r1mU1jJkODc6ud397m kiTnAclKkRqJIRTdFZeHOmJ7O0NjmX73x7iNtZV1q2Y7QgvM+F/x1wq+496Qt7F0 4j97g0W5pfP7jBhGEoY/4QkEtkfGp6veerheQExSRrjxArYB60Iw8K+dAih2pnDk JEkqnC6Wwuczv5tqaUOIy/NRgZfj2c4EX698YYn0TNfO9G32MhKev1MRdV7tm2ya xEgor1xx2pcIEVhVtMaaTtn4pIzys2AXfy30E1FJsCaf+Nm3gAJ0IsGjuDhZBKA= =vyG2 -----END PGP SIGNATURE----- --SO98HVl1bnMOfKZd--