Skip to contentSkip to conversation

x86: fix an off-by-one pirq range check

PATCH In review Jan Beulich 2 participants 4 messages Jun 30, 2010 – Jul 1, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: fix an off-by-one pirq range check

xen/arch/x86/irq.c +1 -1
@@ -1027,7 +1027,7 @@ static void __pirq_guest_eoi(struct doma
 
 int pirq_guest_eoi(struct domain *d, int irq)
 {
-    if ( (irq < 0) || (irq > d->nr_pirqs) )
+    if ( (irq < 0) || (irq >= d->nr_pirqs) )
         return -EINVAL;
 
     __pirq_guest_eoi(d, irq);
#1 lore raw
Quoted 1 line · Jan Beulich

Won't that make PV guest with only one IRQ passed through unable to ACK it? (and if the IRQ is not shared that is).

This code does get executed when the PHYSDEVOP_eoi hypercall is made I believe.

Quoted 20 lines
xen/arch/x86/irq.c +1 -1
@@ -1027,7 +1027,7 @@ static void __pirq_guest_eoi(struct doma
 
 int pirq_guest_eoi(struct domain *d, int irq)
 {
-    if ( (irq < 0) || (irq > d->nr_pirqs) )
+    if ( (irq < 0) || (irq >= d->nr_pirqs) )
         return -EINVAL;
 
     __pirq_guest_eoi(d, irq);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Jan Beulich

Won't that make PV guest with only one IRQ passed through unable to ACK it? (and if the IRQ is not shared that is).

Why would you think so? In such a case, nr_pirqs would be 1, and the only permitted pirq would be 0. All other places do the range checks correctly, just this one would let through an out of bounds number.

Jan

Quoted 22 lines

This code does get executed when the PHYSDEVOP_eoi hypercall is made I believe.

Quoted 20 lines
xen/arch/x86/irq.c +1 -1
@@ -1027,7 +1027,7 @@ static void __pirq_guest_eoi(struct doma
 
 int pirq_guest_eoi(struct domain *d, int irq)
 {
-    if ( (irq < 0) || (irq > d->nr_pirqs) )
+    if ( (irq < 0) || (irq >= d->nr_pirqs) )
         return -EINVAL;
 
     __pirq_guest_eoi(d, irq);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 10 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 1 line · Jan Beulich

Won't that make PV guest with only one IRQ passed through unable to ACK it? (and if the IRQ is not shared that is).

Why would you think so? In such a case, nr_pirqs would be 1, and the only permitted pirq would be 0. All other places do the range checks correctly, just this one would let through an out of bounds number.

Excellent. Thanks for the answer.