• Shyam Prasad N's avatar
    cifs: avoid deadlocks while updating iface · 8da33fd1
    Shyam Prasad N authored
    We use cifs_tcp_ses_lock to protect a lot of things.
    Not only does it protect the lists of connections, sessions,
    tree connects, open file lists, etc., we also use it to
    protect some fields in each of it's entries.
    
    In this case, cifs_mark_ses_for_reconnect takes the
    cifs_tcp_ses_lock to traverse the lists, and then calls
    cifs_update_iface. However, that can end up calling
    cifs_put_tcp_session, which picks up the same lock again.
    
    Avoid this by taking a ref for the session, drop the lock,
    and then call update iface.
    
    Also, in cifs_update_iface, avoid nested locking of iface_lock
    and chan_lock, as much as possible. When unavoidable, we need
    to pick iface_lock first.
    Signed-off-by: default avatarShyam Prasad N <sprasad@microsoft.com>
    Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
    8da33fd1
sess.c 48.3 KB