• Ian Kent's avatar
    autofs4: fix lookup deadlock · 8f63aaa8
    Ian Kent authored
    A deadlock can occur when user space uses a signal (autofs version 4 uses
    SIGCHLD for this) to effect expire completion.
    
    The order of events is:
    
    Expire process completes, but before being able to send SIGCHLD to it's parent
    ...
    
    Another process walks onto a different mount point and drops the directory
    inode semaphore prior to sending the request to the daemon as it must ...
    
    A third process does an lstat on on the expired mount point causing it to wait
    on expire completion (unfortunately) holding the directory semaphore.
    
    The mount request then arrives at the daemon which does an lstat and,
    deadlock.
    
    For some time I was concerned about releasing the directory semaphore around
    the expire wait in autofs4_lookup as well as for the mount call back.  I
    finally realized that the last round of changes in this function made the
    expiring dentry and the lookup dentry separate and distinct so the check and
    possible wait can be done anywhere prior to the mount call back.  This patch
    moves the check to just before the mount call back and inside the directory
    inode mutex release.
    Signed-off-by: default avatarIan Kent <raven@themaw.net>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    8f63aaa8
root.c 23.9 KB