Received: from eggs.gnu.org ([208.118.235.92]:43133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T7gWh-0001Br-Am for qemu-devel@nongnu.org; Sat, 01 Sep 2012 01:45:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T7gWf-0002Q9-QD for qemu-devel@nongnu.org; Sat, 01 Sep 2012 01:45:47 -0400 From: Markus Armbruster References: <1346444481-31727-1-git-send-email-sw@weilnetz.de> <50412E4D.9010204@suse.de> Date: Sat, 01 Sep 2012 07:45:41 +0200 In-Reply-To: <50412E4D.9010204@suse.de> ("Andreas =?utf-8?Q?F=C3=A4rber=22?= =?utf-8?Q?'s?= message of "Fri, 31 Aug 2012 23:36:13 +0200") Message-ID: <871uimi9dm.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] ppc405_uc: Fix buffer overflow List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: qemu-trivial@nongnu.org, Stefan Weil , qemu-devel@nongnu.org, qemu-stable@nongnu.org, Alexander Graf Andreas F=C3=A4rber writes: > Am 31.08.2012 22:21, schrieb Stefan Weil: >> Report from smatch: >>=20 >> ppc405_uc.c:209 dcr_read_pob(12) error: buffer overflow 'pob->besr' 2 <= =3D 2 >> ppc405_uc.c:232 dcr_write_pob(12) error: buffer overflow 'pob->besr' 2 <= =3D 2 >>=20 >> The old code reads and writes besr[POB0_BESR1 - POB0_BESR0] or besr[2] >> which is one too much. >>=20 >> Signed-off-by: Stefan Weil >> --- >>=20 >> As this code was wrong for more than 5 years, there is no urgent need to >> fix it now for QEMU 1.2. >>=20 >> Regards, >>=20 >> Stefan Weil >>=20 >> hw/ppc405_uc.c | 16 +++++++++++----- >> 1 file changed, 11 insertions(+), 5 deletions(-) >>=20 >> diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c >> index 89e5013..b52ab2f 100644 >> --- a/hw/ppc405_uc.c >> +++ b/hw/ppc405_uc.c >> @@ -191,7 +191,8 @@ enum { >> typedef struct ppc4xx_pob_t ppc4xx_pob_t; >> struct ppc4xx_pob_t { >> uint32_t bear; >> - uint32_t besr[2]; >> + uint32_t besr0; >> + uint32_t besr1; >> }; >>=20=20 >> static uint32_t dcr_read_pob (void *opaque, int dcrn) > > Reviewed-by: Andreas F=C3=A4rber > > We could alternatively leave besr[2] and access it with hardcoded 0..1. Minimally invasive fix would be besr[dcrn !=3D POB0_BESR0]. [...]