Skip to content

Commit 32f3191

Browse files
committed
smb3: workaround negprot bug in some Samba servers
Mount can now fail to older Samba servers due to a server bug handling padding at the end of the last negotiate context (negotiate contexts typically are rounded up to 8 bytes by adding padding if needed). This server bug can be avoided by switching the order of negotiate contexts, placing a negotiate context at the end that does not require padding (prior to the recent netname context fix this was the case on the client). Fixes: 73130a7 ("smb3: fix empty netname context on secondary channels") Reported-by: Julian Sikorski <belegdol@gmail.com> Tested-by: Julian Sikorski <belegdol+github@gmail.com> Reviewed-by: Shyam Prasad N <sprasad@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 2883f4b commit 32f3191

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

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)