All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: ioapic: add check for RTC_GSI
@ 2014-09-10 16:53 Chris J Arges
  2014-09-11  6:01 ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Chris J Arges @ 2014-09-10 16:53 UTC (permalink / raw)
  To: kvm; +Cc: Chris J Arges, Gleb Natapov, Paolo Bonzini, linux-kernel

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: ioapic: add check for RTC_GSI
  2014-09-10 16:53 [PATCH] KVM: ioapic: add check for RTC_GSI Chris J Arges
@ 2014-09-11  6:01 ` Jan Kiszka
  2014-09-11  9:08   ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2014-09-11  6:01 UTC (permalink / raw)
  To: Chris J Arges, kvm; +Cc: Gleb Natapov, Paolo Bonzini, linux-kernel

On 2014-09-10 18:53, Chris J Arges wrote:
> 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

That issue is limited to the dead ia64 architecture, no other builds
ioapic.c (besides x86, of course). Maybe finally remove KVM support for
that arch instead of bloating otherwise correct code?

Jan

> 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);
> 

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: ioapic: add check for RTC_GSI
  2014-09-11  6:01 ` Jan Kiszka
@ 2014-09-11  9:08   ` Paolo Bonzini
  2014-09-11  9:19     ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2014-09-11  9:08 UTC (permalink / raw)
  To: Jan Kiszka, Chris J Arges, kvm; +Cc: Gleb Natapov, linux-kernel

Il 11/09/2014 08:01, Jan Kiszka ha scritto:
> That issue is limited to the dead ia64 architecture, no other builds
> ioapic.c (besides x86, of course). Maybe finally remove KVM support for
> that arch instead of bloating otherwise correct code?

Yes, we should.  I've just been too busy to do it.

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: ioapic: add check for RTC_GSI
  2014-09-11  9:08   ` Paolo Bonzini
@ 2014-09-11  9:19     ` Jan Kiszka
  2014-09-11  9:35       ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2014-09-11  9:19 UTC (permalink / raw)
  To: Paolo Bonzini, Chris J Arges, kvm; +Cc: Gleb Natapov, linux-kernel

On 2014-09-11 11:08, Paolo Bonzini wrote:
> Il 11/09/2014 08:01, Jan Kiszka ha scritto:
>> That issue is limited to the dead ia64 architecture, no other builds
>> ioapic.c (besides x86, of course). Maybe finally remove KVM support for
>> that arch instead of bloating otherwise correct code?
> 
> Yes, we should.  I've just been too busy to do it.

As I enjoy creating large negative diffs :), I would almost do it - if I
had a test environment for IA64...

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: ioapic: add check for RTC_GSI
  2014-09-11  9:19     ` Jan Kiszka
@ 2014-09-11  9:35       ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2014-09-11  9:35 UTC (permalink / raw)
  To: Jan Kiszka, Chris J Arges, kvm; +Cc: Gleb Natapov, linux-kernel

Il 11/09/2014 11:19, Jan Kiszka ha scritto:
> On 2014-09-11 11:08, Paolo Bonzini wrote:
>> Il 11/09/2014 08:01, Jan Kiszka ha scritto:
>>> That issue is limited to the dead ia64 architecture, no other builds
>>> ioapic.c (besides x86, of course). Maybe finally remove KVM support for
>>> that arch instead of bloating otherwise correct code?
>>
>> Yes, we should.  I've just been too busy to do it.
> 
> As I enjoy creating large negative diffs :), I would almost do it - if I
> had a test environment for IA64...

I have one. :)

Paolo


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-11  9:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-10 16:53 [PATCH] KVM: ioapic: add check for RTC_GSI Chris J Arges
2014-09-11  6:01 ` Jan Kiszka
2014-09-11  9:08   ` Paolo Bonzini
2014-09-11  9:19     ` Jan Kiszka
2014-09-11  9:35       ` Paolo Bonzini

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.