Skip to contentSkip to conversation

do_iret bug in xen

DISCUSSION Ashish Bijlani 2 participants 3 messages Nov 27, 2007

lore
Share & tools
lore
#0 lore raw

"do_iret" (slow iret via hyercall) can introduce a race condition as "current" can change during the execution of the function. all hypercalls run with "sti" on, so an interrupt on a processor causing the control to enter in "__enter_scheduler" after reading current can change the current process on that processor.

code excerpt

"

    struct iret_context iret_saved;
    struct vcpu *v = current;

    if ( unlikely(copy_from_user(&iret_saved, (void *)regs->rsp,
                                 sizeof(iret_saved))) )
    {

"

Any thoughts on this?

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

#1 lore raw
Quoted 5 lines · Ashish Bijlani

"do_iret" (slow iret via hyercall) can introduce a race condition as "current" can change during the execution of the function. all hypercalls run with "sti" on, so an interrupt on a processor causing the control to enter in "__enter_scheduler" after reading current can change the current process on that processor.

follow the code e.g. surounding ret_from_intr. __enter_scheduler is a softirq handler. it will only be run upon return to guest context, not when returning to an interrupted hypervisor. xen is not preemptible.

regards,
daniel

Signature · 5 lines
Daniel Stodden
LRR     -      Lehrstuhl für Rechnertechnik und Rechnerorganisation
Institut für Informatik der TU München             D-85748 Garching
http://www.lrr.in.tum.de/~stodden         mailto:[email protected]
PGP Fingerprint: F5A4 1575 4C56 E26A 0B33  3D80 457E 82AE B0D8 735B
#2 lore raw

since "sti" is on, an interrupt can occur which can cause the control to enter "__runq_tickle", which then invokes "cpumask_raise_softirq(mask, SCHEDULE_SOFTIRQ)" to send IPI to a processor causing the control to enter "__enter_scheduler" which changes the current.

Quoted 15 lines · Daniel Stodden
Quoted 5 lines · Ashish Bijlani

"do_iret" (slow iret via hyercall) can introduce a race condition as "current" can change during the execution of the function. all hypercalls run with "sti" on, so an interrupt on a processor causing the control to enter in "__enter_scheduler" after reading current can change the current process on that processor.

follow the code e.g. surounding ret_from_intr. __enter_scheduler is a softirq handler. it will only be run upon return to guest context, not when returning to an interrupted hypervisor. xen is not preemptible.

regards,
daniel

Quoted 10 lines

--
Daniel Stodden
LRR - Lehrstuhl für Rechnertechnik und Rechnerorganisation
Institut für Informatik der TU München D-85748 Garching
http://www.lrr.in.tum.de/~stodden <http://www.lrr.in.tum.de/%7Estodden>
mailto:[email protected]
PGP Fingerprint: F5A4 1575 4C56 E26A 0B33 3D80 457E 82AE B0D8 735B

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