Print this page
NEX-10019 SMB server min_protocol setting
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-5273 SMB 3 Encryption
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-4598 SMB2 credit shortage with Mac client
Reviewed by: Bayard Bell <bayard.bell@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
NEX-4539 Allow patching smb1srv_capabilities
Reviewed by: Bayard Bell <bayard.bell@nexenta.com>
Reviewed by: Matt Barden <Matt.Barden@nexenta.com>
SUP-672 Zero-padded IP address strings returned by SMB server...
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
NEX-3611 CLONE NEX-3550 Replace smb2_enable with max_protocol
Reviewed by: Yuri Pankov <Yuri.Pankov@nexenta.com>
NEX-2781 SMB2 credit handling needs work
NEX-1050 enable_smb2 should be smb2_enable
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
SMB-69 read-raw, write-raw are dead code
SMB-56 extended security NTLMSSP, inbound
SMB-50 User-mode SMB server
 Includes work by these authors:
 Thomas Keiser <thomas.keiser@nexenta.com>
 Albert Lee <trisk@nexenta.com>
SMB-65 SMB server in non-global zones (data structure changes)
Many things move to the smb_server_t object, and
many functions gain an sv arg (which server).
re #7126 rb4153 smbd panic with missing negotiate challenge

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbsrv/smb_negotiate.c
          +++ new/usr/src/uts/common/fs/smbsrv/smb_negotiate.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       23 + * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
  25   25  
  26   26  /*
  27   27   * Notes on the virtual circuit (VC) values in the SMB Negotiate
  28   28   * response and SessionSetupAndx request.
  29   29   *
  30   30   * A virtual circuit (VC) represents a connection between a client and a
  31   31   * server using a reliable, session oriented transport protocol, such as
  32   32   * NetBIOS or TCP/IP. Originally, each SMB session was restricted to a
  33   33   * single underlying transport connection, i.e. a single NetBIOS session,
↓ open down ↓ 239 lines elided ↑ open up ↑
 273  273   * an SMB1 Negotiate.  Only the "\ffSMB" header has been checked
 274  274   * when this is called, so this needs to check the SMB command,
 275  275   * if it's Negotiate execute it, then send the reply, etc.
 276  276   *
 277  277   * Since this is called directly from the reader thread, we
 278  278   * know this is the only thread currently using this session.
 279  279   * This has to duplicate some of what smb1sr_work does as a
 280  280   * result of bypassing the normal dispatch mechanism.
 281  281   *
 282  282   * The caller always frees this request.
      283 + *
      284 + * Return value is 0 for success, and anything else will
      285 + * terminate the reader thread (drop the connection).
 283  286   */
 284  287  int
 285  288  smb1_newrq_negotiate(smb_request_t *sr)
 286  289  {
 287  290          smb_sdrc_t      sdrc;
 288  291          uint16_t        pid_hi, pid_lo;
 289  292  
 290  293          /*
 291  294           * Decode the header
 292  295           */
↓ open down ↓ 76 lines elided ↑ open up ↑
 369  372                  if ((dialect = smb_xlate_dialect(negprot->ni_name)) < 0)
 370  373                          continue;
 371  374  
 372  375                  /*
 373  376                   * Conditionally recognize the SMB2 dialects.
 374  377                   */
 375  378                  if (dialect >= DIALECT_SMB2002 &&
 376  379                      skc->skc_max_protocol < SMB_VERS_2_BASE)
 377  380                          continue;
 378  381  
      382 +                /*
      383 +                 * We may not support SMB1; skip those dialects if true.
      384 +                 */
      385 +                if (dialect < DIALECT_SMB2002 &&
      386 +                    skc->skc_min_protocol > SMB_VERS_1)
      387 +                        continue;
      388 +
      389 +                if (dialect == DIALECT_SMB2002 &&
      390 +                    skc->skc_min_protocol > SMB_VERS_2_002)
      391 +                        continue;
      392 +
 379  393                  if (negprot->ni_dialect < dialect) {
 380  394                          negprot->ni_dialect = dialect;
 381  395                          negprot->ni_index = pos;
 382  396                  }
 383  397          }
 384  398  
 385      -        DTRACE_SMB_2(op__Negotiate__start, smb_request_t *, sr,
 386      -            smb_arg_negotiate_t, negprot);
      399 +        DTRACE_SMB_START(op__Negotiate, smb_request_t *, sr);
 387  400  
 388  401          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 389  402  }
 390  403  
 391  404  void
 392  405  smb_post_negotiate(smb_request_t *sr)
 393  406  {
 394  407          smb_arg_negotiate_t     *negprot = sr->sr_negprot;
 395  408  
 396      -        DTRACE_SMB_2(op__Negotiate__done, smb_request_t *, sr,
 397      -            smb_arg_negotiate_t, negprot);
      409 +        DTRACE_SMB_DONE(op__Negotiate, smb_request_t *, sr);
 398  410  
 399  411          bzero(negprot, sizeof (smb_arg_negotiate_t));
 400  412  }
 401  413  
 402  414  smb_sdrc_t
 403  415  smb_com_negotiate(smb_request_t *sr)
 404  416  {
 405  417          smb_session_t           *session = sr->session;
 406  418          smb_arg_negotiate_t     *negprot = sr->sr_negprot;
 407  419          uint16_t                secmode;
↓ open down ↓ 3 lines elided ↑ open up ↑
 411  423          int                     wclen;
 412  424          smb_msgbuf_t            mb;
 413  425          int                     rc;
 414  426  
 415  427          if (session->s_state != SMB_SESSION_STATE_ESTABLISHED) {
 416  428                  /* The protocol has already been negotiated. */
 417  429                  smbsr_error(sr, 0, ERRSRV, ERRerror);
 418  430                  return (SDRC_ERROR);
 419  431          }
 420  432  
      433 +        if (negprot->ni_index < 0) {
      434 +                cmn_err(CE_NOTE, "clnt %s no supported dialect",
      435 +                    sr->session->ip_addr_str);
      436 +                smbsr_error(sr, 0, ERRSRV, ERRerror);
      437 +                return (SDRC_DROP_VC);
      438 +        }
      439 +
 421  440          /*
 422  441           * Special case for negotiating SMB2 from SMB1.  The client
 423  442           * includes the  "SMB 2..." dialects in the SMB1 negotiate,
 424  443           * and if SMB2 is enabled, we choose one of those and then
 425  444           * send an SMB2 reply to that SMB1 request.  Yes, it's very
 426  445           * strange, but this SMB1 request can have an SMB2 reply!
 427  446           * To accomplish this, we let the SMB2 code send the reply
 428  447           * and return the special code SDRC_NO_REPLY to the SMB1
 429  448           * dispatch logic so it will NOT send an SMB1 reply.
 430  449           * (Or possibly send an SMB1 error reply.)
 431  450           */
 432  451          if (negprot->ni_dialect >= DIALECT_SMB2002) {
 433  452                  rc = smb1_negotiate_smb2(sr);
 434  453                  ASSERT(rc == SDRC_NO_REPLY ||
 435  454                      rc == SDRC_DROP_VC || rc == SDRC_ERROR);
 436  455                  return (rc);
 437  456          }
 438  457  
 439      -        session->secmode = NEGOTIATE_ENCRYPT_PASSWORDS |
      458 +        session->srv_secmode = NEGOTIATE_ENCRYPT_PASSWORDS |
 440  459              NEGOTIATE_USER_SECURITY;
 441      -        secmode = session->secmode;
      460 +        secmode = session->srv_secmode;
 442  461          sesskey = session->sesskey;
 443  462  
 444  463          negprot->ni_servertime.tv_sec = gethrestime_sec();
 445  464          negprot->ni_servertime.tv_nsec = 0;
 446  465          negprot->ni_tzcorrection = sr->sr_gmtoff / 60;
 447  466          negprot->ni_maxmpxcount = smb_maxmpxcount;
 448  467          negprot->ni_keylen = SMB_CHALLENGE_SZ;
 449  468          bcopy(&session->challenge_key, negprot->ni_key, SMB_CHALLENGE_SZ);
 450  469          nbdomain = sr->sr_cfg->skc_nbdomain;
 451  470  
↓ open down ↓ 72 lines elided ↑ open up ↑
 524  543                  /*
 525  544                   * Allow SMB signatures if using encrypted passwords
 526  545                   */
 527  546                  if ((secmode & NEGOTIATE_ENCRYPT_PASSWORDS) &&
 528  547                      sr->sr_cfg->skc_signing_enable) {
 529  548                          secmode |= NEGOTIATE_SECURITY_SIGNATURES_ENABLED;
 530  549                          if (sr->sr_cfg->skc_signing_required)
 531  550                                  secmode |=
 532  551                                      NEGOTIATE_SECURITY_SIGNATURES_REQUIRED;
 533  552  
 534      -                        session->secmode = secmode;
      553 +                        session->srv_secmode = secmode;
 535  554                  }
 536  555  
 537  556                  /*
 538  557                   * Does the client want Extended Security?
 539  558                   * (and if we have it enabled)
 540  559                   * If so, handle as if a different dialect.
 541  560                   */
 542  561                  if ((sr->smb_flg2 & SMB_FLAGS2_EXT_SEC) != 0 &&
 543  562                      (negprot->ni_capabilities & CAP_EXTENDED_SECURITY) != 0)
 544  563                          goto NT_LM_0_12_ext_sec;
↓ open down ↓ 104 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX