Skip to content

Commit 84a1f5b

Browse files
Paulo Alcantara (SUSE)smfrench
authored andcommitted
cifs: Fix potential softlockups while refreshing DFS cache
We used to skip reconnects on all SMB2_IOCTL commands due to SMB3+ FSCTL_VALIDATE_NEGOTIATE_INFO - which made sense since we're still establishing a SMB session. However, when refresh_cache_worker() calls smb2_get_dfs_refer() and we're under reconnect, SMB2_ioctl() will not be able to get a proper status error (e.g. -EHOSTDOWN in case we failed to reconnect) but an -EAGAIN from cifs_send_recv() thus looping forever in refresh_cache_worker(). Fixes: e99c63e ("SMB3: Fix deadlock in validate negotiate hits reconnect") Signed-off-by: Paulo Alcantara (SUSE) <[email protected]> Suggested-by: Aurelien Aptel <[email protected]> Reviewed-by: Aurelien Aptel <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent df3df92 commit 84a1f5b

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

fs/cifs/smb2pdu.c

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon)
252252
if (tcon == NULL)
253253
return 0;
254254

255-
if (smb2_command == SMB2_TREE_CONNECT || smb2_command == SMB2_IOCTL)
255+
if (smb2_command == SMB2_TREE_CONNECT)
256256
return 0;
257257

258258
if (tcon->tidStatus == CifsExiting) {
@@ -426,16 +426,9 @@ fill_small_buf(__le16 smb2_command, struct cifs_tcon *tcon, void *buf,
426426
* SMB information in the SMB header. If the return code is zero, this
427427
* function must have filled in request_buf pointer.
428428
*/
429-
static int
430-
smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
431-
void **request_buf, unsigned int *total_len)
429+
static int __smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
430+
void **request_buf, unsigned int *total_len)
432431
{
433-
int rc;
434-
435-
rc = smb2_reconnect(smb2_command, tcon);
436-
if (rc)
437-
return rc;
438-
439432
/* BB eventually switch this to SMB2 specific small buf size */
440433
if (smb2_command == SMB2_SET_INFO)
441434
*request_buf = cifs_buf_get();
@@ -456,7 +449,31 @@ smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
456449
cifs_stats_inc(&tcon->num_smbs_sent);
457450
}
458451

459-
return rc;
452+
return 0;
453+
}
454+
455+
static int smb2_plain_req_init(__le16 smb2_command, struct cifs_tcon *tcon,
456+
void **request_buf, unsigned int *total_len)
457+
{
458+
int rc;
459+
460+
rc = smb2_reconnect(smb2_command, tcon);
461+
if (rc)
462+
return rc;
463+
464+
return __smb2_plain_req_init(smb2_command, tcon, request_buf,
465+
total_len);
466+
}
467+
468+
static int smb2_ioctl_req_init(u32 opcode, struct cifs_tcon *tcon,
469+
void **request_buf, unsigned int *total_len)
470+
{
471+
/* Skip reconnect only for FSCTL_VALIDATE_NEGOTIATE_INFO IOCTLs */
472+
if (opcode == FSCTL_VALIDATE_NEGOTIATE_INFO) {
473+
return __smb2_plain_req_init(SMB2_IOCTL, tcon, request_buf,
474+
total_len);
475+
}
476+
return smb2_plain_req_init(SMB2_IOCTL, tcon, request_buf, total_len);
460477
}
461478

462479
/* For explanation of negotiate contexts see MS-SMB2 section 2.2.3.1 */
@@ -2686,7 +2703,7 @@ SMB2_ioctl_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,
26862703
int rc;
26872704
char *in_data_buf;
26882705

2689-
rc = smb2_plain_req_init(SMB2_IOCTL, tcon, (void **) &req, &total_len);
2706+
rc = smb2_ioctl_req_init(opcode, tcon, (void **) &req, &total_len);
26902707
if (rc)
26912708
return rc;
26922709

0 commit comments

Comments
 (0)