• Yasunori Goto's avatar
    sched: Fix ancient race in do_exit() · b5740f4b
    Yasunori Goto authored
    try_to_wake_up() has a problem which may change status from TASK_DEAD to
    TASK_RUNNING in race condition with SMI or guest environment of virtual
    machine. As a result, exited task is scheduled() again and panic occurs.
    
    Here is the sequence how it occurs:
    
     ----------------------------------+-----------------------------
                                       |
                CPU A                  |             CPU B
     ----------------------------------+-----------------------------
    
    TASK A calls exit()....
    
    do_exit()
    
      exit_mm()
        down_read(mm->mmap_sem);
    
        rwsem_down_failed_common()
    
          set TASK_UNINTERRUPTIBLE
          set waiter.task <= task A
          list_add to sem->wait_list
               :
          raw_spin_unlock_irq()
          (I/O interruption occured)
    
                                          __rwsem_do_wake(mmap_sem)
    
                                            list_del(&waiter->list);
                                            waiter->task = NULL
                                   ...
    b5740f4b
exit.c 46.9 KB