xen: Clear IRQ_GUEST bit from irq_desc status if its action is NULL
On a system with Intel C600 series Patsburg SAS controller if following command are executed:
rmmod isci
modprobe isci
the host will crash in pirq_guest_bind in attempt to dereference NULL action pointer.
This is caused by isci driver which does not cleanup irq properly, removing device first and then os tries to unbind its irqs afterwards.
c/s 20093 and 20844 fixed host crashes when removing isci module.
However in dynamic_irq_cleanup 'action' field of irq_desc is set to NULL but IRQ_GUEST flag in 'status' field is not cleared. So on next attempt to bind pirq (modprobe isci) with IRQ_GUEST flag set, branch
if ( !(desc->status & IRQ_GUEST) )
is skipped and host ends up with dereferencing NULL pointer 'action'.
Second hunk is a bit of code cleanup, removing duplicate code and keeps IRQ_GUEST flag reset at one place.
Please review.
xen/arch/x86/irq.c +3 -5
@@ -1472,6 +1472,7 @@ static irq_guest_action_t *__pirq_guest_if (unlikely (action ==NULL ) ) { + desc->status &= ~IRQ_GUEST ;dprintk (XENLOG_G_WARNING ,"dom%d: pirq %d: desc->action is NULL!\n" , d->domain_id, pirq->pirq);return NULL ;
@@ -1598,17 +1599,14 @@ static int pirq_guest_force_unbind(struc action = (irq_guest_action_t *)desc->action;if (unlikely (action ==NULL ) ) - { -dprintk (XENLOG_G_WARNING ,"dom%d: pirq %d: desc->action is NULL!\n" , - d->domain_id, pirq->pirq); - goto out; - } + goto unbind;for ( i =0 ; (i < action->nr_guests) && (action->guest[i] != d); i++ )continue ;if ( i == action->nr_guests ) goto out; + unbind: bound =1 ; oldaction =__pirq_guest_unbind (d, pirq, desc);
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Igor Mammedov
On a system with Intel C600 series Patsburg SAS controller if following command are executed:
rmmod isci
modprobe iscithe host will crash in
pirq_guest_bindin attempt to dereference NULL action pointer.
Quoted 7 lines
This is caused by isci driver which does not cleanup irq properly, removing device first and then os tries to unbind its irqs afterwards.
c/s 20093 and 20844 fixed host crashes when removing isci module.
However in
dynamic_irq_cleanup'action' field ofirq_descis set to NULL butIRQ_GUESTflag in 'status' field is not cleared. So on next
So why don't you clear the bit there?
Quoted 6 lines
attempt to bind pirq (modprobe isci) with
IRQ_GUESTflag set, branch
if ( !(desc->status &IRQ_GUEST) )
is skipped and host ends up with dereferencing NULL pointer 'action'.Second hunk is a bit of code cleanup, removing duplicate code and keeps
IRQ_GUESTflag reset at one place.
This is not just cleanup - till now, when action == NULL, the function would return 0, while with your patch it would return 1 (which is wrong afaict), so you'll minimally need to move down the unbind: label by one line. But the cleanup here would better be a separate patch anyway.
Jan
Quoted 40 lines
Please review.
Signed-off-by Igor Mammedov <[email protected]>diff -r
0312575dc35exen/arch/x86/irq.cxen/arch/x86/irq.c +3
-5@@ -1472,6 +1472,7 @@ static irq_guest_action_t *__pirq_guest_if (unlikely (action ==NULL ) ) { + desc->status &= ~IRQ_GUEST ;dprintk (XENLOG_G_WARNING ,"dom%d: pirq %d: desc->action is NULL!\n" , d->domain_id, pirq->pirq);return NULL ;@@ -1598,17 +1599,14 @@ static int pirq_guest_force_unbind(struc action = (irq_guest_action_t *)desc->action;if (unlikely (action ==NULL ) ) - { -dprintk (XENLOG_G_WARNING ,"dom%d: pirq %d: desc->action is NULL!\n" , - d->domain_id, pirq->pirq); - goto out; - } + goto unbind;for ( i =0 ; (i < action->nr_guests) && (action->guest[i] != d); i++ )continue ;if ( i == action->nr_guests ) goto out; + unbind: bound =1 ; oldaction =__pirq_guest_unbind (d, pirq, desc);_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 27 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Igor Mammedov
On a system with Intel C600 series Patsburg SAS controller if following command are executed:
rmmod isci
modprobe iscithe host will crash in
pirq_guest_bindin attempt to dereference NULL action pointer.Quoted 7 lines
This is caused by isci driver which does not cleanup irq properly, removing device first and then os tries to unbind its irqs afterwards.
c/s 20093 and 20844 fixed host crashes when removing isci module.
However in
dynamic_irq_cleanup'action' field ofirq_descis set to NULL butIRQ_GUESTflag in 'status' field is not cleared. So on nextSo why don't you clear the bit there?
Quoted 6 lines
attempt to bind pirq (modprobe isci) with
IRQ_GUESTflag set, branch
if ( !(desc->status&IRQ_GUEST) )
is skipped and host ends up with dereferencing NULL pointer 'action'.Second hunk is a bit of code cleanup, removing duplicate code and keeps
IRQ_GUESTflag reset at one place.
Quoted 6 lines
This is not just cleanup - till now, when action == NULL, the function would return 0, while with your patch it would return 1 (which is wrong afaict), so you'll minimally need to move down the unbind: label by one line. But the cleanup here would better be a separate patch anyway.
Jan
Thanks for review.
I'll fix it and re-post it as 2 patches.
Quoted 49 lines
Quoted 37 lines
Please review.
Signed-off-by Igor Mammedov<[email protected]>diff -r
0312575dc35exen/arch/x86/irq.cxen/arch/x86/irq.c +3
-5@@ -1472,6 +1472,7 @@ static irq_guest_action_t *__pirq_guest_if (unlikely (action ==NULL ) ) { + desc->status&= ~IRQ_GUEST ;dprintk (XENLOG_G_WARNING ,"dom%d: pirq %d: desc->action is NULL!\n" , d->domain_id, pirq->pirq);return NULL ;@@ -1598,17 +1599,14 @@ static int pirq_guest_force_unbind(struc action = (irq_guest_action_t *)desc->action;if (unlikely (action ==NULL ) ) - { -dprintk (XENLOG_G_WARNING ,"dom%d: pirq %d: desc->action is NULL!\n" , - d->domain_id, pirq->pirq); - goto out; - } + goto unbind;for ( i =0 ; (i< action->nr_guests)&& (action->guest[i] != d); i++ )continue ;if ( i == action->nr_guests ) goto out; + unbind: bound =1 ; oldaction =__pirq_guest_unbind (d, pirq, desc);Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Signature · 2 lines
Thanks, Igor
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · Igor Mammedov
On a system with Intel C600 series Patsburg SAS controller if following command are executed:
rmmod isci
modprobe iscithe host will crash in
pirq_guest_bindin attempt to dereference NULL action pointer.This is caused by isci driver which does not cleanup irq properly, removing device first and then os tries to unbind its irqs afterwards.
Quoted 6 lines
Quoted 4 lines
c/s 20093 and 20844 fixed host crashes when removing isci module.
However in
dynamic_irq_cleanup'action' field ofirq_descis set to NULL butIRQ_GUESTflag in 'status' field is not cleared. So on nextSo why don't you clear the bit there?
then we may hit
BUG_ON(!(desc->status & IRQ_GUEST));
in pirq_guest_unbind -> __pirq_guest_unbind
It seams safer for me to clear bit in __pirq_guest_unbind
Quoted 22 lines
Quoted 1 line
Quoted 1 line · Igor Mammedov
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · Igor Mammedov
On a system with Intel C600 series Patsburg SAS controller if following command are executed:
rmmod isci
modprobe iscithe host will crash in
pirq_guest_bindin attempt to dereference NULL action pointer.This is caused by isci driver which does not cleanup irq properly, removing device first and then os tries to unbind its irqs afterwards.
Quoted 6 lines
Quoted 4 lines
c/s 20093 and 20844 fixed host crashes when removing isci module.
However in
dynamic_irq_cleanup'action' field ofirq_descis set to NULL butIRQ_GUESTflag in 'status' field is not cleared. So on nextSo why don't you clear the bit there?
Quoted 7 lines
then we may hit
BUG_ON(!(desc->status & IRQ_GUEST));in
pirq_guest_unbind->__pirq_guest_unbindIt seams safer for me to clear bit in
__pirq_guest_unbind
Makes sense - could you say so in the description when re-submitting?
Jan