From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCfKu-00075g-Vy for qemu-devel@nongnu.org; Mon, 13 Jun 2016 23:48:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCfKp-0006p0-MO for qemu-devel@nongnu.org; Mon, 13 Jun 2016 23:48:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47401) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCfKp-0006ou-Gb for qemu-devel@nongnu.org; Mon, 13 Jun 2016 23:48:15 -0400 References: <1464849867-20184-1-git-send-email-ppandit@redhat.com> <20160613083517.GB16232@aurel32.net> From: Jason Wang Message-ID: <575F7E75.2040805@redhat.com> Date: Tue, 14 Jun 2016 11:48:05 +0800 MIME-Version: 1.0 In-Reply-To: <20160613083517.GB16232@aurel32.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] net: mipsnet: check transmit buffer size before sending List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno , Peter Maydell Cc: P J P , Qemu Developers , Li Qiang , Prasad J Pandit , Leon Alrae On 2016=E5=B9=B406=E6=9C=8813=E6=97=A5 16:35, Aurelien Jarno wrote: > On 2016-06-02 10:28, Peter Maydell wrote: >> On 2 June 2016 at 07:44, P J P wrote: >>> From: Prasad J Pandit >>> >>> When processing MIPSnet I/O port write operation, it uses a >>> transmit buffer tx_buffer[MAX_ETH_FRAME_SIZE=3D1514]. Two indices >>> 's->tx_written' and 's->tx_count' are used to control data written >>> to this buffer. If the two were to be equal before writing, it'd >>> lead to an OOB write access beyond tx_buffer. Add check to avoid it. >>> >>> Reported-by: Li Qiang >>> Signed-off-by: Prasad J Pandit >>> --- >>> hw/net/mipsnet.c | 10 ++++++---- >>> 1 file changed, 6 insertions(+), 4 deletions(-) >>> >>> diff --git a/hw/net/mipsnet.c b/hw/net/mipsnet.c >>> index 740cd98..8d5e5bf 100644 >>> --- a/hw/net/mipsnet.c >>> +++ b/hw/net/mipsnet.c >>> @@ -158,7 +158,7 @@ static void mipsnet_ioport_write(void *opaque, hw= addr addr, >>> trace_mipsnet_write(addr, val); >>> switch (addr) { >>> case MIPSNET_TX_DATA_COUNT: >>> - s->tx_count =3D (val <=3D MAX_ETH_FRAME_SIZE) ? val : 0; >>> + s->tx_count =3D (val < MAX_ETH_FRAME_SIZE) ? val : MAX_ETH_F= RAME_SIZE; >>> s->tx_written =3D 0; >> This is a behaviour change -- the register will now read >> back as MAX_ETH_FRAME_SIZE rather than 0 if written with >> an overlarge value. >> >> Do we have any documentation on how this (simulated) >> device is supposed to behave in this case? > This device is not supported by the linux kernel for more than 2.5 year= s > (since v3.7). Do we want to keep this device in QEMU? > > Aurelien > Right, so I suggest to remove this from qemu.