From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=57306 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYPSM-0004D7-LK for qemu-devel@nongnu.org; Mon, 12 Jul 2010 16:18:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OYPSL-0003eB-Au for qemu-devel@nongnu.org; Mon, 12 Jul 2010 16:18:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49127) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OYPSL-0003dl-3o for qemu-devel@nongnu.org; Mon, 12 Jul 2010 16:18:25 -0400 From: Alex Williamson In-Reply-To: <20100712174823.GA11411@redhat.com> References: <20100712174823.GA11411@redhat.com> Content-Type: text/plain; charset="UTF-8" Date: Mon, 12 Jul 2010 14:18:20 -0600 Message-ID: <1278965900.20397.242.camel@x201> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH RFC] e1000: fix access 4 bytes beyond buffer end List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org On Mon, 2010-07-12 at 20:48 +0300, Michael S. Tsirkin wrote: > We do range check for size, and get size as buffer, > but copy size + 4 bytes (4 is for FCS). > Let's copy size bytes but put size + 4 in length. > > Signed-off-by: Michael S. Tsirkin > --- > > Anthony, Alex, please review. Looks fine to me. Acked-by: Alex Williamson > hw/e1000.c | 3 +-- > 1 files changed, 1 insertions(+), 2 deletions(-) > > diff --git a/hw/e1000.c b/hw/e1000.c > index 0da65f9..70aba11 100644 > --- a/hw/e1000.c > +++ b/hw/e1000.c > @@ -649,7 +649,6 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) > } > > rdh_start = s->mac_reg[RDH]; > - size += 4; // for the header > do { > if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) { > set_ics(s, 0, E1000_ICS_RXO); > @@ -663,7 +662,7 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) > if (desc.buffer_addr) { > cpu_physical_memory_write(le64_to_cpu(desc.buffer_addr), > (void *)(buf + vlan_offset), size); > - desc.length = cpu_to_le16(size); > + desc.length = cpu_to_le16(size + 4 /* for FCS */); > desc.status |= E1000_RXD_STAT_EOP|E1000_RXD_STAT_IXSM; > } else // as per intel docs; skip descriptors with null buf addr > DBGOUT(RX, "Null RX descriptor!!\n");