* [Qemu-devel] [PATCH for-1.2] hw/arm_gic.c: Define .class_size in arm_gic_info TypeInfo
@ 2012-08-29 7:52 Peter Maydell
2012-08-29 18:57 ` Stefan Weil
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2012-08-29 7:52 UTC (permalink / raw)
To: qemu-devel; +Cc: Stefan Weil, Anthony Liguori, patches
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 <adam@os.inf.tu-dresden.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
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)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.2] hw/arm_gic.c: Define .class_size in arm_gic_info TypeInfo
2012-08-29 7:52 [Qemu-devel] [PATCH for-1.2] hw/arm_gic.c: Define .class_size in arm_gic_info TypeInfo Peter Maydell
@ 2012-08-29 18:57 ` Stefan Weil
2012-08-30 13:06 ` Andreas Färber
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Weil @ 2012-08-29 18:57 UTC (permalink / raw)
To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel, patches
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<adam@os.inf.tu-dresden.de>
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
> 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 <sw@weilnetz.de>
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH for-1.2] hw/arm_gic.c: Define .class_size in arm_gic_info TypeInfo
2012-08-29 18:57 ` Stefan Weil
@ 2012-08-30 13:06 ` Andreas Färber
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Färber @ 2012-08-30 13:06 UTC (permalink / raw)
To: Stefan Weil; +Cc: Peter Maydell, Anthony Liguori, qemu-devel, patches
Am 29.08.2012 20:57, schrieb Stefan Weil:
> PS. Are there perhaps more bugs of this sort? A quick test looking
> for .class_init without .class_size shows a lot of files.
That alone is not wrong.
A problem only arises when a new struct ...Class is casted to but the
object not sized appropriately through .class_size.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-30 13:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-29 7:52 [Qemu-devel] [PATCH for-1.2] hw/arm_gic.c: Define .class_size in arm_gic_info TypeInfo Peter Maydell
2012-08-29 18:57 ` Stefan Weil
2012-08-30 13:06 ` Andreas Färber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).