• R
    process robust list in pthread_exit to fix detached thread use-after-unmap · 12e1e324
    Rich Felker 提交于
    the robust list head lies in the thread structure, which is unmapped
    before exit for detached threads. this leaves the kernel unable to
    process the exiting thread's robust list, and with a dangling pointer
    which may happen to point to new unrelated data at the time the kernel
    processes it.
    
    userspace processing of the robust list was already needed for
    non-pshared robust mutexes in order to perform private futex wakes
    rather than the shared ones the kernel would do, but it was
    conditional on linking pthread_mutexattr_setrobust and did not bother
    processing the pshared mutexes in the list, which requires additional
    logic for the robust list pending slot in case pthread_exit is
    interrupted by asynchronous process termination.
    
    the new robust list processing code is linked unconditionally (inlined
    in pthread_exit), handles both private and shared mutexes, and also
    removes the kernel's reference to the robust list before unmapping and
    exit if the exiting thread is detached.
    12e1e324
pthread_mutexattr_setrobust.c 185 字节