All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris J Arges <chris.j.arges@canonical.com>
To: kvm@vger.kernel.org
Cc: Chris J Arges <chris.j.arges@canonical.com>,
	Gleb Natapov <gleb@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] KVM: ioapic: add check for RTC_GSI
Date: Wed, 10 Sep 2014 11:53:31 -0500	[thread overview]
Message-ID: <1410368033-23628-1-git-send-email-chris.j.arges@canonical.com> (raw)

cppcheck found the following error:
[ioapic.c:114]: (error) Array index -1 is out of bounds.

If CONFIG_X86 is not defined, RTC_GSI == -1U which means that an out of bounds
error could occur when accessing &ioapic->redirtbl[RTC_GSI].

This patch adds a check to kvm_rtc_eoi_tracking_restore_one that is similar to
how kvm_rtc_eoi_tracking_restore_all checks this condition.

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
---
 virt/kvm/ioapic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index e8ce34c..859f5b8 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -136,6 +136,9 @@ void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
 {
 	struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
 
+	if (RTC_GSI >= IOAPIC_NUM_PINS)
+		return;
+
 	spin_lock(&ioapic->lock);
 	__rtc_irq_eoi_tracking_restore_one(vcpu);
 	spin_unlock(&ioapic->lock);
-- 
1.9.1


             reply	other threads:[~2014-09-10 16:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 16:53 Chris J Arges [this message]
2014-09-11  6:01 ` [PATCH] KVM: ioapic: add check for RTC_GSI Jan Kiszka
2014-09-11  9:08   ` Paolo Bonzini
2014-09-11  9:19     ` Jan Kiszka
2014-09-11  9:35       ` Paolo Bonzini

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=1410368033-23628-1-git-send-email-chris.j.arges@canonical.com \
    --to=chris.j.arges@canonical.com \
    --cc=gleb@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.