From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6nSZ-0001pj-36 for qemu-devel@nongnu.org; Wed, 29 Aug 2012 14:57:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6nSY-0001Vr-15 for qemu-devel@nongnu.org; Wed, 29 Aug 2012 14:57:51 -0400 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:54395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6nSX-0001Vm-Qk for qemu-devel@nongnu.org; Wed, 29 Aug 2012 14:57:49 -0400 Message-ID: <503E662B.2010903@weilnetz.de> Date: Wed, 29 Aug 2012 20:57:47 +0200 From: Stefan Weil MIME-Version: 1.0 References: <1346226757-24968-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1346226757-24968-1-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-1.2] hw/arm_gic.c: Define .class_size in arm_gic_info TypeInfo List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Anthony Liguori , qemu-devel@nongnu.org, patches@linaro.org Am 29.08.2012 09:52, schrieb Peter Maydell: > Add the missing .class_size definition to the arm_gic_info TypeInfo. > This fixes the memory corruption and possible segfault that otherwise > results when the class struct is allocated at too small a size and > the class init function writes off the end of it. > > Reported-by: Adam Lackorzynski > Signed-off-by: Peter Maydell > --- > Oops. I suspect this only crashes on 32 bit hosts because the class > is only one field larger than its subclass, so on 64 bit systems > we are probably only overwriting padding rather than anything > important. For 1.2 since it fixes a segfault. > > hw/arm_gic.c | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/hw/arm_gic.c b/hw/arm_gic.c > index 186ac66..55871fa 100644 > --- a/hw/arm_gic.c > +++ b/hw/arm_gic.c > @@ -703,6 +703,7 @@ static TypeInfo arm_gic_info = { > .parent = TYPE_ARM_GIC_COMMON, > .instance_size = sizeof(gic_state), > .class_init = arm_gic_class_init, > + .class_size = sizeof(ARMGICClass), > }; > > static void arm_gic_register_types(void) Tested-by: Stefan Weil The patch fixes Valgrind error messages (tested on 64 bit Linux Debian Squeeze) and segfaults (seen on 32 bit Linux Ubuntu Lenny and on 64 bit Windows). Anthony, please apply it to QEMU 1.2. Regards, Stefan PS. Are there perhaps more bugs of this sort? A quick test looking for .class_init without .class_size shows a lot of files.