Skip to content

Commit 28f3b86

Browse files
committed
smb: client: fix hang in wait_for_response() for negproto
jira LE-2157 Rebuild_History Non-Buildable kernel-5.14.0-503.14.1.el9_5 commit-author Paulo Alcantara <[email protected]> commit 7ccc146 Call cifs_reconnect() to wake up processes waiting on negotiate protocol to handle the case where server abruptly shut down and had no chance to properly close the socket. Simple reproducer: ssh 192.168.2.100 pkill -STOP smbd mount.cifs //192.168.2.100/test /mnt -o ... [never returns] Cc: Rickard Andersson <[email protected]> Signed-off-by: Paulo Alcantara (Red Hat) <[email protected]> Signed-off-by: Steve French <[email protected]> (cherry picked from commit 7ccc146) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 13678b9 commit 28f3b86

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

fs/smb/client/connect.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,19 @@ allocate_buffers(struct TCP_Server_Info *server)
656656
static bool
657657
server_unresponsive(struct TCP_Server_Info *server)
658658
{
659+
/*
660+
* If we're in the process of mounting a share or reconnecting a session
661+
* and the server abruptly shut down (e.g. socket wasn't closed, packet
662+
* had been ACK'ed but no SMB response), don't wait longer than 20s to
663+
* negotiate protocol.
664+
*/
665+
spin_lock(&server->srv_lock);
666+
if (server->tcpStatus == CifsInNegotiate &&
667+
time_after(jiffies, server->lstrp + 20 * HZ)) {
668+
spin_unlock(&server->srv_lock);
669+
cifs_reconnect(server, false);
670+
return true;
671+
}
659672
/*
660673
* We need to wait 3 echo intervals to make sure we handle such
661674
* situations right:
@@ -667,7 +680,6 @@ server_unresponsive(struct TCP_Server_Info *server)
667680
* 65s kernel_recvmsg times out, and we see that we haven't gotten
668681
* a response in >60s.
669682
*/
670-
spin_lock(&server->srv_lock);
671683
if ((server->tcpStatus == CifsGood ||
672684
server->tcpStatus == CifsNeedNegotiate) &&
673685
(!server->ops->can_echo || server->ops->can_echo(server)) &&

0 commit comments

Comments
 (0)