Skip to content

Commit a3713ec

Browse files
Roberto Bergantinos Corpassmfrench
authored andcommitted
cifs`: handle ERRBaduid for SMB1
If server returns ERRBaduid but does not reset transport connection, we'll keep sending command with a non-valid UID for the server as long as transport is healthy, without actually recovering. This have been observed on the field. This patch adds ERRBaduid handling so that we set CifsNeedReconnect. map_and_check_smb_error() can be modified to extend use cases. Signed-off-by: Roberto Bergantinos Corpas <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Ronnie Sahlberg <[email protected]>
1 parent 66a4bbc commit a3713ec

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

fs/cifs/cifsproto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ extern int decode_negTokenInit(unsigned char *security_blob, int length,
154154
extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
155155
extern void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
156156
extern int map_smb_to_linux_error(char *buf, bool logErr);
157+
extern int map_and_check_smb_error(struct mid_q_entry *mid, bool logErr);
157158
extern void header_assemble(struct smb_hdr *, char /* command */ ,
158159
const struct cifs_tcon *, int /* length of
159160
fixed section (word count) in two byte units */);

fs/cifs/netmisc.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,33 @@ map_smb_to_linux_error(char *buf, bool logErr)
881881
return rc;
882882
}
883883

884+
int
885+
map_and_check_smb_error(struct mid_q_entry *mid, bool logErr)
886+
{
887+
int rc;
888+
struct smb_hdr *smb = (struct smb_hdr *)mid->resp_buf;
889+
890+
rc = map_smb_to_linux_error((char *)smb, logErr);
891+
if (rc == -EACCES && !(smb->Flags2 & SMBFLG2_ERR_STATUS)) {
892+
/* possible ERRBaduid */
893+
__u8 class = smb->Status.DosError.ErrorClass;
894+
__u16 code = le16_to_cpu(smb->Status.DosError.Error);
895+
896+
/* switch can be used to handle different errors */
897+
if (class == ERRSRV && code == ERRbaduid) {
898+
cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
899+
code);
900+
spin_lock(&GlobalMid_Lock);
901+
if (mid->server->tcpStatus != CifsExiting)
902+
mid->server->tcpStatus = CifsNeedReconnect;
903+
spin_unlock(&GlobalMid_Lock);
904+
}
905+
}
906+
907+
return rc;
908+
}
909+
910+
884911
/*
885912
* calculate the size of the SMB message based on the fixed header
886913
* portion, the number of word parameters and the data portion of the message

fs/cifs/transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
936936
}
937937

938938
/* BB special case reconnect tid and uid here? */
939-
return map_smb_to_linux_error(mid->resp_buf, log_error);
939+
return map_and_check_smb_error(mid, log_error);
940940
}
941941

942942
struct mid_q_entry *

0 commit comments

Comments
 (0)