public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm <kvm@vger.kernel.org>, Avi Kivity <avi@redhat.com>,
	Gleb Natapov <gleb@redhat.com>
Subject: Re: KVM: properly check max PIC pin in irq route setup
Date: Tue, 12 Jan 2010 20:45:35 +0100	[thread overview]
Message-ID: <m31vhvksyo.fsf@neno.neno> (raw)
In-Reply-To: <20100112184209.GA4055@amt.cnet> (Marcelo Tosatti's message of "Tue, 12 Jan 2010 16:42:09 -0200")

Marcelo Tosatti <mtosatti@redhat.com> wrote:
> Otherwise memory beyond irq_states[16] might be accessed.
>
> Noticed by Juan Quintela.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
> index 9b07734..9fd5b3e 100644
> --- a/virt/kvm/irq_comm.c
> +++ b/virt/kvm/irq_comm.c
> @@ -302,6 +302,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
>  {
>  	int r = -EINVAL;
>  	int delta;
> +	unsigned max_pin;
>  	struct kvm_kernel_irq_routing_entry *ei;
>  	struct hlist_node *n;
>  
> @@ -322,12 +323,15 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
>  		switch (ue->u.irqchip.irqchip) {
>  		case KVM_IRQCHIP_PIC_MASTER:
>  			e->set = kvm_set_pic_irq;
> +			max_pin = 16;

once you are here, you can use the constant name:
	PIC_NUM_PINS
Humm, that is not going to fly, it is defined in x86 code, and it is
used in generic code.

No great ideas here :(

>  			break;
>  		case KVM_IRQCHIP_PIC_SLAVE:
>  			e->set = kvm_set_pic_irq;
> +			max_pin = 16;
>  			delta = 8;
>  			break;
>  		case KVM_IRQCHIP_IOAPIC:
> +			max_pin = KVM_IOAPIC_NUM_PINS;
>  			e->set = kvm_set_ioapic_irq;
>  			break;
>  		default:
> @@ -335,7 +339,7 @@ static int setup_routing_entry(struct kvm_irq_routing_table *rt,
>  		}
>  		e->irqchip.irqchip = ue->u.irqchip.irqchip;
>  		e->irqchip.pin = ue->u.irqchip.pin + delta;
> -		if (e->irqchip.pin >= KVM_IOAPIC_NUM_PINS)
> +		if (e->irqchip.pin >= max_pin)
>  			goto out;
>  		rt->chip[ue->u.irqchip.irqchip][e->irqchip.pin] = ue->gsi;
>  		break;

For the rest, patch fixes my concerns.

Acked-by: Juan Quintela <quintela@redhat.com>

  reply	other threads:[~2010-01-12 19:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-12 18:42 KVM: properly check max PIC pin in irq route setup Marcelo Tosatti
2010-01-12 19:45 ` Juan Quintela [this message]
2010-01-17 13:00 ` Avi Kivity

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=m31vhvksyo.fsf@neno.neno \
    --to=quintela@redhat.com \
    --cc=avi@redhat.com \
    --cc=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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