• Andrew Morton's avatar
    [PATCH] Fix dcache_lock/tasklist_lock ranking bug · 055e188d
    Andrew Morton authored
    __unhash_process acquires the dcache_lock while holding the
    tasklist_lock for writing. This can deadlock. Additionally,
    fs/proc/base.c incorrectly assumed that p->pid would be set to 0 during
    release_task.
    
    The patch fixes that by adding a new spinlock to the task structure and
    fixing all references to (!p->pid).
    
    The alternative to the new spinlock would be to hold dcache_lock around
    __unhash_process.
    
    - fs/proc/base.c assumed that p->pid is reset to 0 during exit.  This is
      not the case anymore.  I now look at the count of the pid structure for
      PIDTYPE_PID.
    
    - de_thread now tested - as broken as it was before: open handles to
      /proc/<pid> are either stale or invalid after an exec of a nptl process,
      if the exec was call from a secondary thread.
    
    - a few lock_kernels removed - that part of /proc doesn't need it.
    
    - additional instances of 'if(current->pid)' replaced with pid_alive.
    055e188d
exit.c 26.3 KB