Received: from eggs.gnu.org ([2001:4830:134:3::10]:42960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHrPI-0001c2-74 for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:42:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHrPD-0007P2-Pe for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:42:19 -0400 Received: from mx4-phx2.redhat.com ([209.132.183.25]:46123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHrPD-0007Ow-GA for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:42:15 -0400 Date: Tue, 28 Jun 2016 07:42:13 -0400 (EDT) From: Paolo Bonzini Message-ID: <1514553233.2615640.1467114133062.JavaMail.zimbra@redhat.com> In-Reply-To: <8cd2bb86-6689-e495-86b7-2ea43b096f18@kaod.org> References: <1467103170-5784-1-git-send-email-pbonzini@redhat.com> <1467103170-5784-3-git-send-email-pbonzini@redhat.com> <8cd2bb86-6689-e495-86b7-2ea43b096f18@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/3] m25p80: avoid out of bounds accesses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?C=C3=A9dric?= Le Goater Cc: qemu-devel@nongnu.org ----- Original Message ----- > From: "C=C3=A9dric Le Goater" > To: "Paolo Bonzini" , qemu-devel@nongnu.org > Sent: Tuesday, June 28, 2016 11:05:24 AM > Subject: Re: [PATCH 2/3] m25p80: avoid out of bounds accesses >=20 > On 06/28/2016 10:39 AM, Paolo Bonzini wrote: > > s->cur_addr can be made to point outside s->storage, either by > > writing a value >=3D 128 to s->ear (because s->ear * MAX_3BYTES_SIZE > > is a signed integer and sign-extends into the 64-bit cur_addr), > > or just by writing an address beyond the size of the flash being > > emulated. Avoid the sign extension to make the code cleaner, and > > on top of that mask s->cur_addr to s->size. > >=20 > > Signed-off-by: Paolo Bonzini >=20 > Yes. We can trash memory very easily with the m25p80 object so we > clearly want this fix. >=20 > Maybe, we could add a guest error when going beyond storage and > the case doing flash_write8() needs some care also. I don't know, it's quite possible that real hardware does an AND simply because some address lines are not connected anywhere. Paolo