• Olof Johansson's avatar
    [PATCH] Fix possible futex mmap_sem deadlock · f5f23ec8
    Olof Johansson authored
    Some futex functions do get_user calls while holding mmap_sem for
    reading.  If get_user() faults, and another thread happens to be in mmap
    (or somewhere else holding waiting on down_write for the same
    semaphore), then do_page_fault will deadlock.  Most architectures seem
    to be exposed to this.
    
    To avoid it, make sure the page is available.  If not, release the
    semaphore, fault it in and retry.
    
    I also found another exposure by inspection, moving some of the code
    around avoids the possible deadlock there.
    Signed-off-by: default avatarOlof Johansson <olof@austin.ibm.com>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    f5f23ec8
futex.c 19.4 KB