]> git.baikalelectronics.ru Git - kernel.git/commit
cifs: avoid race during socket reconnect between send and recv
authorShyam Prasad N <sprasad@microsoft.com>
Mon, 25 Oct 2021 05:44:10 +0000 (05:44 +0000)
committerSteve French <stfrench@microsoft.com>
Sat, 8 Jan 2022 02:09:23 +0000 (20:09 -0600)
commit43923636efd29ee9e2400d455ea82776b9e740e3
treec9002fe22f2e9294726411f82e012835ffef95ac
parentf9458cd0811820458a93f0669d6c7d50185be2a7
cifs: avoid race during socket reconnect between send and recv

When a TCP connection gets reestablished by the sender in cifs_reconnect,
There is a chance for race condition with demultiplex thread waiting in
cifs_readv_from_socket on the old socket. It will now return -ECONNRESET.

This condition is handled by comparing socket pointer before and after
sock_recvmsg. If the socket pointer has changed, we should not call
cifs_reconnect again, but instead retry with new socket.

Also fixed another bug in my prev mchan commits.
We should always reestablish session (even if binding) on a channel
that needs reconnection.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/connect.c
fs/cifs/smb2pdu.c
fs/cifs/transport.c