1*a90cf9f2SGordon Ross /* 2*a90cf9f2SGordon Ross * This file and its contents are supplied under the terms of the 3*a90cf9f2SGordon Ross * Common Development and Distribution License ("CDDL"), version 1.0. 4*a90cf9f2SGordon Ross * You may only use this file in accordance with the terms of version 5*a90cf9f2SGordon Ross * 1.0 of the CDDL. 6*a90cf9f2SGordon Ross * 7*a90cf9f2SGordon Ross * A full copy of the text of the CDDL should have accompanied this 8*a90cf9f2SGordon Ross * source. A copy of the CDDL is also available via the Internet at 9*a90cf9f2SGordon Ross * http://www.illumos.org/license/CDDL. 10*a90cf9f2SGordon Ross */ 11*a90cf9f2SGordon Ross 12*a90cf9f2SGordon Ross /* 13*a90cf9f2SGordon Ross * Copyright 2015 Nexenta Systems, Inc. All rights reserved. 14*a90cf9f2SGordon Ross */ 15*a90cf9f2SGordon Ross 16*a90cf9f2SGordon Ross /* 17*a90cf9f2SGordon Ross * Dispatch function for SMB2_NEGOTIATE 18*a90cf9f2SGordon Ross */ 19*a90cf9f2SGordon Ross 20*a90cf9f2SGordon Ross #include <smbsrv/smb2_kproto.h> 21*a90cf9f2SGordon Ross #include <smbsrv/smb2.h> 22*a90cf9f2SGordon Ross 23*a90cf9f2SGordon Ross static int smb2_negotiate_common(smb_request_t *, uint16_t); 24*a90cf9f2SGordon Ross 25*a90cf9f2SGordon Ross uint32_t smb2srv_capabilities = 26*a90cf9f2SGordon Ross SMB2_CAP_DFS | 27*a90cf9f2SGordon Ross SMB2_CAP_LARGE_MTU; 28*a90cf9f2SGordon Ross 29*a90cf9f2SGordon Ross /* 30*a90cf9f2SGordon Ross * These are not intended as customer tunables, but dev. & test folks 31*a90cf9f2SGordon Ross * might want to adjust them (with caution). 32*a90cf9f2SGordon Ross * 33*a90cf9f2SGordon Ross * smb2_tcp_bufsize is the TCP buffer size, applied to the network socket 34*a90cf9f2SGordon Ross * with setsockopt SO_SNDBUF, SO_RCVBUF. These set the TCP window size. 35*a90cf9f2SGordon Ross * This is also used as a "sanity limit" for internal send/reply message 36*a90cf9f2SGordon Ross * allocations. Note that with compounding SMB2 messages may contain 37*a90cf9f2SGordon Ross * multiple requests/responses. This size should be large enough for 38*a90cf9f2SGordon Ross * at least a few SMB2 requests, and at least 2X smb2_max_rwsize. 39*a90cf9f2SGordon Ross * 40*a90cf9f2SGordon Ross * smb2_max_rwsize is what we put in the SMB2 negotiate response to tell 41*a90cf9f2SGordon Ross * the client the largest read and write request size we'll support. 42*a90cf9f2SGordon Ross * One megabyte is a compromise between efficiency on fast networks 43*a90cf9f2SGordon Ross * and memory consumption (for the buffers) on the server side. 44*a90cf9f2SGordon Ross * 45*a90cf9f2SGordon Ross * smb2_max_trans is the largest "transact" send or receive, which is 46*a90cf9f2SGordon Ross * used for directory listings and info set/get operations. 47*a90cf9f2SGordon Ross */ 48*a90cf9f2SGordon Ross uint32_t smb2_tcp_bufsize = (1<<22); /* 4MB */ 49*a90cf9f2SGordon Ross uint32_t smb2_max_rwsize = (1<<20); /* 1MB */ 50*a90cf9f2SGordon Ross uint32_t smb2_max_trans = (1<<16); /* 64KB */ 51*a90cf9f2SGordon Ross 52*a90cf9f2SGordon Ross /* 53*a90cf9f2SGordon Ross * List of all SMB2 versions we implement. Note that the 54*a90cf9f2SGordon Ross * highest version we support may be limited by the 55*a90cf9f2SGordon Ross * _cfg.skc_max_protocol setting. 56*a90cf9f2SGordon Ross */ 57*a90cf9f2SGordon Ross static uint16_t smb2_versions[] = { 58*a90cf9f2SGordon Ross 0x202, /* SMB 2.002 */ 59*a90cf9f2SGordon Ross 0x210, /* SMB 2.1 */ 60*a90cf9f2SGordon Ross }; 61*a90cf9f2SGordon Ross static uint16_t smb2_nversions = 62*a90cf9f2SGordon Ross sizeof (smb2_versions) / sizeof (smb2_versions[0]); 63*a90cf9f2SGordon Ross 64*a90cf9f2SGordon Ross static boolean_t 65*a90cf9f2SGordon Ross smb2_supported_version(smb_session_t *s, uint16_t version) 66*a90cf9f2SGordon Ross { 67*a90cf9f2SGordon Ross int i; 68*a90cf9f2SGordon Ross 69*a90cf9f2SGordon Ross if (version > s->s_cfg.skc_max_protocol) 70*a90cf9f2SGordon Ross return (B_FALSE); 71*a90cf9f2SGordon Ross for (i = 0; i < smb2_nversions; i++) 72*a90cf9f2SGordon Ross if (version == smb2_versions[i]) 73*a90cf9f2SGordon Ross return (B_TRUE); 74*a90cf9f2SGordon Ross return (B_FALSE); 75*a90cf9f2SGordon Ross } 76*a90cf9f2SGordon Ross 77*a90cf9f2SGordon Ross /* 78*a90cf9f2SGordon Ross * Helper for the (SMB1) smb_com_negotiate(). This is the 79*a90cf9f2SGordon Ross * very unusual protocol interaction where an SMB1 negotiate 80*a90cf9f2SGordon Ross * gets an SMB2 negotiate response. This is the normal way 81*a90cf9f2SGordon Ross * clients first find out if the server supports SMB2. 82*a90cf9f2SGordon Ross * 83*a90cf9f2SGordon Ross * Note: This sends an SMB2 reply _itself_ and then returns 84*a90cf9f2SGordon Ross * SDRC_NO_REPLY so the caller will not send an SMB1 reply. 85*a90cf9f2SGordon Ross * Also, this is called directly from the reader thread, so 86*a90cf9f2SGordon Ross * we know this is the only thread using this session. 87*a90cf9f2SGordon Ross * 88*a90cf9f2SGordon Ross * The caller frees this request. 89*a90cf9f2SGordon Ross */ 90*a90cf9f2SGordon Ross smb_sdrc_t 91*a90cf9f2SGordon Ross smb1_negotiate_smb2(smb_request_t *sr) 92*a90cf9f2SGordon Ross { 93*a90cf9f2SGordon Ross smb_session_t *s = sr->session; 94*a90cf9f2SGordon Ross smb_arg_negotiate_t *negprot = sr->sr_negprot; 95*a90cf9f2SGordon Ross uint16_t smb2_version; 96*a90cf9f2SGordon Ross uint16_t secmode2; 97*a90cf9f2SGordon Ross int rc; 98*a90cf9f2SGordon Ross 99*a90cf9f2SGordon Ross /* 100*a90cf9f2SGordon Ross * Note: In the SMB1 negotiate command handler, we 101*a90cf9f2SGordon Ross * agreed with one of the SMB2 dialects. If that 102*a90cf9f2SGordon Ross * dialect was "SMB 2.002", we'll respond here with 103*a90cf9f2SGordon Ross * version 0x202 and negotiation is done. If that 104*a90cf9f2SGordon Ross * dialect was "SMB 2.???", we'll respond here with 105*a90cf9f2SGordon Ross * the "wildcard" version 0x2FF, and the client will 106*a90cf9f2SGordon Ross * come back with an SMB2 negotiate. 107*a90cf9f2SGordon Ross */ 108*a90cf9f2SGordon Ross switch (negprot->ni_dialect) { 109*a90cf9f2SGordon Ross case DIALECT_SMB2002: /* SMB 2.002 (a.k.a. SMB2.0) */ 110*a90cf9f2SGordon Ross smb2_version = 0x202; 111*a90cf9f2SGordon Ross s->dialect = smb2_version; 112*a90cf9f2SGordon Ross s->s_state = SMB_SESSION_STATE_NEGOTIATED; 113*a90cf9f2SGordon Ross /* Allow normal SMB2 requests now. */ 114*a90cf9f2SGordon Ross s->newrq_func = smb2sr_newrq; 115*a90cf9f2SGordon Ross 116*a90cf9f2SGordon Ross /* 117*a90cf9f2SGordon Ross * Translate SMB1 sec. mode to SMB2. 118*a90cf9f2SGordon Ross */ 119*a90cf9f2SGordon Ross secmode2 = 0; 120*a90cf9f2SGordon Ross if (s->secmode & NEGOTIATE_SECURITY_SIGNATURES_ENABLED) 121*a90cf9f2SGordon Ross secmode2 |= SMB2_NEGOTIATE_SIGNING_ENABLED; 122*a90cf9f2SGordon Ross if (s->secmode & NEGOTIATE_SECURITY_SIGNATURES_REQUIRED) 123*a90cf9f2SGordon Ross secmode2 |= SMB2_NEGOTIATE_SIGNING_REQUIRED; 124*a90cf9f2SGordon Ross s->secmode = secmode2; 125*a90cf9f2SGordon Ross break; 126*a90cf9f2SGordon Ross case DIALECT_SMB2XXX: /* SMB 2.??? (wildcard vers) */ 127*a90cf9f2SGordon Ross /* 128*a90cf9f2SGordon Ross * Expecting an SMB2 negotiate next, so keep the 129*a90cf9f2SGordon Ross * initial s->newrq_func. Note that secmode is 130*a90cf9f2SGordon Ross * fiction good enough to pass the signing check 131*a90cf9f2SGordon Ross * in smb2_negotiate_common(). We'll check the 132*a90cf9f2SGordon Ross * real secmode when the 2nd negotiate comes. 133*a90cf9f2SGordon Ross */ 134*a90cf9f2SGordon Ross smb2_version = 0x2FF; 135*a90cf9f2SGordon Ross s->secmode = SMB2_NEGOTIATE_SIGNING_ENABLED; 136*a90cf9f2SGordon Ross break; 137*a90cf9f2SGordon Ross default: 138*a90cf9f2SGordon Ross return (SDRC_DROP_VC); 139*a90cf9f2SGordon Ross } 140*a90cf9f2SGordon Ross 141*a90cf9f2SGordon Ross /* 142*a90cf9f2SGordon Ross * We did not decode an SMB2 header, so make sure 143*a90cf9f2SGordon Ross * the SMB2 header fields are initialized. 144*a90cf9f2SGordon Ross * (Most are zero from smb_request_alloc.) 145*a90cf9f2SGordon Ross * Also, the SMB1 common dispatch code reserved space 146*a90cf9f2SGordon Ross * for an SMB1 header, which we need to undo here. 147*a90cf9f2SGordon Ross */ 148*a90cf9f2SGordon Ross sr->smb2_reply_hdr = sr->reply.chain_offset = 0; 149*a90cf9f2SGordon Ross sr->smb2_cmd_code = SMB2_NEGOTIATE; 150*a90cf9f2SGordon Ross 151*a90cf9f2SGordon Ross rc = smb2_negotiate_common(sr, smb2_version); 152*a90cf9f2SGordon Ross if (rc != 0) 153*a90cf9f2SGordon Ross return (SDRC_DROP_VC); 154*a90cf9f2SGordon Ross 155*a90cf9f2SGordon Ross return (SDRC_NO_REPLY); 156*a90cf9f2SGordon Ross } 157*a90cf9f2SGordon Ross 158*a90cf9f2SGordon Ross /* 159*a90cf9f2SGordon Ross * SMB2 Negotiate gets special handling. This is called directly by 160*a90cf9f2SGordon Ross * the reader thread (see smbsr_newrq_initial) with what _should_ be 161*a90cf9f2SGordon Ross * an SMB2 Negotiate. Only the "\feSMB" header has been checked 162*a90cf9f2SGordon Ross * when this is called, so this needs to check the SMB command, 163*a90cf9f2SGordon Ross * if it's Negotiate execute it, then send the reply, etc. 164*a90cf9f2SGordon Ross * 165*a90cf9f2SGordon Ross * Since this is called directly from the reader thread, we 166*a90cf9f2SGordon Ross * know this is the only thread currently using this session. 167*a90cf9f2SGordon Ross * This has to duplicate some of what smb2sr_work does as a 168*a90cf9f2SGordon Ross * result of bypassing the normal dispatch mechanism. 169*a90cf9f2SGordon Ross * 170*a90cf9f2SGordon Ross * The caller always frees this request. 171*a90cf9f2SGordon Ross */ 172*a90cf9f2SGordon Ross int 173*a90cf9f2SGordon Ross smb2_newrq_negotiate(smb_request_t *sr) 174*a90cf9f2SGordon Ross { 175*a90cf9f2SGordon Ross smb_session_t *s = sr->session; 176*a90cf9f2SGordon Ross int i, rc; 177*a90cf9f2SGordon Ross uint16_t struct_size; 178*a90cf9f2SGordon Ross uint16_t best_version; 179*a90cf9f2SGordon Ross uint16_t version_cnt; 180*a90cf9f2SGordon Ross uint16_t cl_versions[8]; 181*a90cf9f2SGordon Ross 182*a90cf9f2SGordon Ross sr->smb2_cmd_hdr = sr->command.chain_offset; 183*a90cf9f2SGordon Ross rc = smb2_decode_header(sr); 184*a90cf9f2SGordon Ross if (rc != 0) 185*a90cf9f2SGordon Ross return (rc); 186*a90cf9f2SGordon Ross 187*a90cf9f2SGordon Ross if ((sr->smb2_cmd_code != SMB2_NEGOTIATE) || 188*a90cf9f2SGordon Ross (sr->smb2_next_command != 0)) 189*a90cf9f2SGordon Ross return (SDRC_DROP_VC); 190*a90cf9f2SGordon Ross 191*a90cf9f2SGordon Ross /* 192*a90cf9f2SGordon Ross * Decode SMB2 Negotiate (fixed-size part) 193*a90cf9f2SGordon Ross */ 194*a90cf9f2SGordon Ross rc = smb_mbc_decodef( 195*a90cf9f2SGordon Ross &sr->command, "www..l16.8.", 196*a90cf9f2SGordon Ross &struct_size, /* w */ 197*a90cf9f2SGordon Ross &version_cnt, /* w */ 198*a90cf9f2SGordon Ross &s->secmode, /* w */ 199*a90cf9f2SGordon Ross /* reserved (..) */ 200*a90cf9f2SGordon Ross &s->capabilities); /* l */ 201*a90cf9f2SGordon Ross /* clnt_uuid 16. */ 202*a90cf9f2SGordon Ross /* start_time 8. */ 203*a90cf9f2SGordon Ross if (rc != 0) 204*a90cf9f2SGordon Ross return (rc); 205*a90cf9f2SGordon Ross if (struct_size != 36 || version_cnt > 8) 206*a90cf9f2SGordon Ross return (SDRC_DROP_VC); 207*a90cf9f2SGordon Ross 208*a90cf9f2SGordon Ross /* 209*a90cf9f2SGordon Ross * Decode SMB2 Negotiate (variable part) 210*a90cf9f2SGordon Ross */ 211*a90cf9f2SGordon Ross rc = smb_mbc_decodef(&sr->command, 212*a90cf9f2SGordon Ross "#w", version_cnt, cl_versions); 213*a90cf9f2SGordon Ross if (rc != 0) 214*a90cf9f2SGordon Ross return (SDRC_DROP_VC); 215*a90cf9f2SGordon Ross 216*a90cf9f2SGordon Ross /* 217*a90cf9f2SGordon Ross * The client offers an array of protocol versions it 218*a90cf9f2SGordon Ross * supports, which we have decoded into cl_versions[]. 219*a90cf9f2SGordon Ross * We walk the array and pick the highest supported. 220*a90cf9f2SGordon Ross */ 221*a90cf9f2SGordon Ross best_version = 0; 222*a90cf9f2SGordon Ross for (i = 0; i < version_cnt; i++) 223*a90cf9f2SGordon Ross if (smb2_supported_version(s, cl_versions[i]) && 224*a90cf9f2SGordon Ross best_version < cl_versions[i]) 225*a90cf9f2SGordon Ross best_version = cl_versions[i]; 226*a90cf9f2SGordon Ross if (best_version == 0) 227*a90cf9f2SGordon Ross return (SDRC_DROP_VC); 228*a90cf9f2SGordon Ross s->dialect = best_version; 229*a90cf9f2SGordon Ross 230*a90cf9f2SGordon Ross /* Allow normal SMB2 requests now. */ 231*a90cf9f2SGordon Ross s->s_state = SMB_SESSION_STATE_NEGOTIATED; 232*a90cf9f2SGordon Ross s->newrq_func = smb2sr_newrq; 233*a90cf9f2SGordon Ross 234*a90cf9f2SGordon Ross rc = smb2_negotiate_common(sr, best_version); 235*a90cf9f2SGordon Ross if (rc != 0) 236*a90cf9f2SGordon Ross return (SDRC_DROP_VC); 237*a90cf9f2SGordon Ross 238*a90cf9f2SGordon Ross return (0); 239*a90cf9f2SGordon Ross } 240*a90cf9f2SGordon Ross 241*a90cf9f2SGordon Ross /* 242*a90cf9f2SGordon Ross * Common parts of SMB2 Negotiate, used for both the 243*a90cf9f2SGordon Ross * SMB1-to-SMB2 style, and straight SMB2 style. 244*a90cf9f2SGordon Ross * Do negotiation decisions, encode, send the reply. 245*a90cf9f2SGordon Ross */ 246*a90cf9f2SGordon Ross static int 247*a90cf9f2SGordon Ross smb2_negotiate_common(smb_request_t *sr, uint16_t version) 248*a90cf9f2SGordon Ross { 249*a90cf9f2SGordon Ross timestruc_t boot_tv, now_tv; 250*a90cf9f2SGordon Ross smb_session_t *s = sr->session; 251*a90cf9f2SGordon Ross int rc; 252*a90cf9f2SGordon Ross uint16_t secmode; 253*a90cf9f2SGordon Ross 254*a90cf9f2SGordon Ross sr->smb2_status = 0; 255*a90cf9f2SGordon Ross 256*a90cf9f2SGordon Ross /* 257*a90cf9f2SGordon Ross * Negotiation itself. First the Security Mode. 258*a90cf9f2SGordon Ross * The caller stashed the client's secmode in s->secmode, 259*a90cf9f2SGordon Ross * which we validate, and then replace with the server's 260*a90cf9f2SGordon Ross * secmode, which is all we care about after this. 261*a90cf9f2SGordon Ross */ 262*a90cf9f2SGordon Ross secmode = SMB2_NEGOTIATE_SIGNING_ENABLED; 263*a90cf9f2SGordon Ross if (sr->sr_cfg->skc_signing_required) { 264*a90cf9f2SGordon Ross secmode |= SMB2_NEGOTIATE_SIGNING_REQUIRED; 265*a90cf9f2SGordon Ross /* Make sure client at least enables signing. */ 266*a90cf9f2SGordon Ross if ((s->secmode & secmode) == 0) { 267*a90cf9f2SGordon Ross sr->smb2_status = NT_STATUS_INVALID_PARAMETER; 268*a90cf9f2SGordon Ross } 269*a90cf9f2SGordon Ross } 270*a90cf9f2SGordon Ross s->secmode = secmode; 271*a90cf9f2SGordon Ross 272*a90cf9f2SGordon Ross s->cmd_max_bytes = smb2_tcp_bufsize; 273*a90cf9f2SGordon Ross s->reply_max_bytes = smb2_tcp_bufsize; 274*a90cf9f2SGordon Ross 275*a90cf9f2SGordon Ross /* 276*a90cf9f2SGordon Ross * "The number of credits held by the client MUST be considered 277*a90cf9f2SGordon Ross * as 1 when the connection is established." [MS-SMB2] 278*a90cf9f2SGordon Ross * We leave credits at 1 until the first successful 279*a90cf9f2SGordon Ross * session setup is completed. 280*a90cf9f2SGordon Ross */ 281*a90cf9f2SGordon Ross s->s_cur_credits = s->s_max_credits = 1; 282*a90cf9f2SGordon Ross sr->smb2_credit_response = 1; 283*a90cf9f2SGordon Ross 284*a90cf9f2SGordon Ross boot_tv.tv_sec = smb_get_boottime(); 285*a90cf9f2SGordon Ross boot_tv.tv_nsec = 0; 286*a90cf9f2SGordon Ross now_tv.tv_sec = gethrestime_sec(); 287*a90cf9f2SGordon Ross now_tv.tv_nsec = 0; 288*a90cf9f2SGordon Ross 289*a90cf9f2SGordon Ross /* 290*a90cf9f2SGordon Ross * SMB2 negotiate reply 291*a90cf9f2SGordon Ross */ 292*a90cf9f2SGordon Ross sr->smb2_hdr_flags = SMB2_FLAGS_SERVER_TO_REDIR; 293*a90cf9f2SGordon Ross (void) smb2_encode_header(sr, B_FALSE); 294*a90cf9f2SGordon Ross if (sr->smb2_status != 0) { 295*a90cf9f2SGordon Ross smb2sr_put_error(sr, sr->smb2_status); 296*a90cf9f2SGordon Ross smb2_send_reply(sr); 297*a90cf9f2SGordon Ross return (-1); /* will drop */ 298*a90cf9f2SGordon Ross } 299*a90cf9f2SGordon Ross 300*a90cf9f2SGordon Ross rc = smb_mbc_encodef( 301*a90cf9f2SGordon Ross &sr->reply, 302*a90cf9f2SGordon Ross "wwww#cllllTTwwl#c", 303*a90cf9f2SGordon Ross 65, /* StructSize */ /* w */ 304*a90cf9f2SGordon Ross s->secmode, /* w */ 305*a90cf9f2SGordon Ross version, /* w */ 306*a90cf9f2SGordon Ross 0, /* reserved */ /* w */ 307*a90cf9f2SGordon Ross UUID_LEN, /* # */ 308*a90cf9f2SGordon Ross &s->s_cfg.skc_machine_uuid, /* c */ 309*a90cf9f2SGordon Ross smb2srv_capabilities, /* l */ 310*a90cf9f2SGordon Ross smb2_max_trans, /* l */ 311*a90cf9f2SGordon Ross smb2_max_rwsize, /* l */ 312*a90cf9f2SGordon Ross smb2_max_rwsize, /* l */ 313*a90cf9f2SGordon Ross &now_tv, /* T */ 314*a90cf9f2SGordon Ross &boot_tv, /* T */ 315*a90cf9f2SGordon Ross 128, /* SecBufOff */ /* w */ 316*a90cf9f2SGordon Ross sr->sr_cfg->skc_negtok_len, /* w */ 317*a90cf9f2SGordon Ross 0, /* reserved */ /* l */ 318*a90cf9f2SGordon Ross sr->sr_cfg->skc_negtok_len, /* # */ 319*a90cf9f2SGordon Ross sr->sr_cfg->skc_negtok); /* c */ 320*a90cf9f2SGordon Ross 321*a90cf9f2SGordon Ross smb2_send_reply(sr); 322*a90cf9f2SGordon Ross 323*a90cf9f2SGordon Ross (void) ksocket_setsockopt(s->sock, SOL_SOCKET, 324*a90cf9f2SGordon Ross SO_SNDBUF, (const void *)&smb2_tcp_bufsize, 325*a90cf9f2SGordon Ross sizeof (smb2_tcp_bufsize), CRED()); 326*a90cf9f2SGordon Ross (void) ksocket_setsockopt(s->sock, SOL_SOCKET, 327*a90cf9f2SGordon Ross SO_RCVBUF, (const void *)&smb2_tcp_bufsize, 328*a90cf9f2SGordon Ross sizeof (smb2_tcp_bufsize), CRED()); 329*a90cf9f2SGordon Ross 330*a90cf9f2SGordon Ross return (rc); 331*a90cf9f2SGordon Ross } 332*a90cf9f2SGordon Ross 333*a90cf9f2SGordon Ross /* 334*a90cf9f2SGordon Ross * SMB2 Dispatch table handler, which will run if we see an 335*a90cf9f2SGordon Ross * SMB2_NEGOTIATE after the initial negotiation is done. 336*a90cf9f2SGordon Ross * That would be a protocol error. 337*a90cf9f2SGordon Ross */ 338*a90cf9f2SGordon Ross smb_sdrc_t 339*a90cf9f2SGordon Ross smb2_negotiate(smb_request_t *sr) 340*a90cf9f2SGordon Ross { 341*a90cf9f2SGordon Ross sr->smb2_status = NT_STATUS_INVALID_PARAMETER; 342*a90cf9f2SGordon Ross return (SDRC_ERROR); 343*a90cf9f2SGordon Ross } 344*a90cf9f2SGordon Ross 345*a90cf9f2SGordon Ross /* 346*a90cf9f2SGordon Ross * VALIDATE_NEGOTIATE_INFO [MS-SMB2] 2.2.32.6 347*a90cf9f2SGordon Ross */ 348*a90cf9f2SGordon Ross uint32_t 349*a90cf9f2SGordon Ross smb2_fsctl_vneginfo(smb_request_t *sr, smb_fsctl_t *fsctl) 350*a90cf9f2SGordon Ross { 351*a90cf9f2SGordon Ross smb_session_t *s = sr->session; 352*a90cf9f2SGordon Ross int rc; 353*a90cf9f2SGordon Ross 354*a90cf9f2SGordon Ross /* 355*a90cf9f2SGordon Ross * The spec. says to parse the VALIDATE_NEGOTIATE_INFO here 356*a90cf9f2SGordon Ross * and verify that the original negotiate was not modified. 357*a90cf9f2SGordon Ross * The only tampering we need worry about is secmode, and 358*a90cf9f2SGordon Ross * we're not taking that from the client, so don't bother. 359*a90cf9f2SGordon Ross * 360*a90cf9f2SGordon Ross * One interesting requirement here is that we MUST reply 361*a90cf9f2SGordon Ross * with exactly the same information as we returned in our 362*a90cf9f2SGordon Ross * original reply to the SMB2 negotiate on this session. 363*a90cf9f2SGordon Ross * If we don't the client closes the connection. 364*a90cf9f2SGordon Ross */ 365*a90cf9f2SGordon Ross 366*a90cf9f2SGordon Ross rc = smb_mbc_encodef( 367*a90cf9f2SGordon Ross fsctl->out_mbc, "l#cww", 368*a90cf9f2SGordon Ross smb2srv_capabilities, /* l */ 369*a90cf9f2SGordon Ross UUID_LEN, /* # */ 370*a90cf9f2SGordon Ross &s->s_cfg.skc_machine_uuid, /* c */ 371*a90cf9f2SGordon Ross s->secmode, /* w */ 372*a90cf9f2SGordon Ross s->dialect); /* w */ 373*a90cf9f2SGordon Ross if (rc) 374*a90cf9f2SGordon Ross return (NT_STATUS_INTERNAL_ERROR); 375*a90cf9f2SGordon Ross 376*a90cf9f2SGordon Ross return (0); 377*a90cf9f2SGordon Ross } 378