]> git.baikalelectronics.ru Git - kernel.git/commit
cifs: avoid deadlocks while updating iface
authorShyam Prasad N <sprasad@microsoft.com>
Fri, 24 Jun 2022 09:43:59 +0000 (09:43 +0000)
committerSteve French <stfrench@microsoft.com>
Fri, 24 Jun 2022 14:17:56 +0000 (09:17 -0500)
commit654a11fa4e3479afcf17040ca58e370550eec9aa
treecad8d3ff15fffbbe8c7255f0fd87ac18634d8bf2
parentcdabf743c6997bbf8cc1086febffc3bb67596177
cifs: avoid deadlocks while updating iface

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: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/connect.c
fs/cifs/sess.c