Skip to content

Commit f41d5df

Browse files
committed
Merge tag '5.19-rc6-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "Three smb3 client fixes: - two multichannel fixes: fix a potential deadlock freeing a channel, and fix a race condition on failed creation of a new channel - mount failure fix: work around a server bug in some common older Samba servers by avoiding padding at the end of the negotiate protocol request" * tag '5.19-rc6-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: smb3: workaround negprot bug in some Samba servers cifs: remove unnecessary locking of chan_lock while freeing session cifs: fix race condition with delayed threads
2 parents a24a6c0 + 32f3191 commit f41d5df

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

fs/cifs/connect.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,6 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
19181918
list_del_init(&ses->smb_ses_list);
19191919
spin_unlock(&cifs_tcp_ses_lock);
19201920

1921-
spin_lock(&ses->chan_lock);
19221921
chan_count = ses->chan_count;
19231922

19241923
/* close any extra channels */
@@ -1934,7 +1933,6 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
19341933
ses->chans[i].server = NULL;
19351934
}
19361935
}
1937-
spin_unlock(&ses->chan_lock);
19381936

19391937
sesInfoFree(ses);
19401938
cifs_put_tcp_session(server, 0);

fs/cifs/sess.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,14 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
474474

475475
out:
476476
if (rc && chan->server) {
477+
/*
478+
* we should avoid race with these delayed works before we
479+
* remove this channel
480+
*/
481+
cancel_delayed_work_sync(&chan->server->echo);
482+
cancel_delayed_work_sync(&chan->server->resolve);
483+
cancel_delayed_work_sync(&chan->server->reconnect);
484+
477485
spin_lock(&ses->chan_lock);
478486
/* we rely on all bits beyond chan_count to be clear */
479487
cifs_chan_clear_need_reconnect(ses, chan->server);
@@ -484,10 +492,9 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
484492
*/
485493
WARN_ON(ses->chan_count < 1);
486494
spin_unlock(&ses->chan_lock);
487-
}
488495

489-
if (rc && chan->server)
490496
cifs_put_tcp_session(chan->server, 0);
497+
}
491498

492499
return rc;
493500
}

fs/cifs/smb2pdu.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,6 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
571571
*total_len += ctxt_len;
572572
pneg_ctxt += ctxt_len;
573573

574-
build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt);
575-
*total_len += sizeof(struct smb2_posix_neg_context);
576-
pneg_ctxt += sizeof(struct smb2_posix_neg_context);
577-
578574
/*
579575
* secondary channels don't have the hostname field populated
580576
* use the hostname field in the primary channel instead
@@ -586,9 +582,14 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
586582
hostname);
587583
*total_len += ctxt_len;
588584
pneg_ctxt += ctxt_len;
589-
neg_context_count = 4;
590-
} else /* second channels do not have a hostname */
591585
neg_context_count = 3;
586+
} else
587+
neg_context_count = 2;
588+
589+
build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt);
590+
*total_len += sizeof(struct smb2_posix_neg_context);
591+
pneg_ctxt += sizeof(struct smb2_posix_neg_context);
592+
neg_context_count++;
592593

593594
if (server->compress_algorithm) {
594595
build_compression_ctxt((struct smb2_compression_capabilities_context *)

0 commit comments

Comments
 (0)