Skip to content
  • Ioanna Alifieraki's avatar
    Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()" · edf28f40
    Ioanna Alifieraki authored
    This reverts commit a9795584.
    
    Commit a9795584 ("ipc,sem: remove uneeded sem_undo_list lock usage
    in exit_sem()") removes a lock that is needed.  This leads to a process
    looping infinitely in exit_sem() and can also lead to a crash.  There is
    a reproducer available in [1] and with the commit reverted the issue
    does not reproduce anymore.
    
    Using the reproducer found in [1] is fairly easy to reach a point where
    one of the child processes is looping infinitely in exit_sem between
    for(;;) and if (semid == -1) block, while it's trying to free its last
    sem_undo structure which has already been freed by freeary().
    
    Each sem_undo struct is on two lists: one per semaphore set (list_id)
    and one per process (list_proc).  The list_id list tracks undos by
    semaphore set, and the list_proc by process.
    
    Undo structures are removed either by freeary() or by exit_sem().  The
    freeary function is invoked when the user ...
    edf28f40