mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-03 17:40:04 +00:00
cifs: eliminate some more premature cifsd exits
If the tcpStatus is still CifsNew, the main cifs_demultiplex_loop can break out prematurely in some cases. This is wrong as we will almost always have other structures with pointers to the TCP_Server_Info. If the main loop breaks under any other condition other than tcpStatus == CifsExiting, then it'll face a use-after-free situation. I don't see any reason to treat a CifsNew tcpStatus differently than CifsGood. I believe we'll still want to attempt to reconnect in either case. What should happen in those situations is that the MIDs get marked as MID_RETRY_NEEDED. This will make CIFSSMBNegotiate return -EAGAIN, and then the caller can retry the whole thing on a newly reconnected socket. If that fails again in the same way, the caller of cifs_get_smb_ses should tear down the TCP_Server_Info struct. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
522bbe65a2
commit
7332f2a621
1 changed files with 12 additions and 29 deletions
|
@ -416,14 +416,6 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
|
||||||
} else
|
} else
|
||||||
continue;
|
continue;
|
||||||
} else if (length <= 0) {
|
} else if (length <= 0) {
|
||||||
if (server->tcpStatus == CifsNew) {
|
|
||||||
cFYI(1, "tcp session abend after SMBnegprot");
|
|
||||||
/* some servers kill the TCP session rather than
|
|
||||||
returning an SMB negprot error, in which
|
|
||||||
case reconnecting here is not going to help,
|
|
||||||
and so simply return error to mount */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cFYI(1, "Reconnect after unexpected peek error %d",
|
cFYI(1, "Reconnect after unexpected peek error %d",
|
||||||
length);
|
length);
|
||||||
cifs_reconnect(server);
|
cifs_reconnect(server);
|
||||||
|
@ -464,27 +456,18 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
|
||||||
an error on SMB negprot response */
|
an error on SMB negprot response */
|
||||||
cFYI(1, "Negative RFC1002 Session Response Error 0x%x)",
|
cFYI(1, "Negative RFC1002 Session Response Error 0x%x)",
|
||||||
pdu_length);
|
pdu_length);
|
||||||
if (server->tcpStatus == CifsNew) {
|
/* give server a second to clean up */
|
||||||
/* if nack on negprot (rather than
|
msleep(1000);
|
||||||
ret of smb negprot error) reconnecting
|
/* always try 445 first on reconnect since we get NACK
|
||||||
not going to help, ret error to mount */
|
* on some if we ever connected to port 139 (the NACK
|
||||||
break;
|
* is since we do not begin with RFC1001 session
|
||||||
} else {
|
* initialize frame)
|
||||||
/* give server a second to
|
*/
|
||||||
clean up before reconnect attempt */
|
server->addr.sockAddr.sin_port = htons(CIFS_PORT);
|
||||||
msleep(1000);
|
cifs_reconnect(server);
|
||||||
/* always try 445 first on reconnect
|
csocket = server->ssocket;
|
||||||
since we get NACK on some if we ever
|
wake_up(&server->response_q);
|
||||||
connected to port 139 (the NACK is
|
continue;
|
||||||
since we do not begin with RFC1001
|
|
||||||
session initialize frame) */
|
|
||||||
server->addr.sockAddr.sin_port =
|
|
||||||
htons(CIFS_PORT);
|
|
||||||
cifs_reconnect(server);
|
|
||||||
csocket = server->ssocket;
|
|
||||||
wake_up(&server->response_q);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if (temp != (char) 0) {
|
} else if (temp != (char) 0) {
|
||||||
cERROR(1, "Unknown RFC 1002 frame");
|
cERROR(1, "Unknown RFC 1002 frame");
|
||||||
cifs_dump_mem(" Received Data: ", (char *)smb_buffer,
|
cifs_dump_mem(" Received Data: ", (char *)smb_buffer,
|
||||||
|
|
Loading…
Reference in a new issue