public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Chris Lalancette <clalance-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH]: Fix memory corruption in-kernel	IOAPIC	emulation
Date: Thu, 31 Jan 2008 09:24:46 +0200	[thread overview]
Message-ID: <47A177BE.6020300@qumranet.com> (raw)
In-Reply-To: <47A0E613.7080408-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Chris Lalancette wrote:
> Another version of the patch, done by changing the on-the-wire protocol
> as Avi suggested.  I've tested this with:
>
> old -> old - Migration works, but runs into the bug I'm trying to fix
> old -> new - Migration works, but runs into the bug I'm trying to fix
> new -> old - Migration fails gracefully with ioapic version mismatch
> new -> new - Migration works, and doesn't run into this particular bug
>   

>  
> -static void kvm_kernel_ioapic_load_from_user(IOAPICState *s)
> +static int kvm_kernel_ioapic_load_from_user(IOAPICState *s, int version_id)
>  {
>  #if defined(KVM_CAP_IRQCHIP) && defined(TARGET_I386)
>      struct kvm_irqchip chip;
>      struct kvm_ioapic_state *kioapic;
>      int i;
>  
> +    if (version_id > 2) {
> +        return -EINVAL;
> +    }
> +
>      chip.chip_id = KVM_IRQCHIP_IOAPIC;
>      kioapic = &chip.chip.ioapic;
>  
> +    if (version_id == 2) {
> +        kioapic->base_address = s->base_address;
> +        kioapic->irr = s->irr;
> +    }
> +
>   

Preferably this function would always set all variables; the caller 
should make sure all the values are sane (by initializing them to sane 
values on ioapic creation, and not modifying them when a version 1 
migration happens).  It's best to limit protocol change handling to the 
actual qemu save/restore routines.

>  static void ioapic_save(QEMUFile *f, void *opaque)
> @@ -1173,8 +1188,9 @@ static int ioapic_load(QEMUFile *f, void *opaque, int version_id)
>  {
>      IOAPICState *s = opaque;
>      int i;
> +    int ret;
>  
> -    if (version_id != 1)
> +    if (version_id > 2)
>          return -EINVAL;
>   

This allows version_id == 0 to sneak in, where it couldn't before.  It's 
not a problem in practice, but let's get it right.



-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

  parent reply	other threads:[~2008-01-31  7:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-29 23:24 [PATCH]: Fix memory corruption in-kernel IOAPIC emulation Chris Lalancette
     [not found] ` <479FB5C6.6060204-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-30 10:04   ` Avi Kivity
     [not found]     ` <47A04BB3.7020302-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-01-30 13:28       ` Chris Lalancette
2008-01-30 16:39       ` Chris Lalancette
     [not found]         ` <47A0A830.8040900-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-30 16:54           ` Avi Kivity
2008-01-30 21:03   ` Chris Lalancette
     [not found]     ` <47A0E613.7080408-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2008-01-31  7:24       ` Avi Kivity [this message]
     [not found]         ` <47A177BE.6020300-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2008-02-05 15:58           ` Chris Lalancette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47A177BE.6020300@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=clalance-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox