Skip to content

Commit 978b567

Browse files
Marios Makassikisnamjaejeon
authored andcommitted
ksmbd: smb1: fix session setup without SPNEGO
- Unset spnego bit in SMB negotiate response. - Include NativeOS / Native LAN Manager / Primary Domain fields in session setup response. Without these, smbclient fails with NT_STATUS_BUFFER_TOO_SMALL. Tested with smbclient: smbclient //127.0.0.1/testshare -U user%password \ --option "client min protocol = NT1" \ --option "client use spnego = no" \ -m NT1 Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 3df3c5b commit 978b567

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

smb1pdu.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ int smb_handle_negotiate(struct ksmbd_work *work)
862862

863863
if (conn->use_spnego == false) {
864864
neg_rsp->EncryptionKeyLength = CIFS_CRYPTO_KEY_SIZE;
865+
neg_rsp->Capabilities &= ~cpu_to_le32(CAP_EXTENDED_SECURITY);
865866
neg_rsp->ByteCount = cpu_to_le16(CIFS_CRYPTO_KEY_SIZE);
866867
/* initialize random server challenge */
867868
get_random_bytes(conn->ntlmssp.cryptkey, sizeof(__u64));
@@ -895,8 +896,9 @@ static int build_sess_rsp_noextsec(struct ksmbd_conn *conn,
895896
struct smb_com_session_setup_req_no_secext *req,
896897
struct smb_com_session_setup_old_resp *rsp)
897898
{
898-
int offset, err = 0;
899+
int offset, err = 0, len;
899900
char *name;
901+
__le16 str[32];
900902

901903
/* Build response. We don't use extended security (yet), so wct is 3 */
902904
rsp->hdr.WordCount = 3;
@@ -981,6 +983,29 @@ static int build_sess_rsp_noextsec(struct ksmbd_conn *conn,
981983
rsp->AndXReserved = 0;
982984
rsp->AndXOffset = cpu_to_le16(get_rfc1002_len(&rsp->hdr));
983985

986+
/* 1 byte padding for word alignment */
987+
offset = 1;
988+
989+
memset(str, 0 , sizeof(str));
990+
991+
len = smb_strtoUTF16(str, "Unix", 4, conn->local_nls);
992+
len = UNICODE_LEN(len + 1);
993+
memcpy(rsp->NativeOS + offset, str, len);
994+
offset += len;
995+
996+
len = smb_strtoUTF16(str, "ksmbd", 5, conn->local_nls);
997+
len = UNICODE_LEN(len + 1);
998+
memcpy(rsp->NativeOS + offset, str, len);
999+
offset += len;
1000+
1001+
len = smb_strtoUTF16(str, "WORKGROUP", 9, conn->local_nls);
1002+
len = UNICODE_LEN(len + 1);
1003+
memcpy(rsp->NativeOS + offset, str, len);
1004+
offset += len;
1005+
1006+
rsp->ByteCount = cpu_to_le16(offset);
1007+
inc_rfc1001_len(&rsp->hdr, offset);
1008+
9841009
if (req->AndXCommand != SMB_NO_MORE_ANDX_COMMAND) {
9851010
/* adjust response */
9861011
rsp->AndXCommand = req->AndXCommand;

0 commit comments

Comments
 (0)