Print this page
12513 SMB 3.1.1 support for server
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2019 Nexenta Systems, Inc.  All rights reserved.
  14  * Copyright 2019 RackTop Systems.
  15  */
  16 
  17 
  18 #include <smbsrv/smb2_kproto.h>
  19 #include <smbsrv/smb_kstat.h>
  20 #include <smbsrv/smb2.h>
  21 
  22 #define SMB2_ASYNCID(sr) (sr->smb2_messageid ^ (1ULL << 62))
  23 
  24 smb_sdrc_t smb2_invalid_cmd(smb_request_t *);
  25 static void smb2_tq_work(void *);
  26 static void smb2sr_run_postwork(smb_request_t *);
  27 static int smb3_decrypt_msg(smb_request_t *);
  28 
  29 static const smb_disp_entry_t
  30 smb2_disp_table[SMB2__NCMDS] = {
  31 
  32         /* text-name, pre, func, post, cmd-code, dialect, flags */
  33 
  34         {  "smb2_negotiate", NULL,


 956 
 957         /*
 958          * If there's a next command, figure out where it starts,
 959          * and fill in the next header offset for the reply.
 960          * Note: We sanity checked smb2_next_command above.
 961          */
 962         if (sr->smb2_next_command != 0) {
 963                 sr->command.chain_offset =
 964                     sr->smb2_cmd_hdr + sr->smb2_next_command;
 965                 sr->smb2_next_reply =
 966                     sr->reply.chain_offset - sr->smb2_reply_hdr;
 967         } else {
 968                 ASSERT(sr->smb2_next_reply == 0);
 969         }
 970 
 971         /*
 972          * Overwrite the (now final) SMB2 header for this response.
 973          */
 974         (void) smb2_encode_header(sr, B_TRUE);
 975 










 976         /* Don't sign if we're going to encrypt */
 977         if (sr->tform_ssn == NULL &&
 978             (sr->smb2_hdr_flags & SMB2_FLAGS_SIGNED) != 0)
 979                 smb2_sign_reply(sr);
 980 
 981         /*
 982          * Non-async runs the whole compound before send.
 983          * When we've gone async, send each individually.
 984          */
 985         if (!sr->smb2_async && sr->smb2_next_command != 0)
 986                 goto cmd_start;
 987 
 988         /*
 989          * If we have a durable handle, and this operation updated
 990          * the nvlist, write it out (before smb2_send_reply).
 991          */
 992         if (sr->dh_nvl_dirty) {
 993                 sr->dh_nvl_dirty = B_FALSE;
 994                 smb2_dh_update_nvfile(sr);
 995         }


   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2019 Nexenta Systems, Inc.  All rights reserved.
  14  * Copyright 2020 RackTop Systems, Inc.
  15  */
  16 
  17 
  18 #include <smbsrv/smb2_kproto.h>
  19 #include <smbsrv/smb_kstat.h>
  20 #include <smbsrv/smb2.h>
  21 
  22 #define SMB2_ASYNCID(sr) (sr->smb2_messageid ^ (1ULL << 62))
  23 
  24 smb_sdrc_t smb2_invalid_cmd(smb_request_t *);
  25 static void smb2_tq_work(void *);
  26 static void smb2sr_run_postwork(smb_request_t *);
  27 static int smb3_decrypt_msg(smb_request_t *);
  28 
  29 static const smb_disp_entry_t
  30 smb2_disp_table[SMB2__NCMDS] = {
  31 
  32         /* text-name, pre, func, post, cmd-code, dialect, flags */
  33 
  34         {  "smb2_negotiate", NULL,


 956 
 957         /*
 958          * If there's a next command, figure out where it starts,
 959          * and fill in the next header offset for the reply.
 960          * Note: We sanity checked smb2_next_command above.
 961          */
 962         if (sr->smb2_next_command != 0) {
 963                 sr->command.chain_offset =
 964                     sr->smb2_cmd_hdr + sr->smb2_next_command;
 965                 sr->smb2_next_reply =
 966                     sr->reply.chain_offset - sr->smb2_reply_hdr;
 967         } else {
 968                 ASSERT(sr->smb2_next_reply == 0);
 969         }
 970 
 971         /*
 972          * Overwrite the (now final) SMB2 header for this response.
 973          */
 974         (void) smb2_encode_header(sr, B_TRUE);
 975 
 976         /*
 977          * Cannot move this into smb2_session_setup() - encoded header required.
 978          */
 979         if (session->dialect >= SMB_VERS_3_11 &&
 980             sr->smb2_cmd_code == SMB2_SESSION_SETUP &&
 981             sr->smb2_status == NT_STATUS_MORE_PROCESSING_REQUIRED) {
 982                 (void) smb31_preauth_sha512_calc(sr, &sr->reply,
 983                     session->smb31_preauth_hashval);
 984         }
 985 
 986         /* Don't sign if we're going to encrypt */
 987         if (sr->tform_ssn == NULL &&
 988             (sr->smb2_hdr_flags & SMB2_FLAGS_SIGNED) != 0)
 989                 smb2_sign_reply(sr);
 990 
 991         /*
 992          * Non-async runs the whole compound before send.
 993          * When we've gone async, send each individually.
 994          */
 995         if (!sr->smb2_async && sr->smb2_next_command != 0)
 996                 goto cmd_start;
 997 
 998         /*
 999          * If we have a durable handle, and this operation updated
1000          * the nvlist, write it out (before smb2_send_reply).
1001          */
1002         if (sr->dh_nvl_dirty) {
1003                 sr->dh_nvl_dirty = B_FALSE;
1004                 smb2_dh_update_nvfile(sr);
1005         }