Skip to content

Commit e0bb0d0

Browse files
committed
smb: client: fix hang in wait_for_response() for negproto
jira LE-2015 Rebuild_History Non-Buildable kernel-5.14.0-427.42.1.el9_4 commit-author Paulo Alcantara <pc@manguebit.com> 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 <rickaran@axis.com> Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com> Signed-off-by: Steve French <stfrench@microsoft.com> (cherry picked from commit 7ccc146) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 1b5a425 commit e0bb0d0

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
@@ -617,6 +617,19 @@ allocate_buffers(struct TCP_Server_Info *server)
617617
static bool
618618
server_unresponsive(struct TCP_Server_Info *server)
619619
{
620+
/*
621+
* If we're in the process of mounting a share or reconnecting a session
622+
* and the server abruptly shut down (e.g. socket wasn't closed, packet
623+
* had been ACK'ed but no SMB response), don't wait longer than 20s to
624+
* negotiate protocol.
625+
*/
626+
spin_lock(&server->srv_lock);
627+
if (server->tcpStatus == CifsInNegotiate &&
628+
time_after(jiffies, server->lstrp + 20 * HZ)) {
629+
spin_unlock(&server->srv_lock);
630+
cifs_reconnect(server, false);
631+
return true;
632+
}
620633
/*
621634
* We need to wait 3 echo intervals to make sure we handle such
622635
* situations right:
@@ -628,7 +641,6 @@ server_unresponsive(struct TCP_Server_Info *server)
628641
* 65s kernel_recvmsg times out, and we see that we haven't gotten
629642
* a response in >60s.
630643
*/
631-
spin_lock(&server->srv_lock);
632644
if ((server->tcpStatus == CifsGood ||
633645
server->tcpStatus == CifsNeedNegotiate) &&
634646
(!server->ops->can_echo || server->ops->can_echo(server)) &&

0 commit comments

Comments
 (0)