Print this page
NEX-14666 Need to provide SMB 2.1 Client
NEX-17187 panic in smbfs_acl_store
NEX-17231 smbfs create xattr files finds wrong file
NEX-17224 smbfs lookup EINVAL should be ENOENT
NEX-17260 SMB1 client fails to list directory after NEX-14666
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
and: (cleanup)
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-5844 want SMB2 ioctl FSCTL_SRV_COPYCHUNK
NEX-6124 smb_fsop_read/write should allow file != sr->fid_ofile
NEX-6125 smbtorture invalid response with smb2.ioctl
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-4083 Upstream changes from illumos 5917 and 5995
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-2188 Browsing top level share produces RPC error 1728
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-48 Panic with smbtorture raw.scan-eamax (fix dtrace probes)
SMB-39 Use AF_UNIX pipes for RPC
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).
SMB-48 Panic with smbtorture raw.scan-eamax
re #11215 rb3676 sesctl to SGI JBOD hangs in biowait() with a command stuck in mptsas driver
re #10734 NT Trans. Notify returning too quickly

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbsrv/smb_common_transact.c
          +++ new/usr/src/uts/common/fs/smbsrv/smb_common_transact.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  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  /*
  23   23   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
       24 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  25   25   */
  26   26  
  27   27  #include <smbsrv/smb_kproto.h>
  28   28  #include <smbsrv/smb_fsops.h>
  29   29  #include <smbsrv/smb_share.h>
  30   30  #include <smbsrv/string.h>
  31   31  #include <smbsrv/nmpipes.h>
  32   32  #include <smbsrv/mailslot.h>
  33      -#include <smbsrv/winioctl.h>
       33 +#include <smb/winioctl.h>
  34   34  
  35   35  /*
  36   36   * count of bytes in server response packet
  37   37   * except parameters and data. Note that setup
  38   38   * word count is zero.
  39   39   */
  40   40  #define RESP_HEADER_LEN         24
  41   41  
  42   42  /*
  43   43   * We started by using common functions for transaction/transaction2
↓ open down ↓ 4 lines elided ↑ open up ↑
  48   48   * be applied to its peer.
  49   49   */
  50   50  
  51   51  static int smb_trans_ready(smb_xa_t *);
  52   52  static smb_sdrc_t smb_trans_dispatch(smb_request_t *, smb_xa_t *);
  53   53  static smb_sdrc_t smb_trans2_dispatch(smb_request_t *, smb_xa_t *);
  54   54  
  55   55  smb_sdrc_t
  56   56  smb_pre_transaction(smb_request_t *sr)
  57   57  {
  58      -        DTRACE_SMB_1(op__Transaction__start, smb_request_t *, sr);
       58 +        DTRACE_SMB_START(op__Transaction, smb_request_t *, sr);
  59   59          return (SDRC_SUCCESS);
  60   60  }
  61   61  
  62   62  void
  63   63  smb_post_transaction(smb_request_t *sr)
  64   64  {
  65      -        DTRACE_SMB_1(op__Transaction__done, smb_request_t *, sr);
       65 +        DTRACE_SMB_DONE(op__Transaction, smb_request_t *, sr);
  66   66  }
  67   67  
  68   68  smb_sdrc_t
  69   69  smb_com_transaction(smb_request_t *sr)
  70   70  {
  71   71          int             rc;
  72   72          unsigned char   msrcnt, suwcnt;
  73   73          uint16_t        tpscnt, tdscnt, mprcnt, mdrcnt, flags;
  74   74          uint16_t        pscnt, psoff, dscnt, dsoff;
  75   75          uint32_t        timeo;
↓ open down ↓ 73 lines elided ↑ open up ↑
 149  149                  smbsr_error(sr, 0, ERRDOS, ERRbadformat);
 150  150                  return (SDRC_ERROR);
 151  151          }
 152  152  
 153  153          return (smb_trans_dispatch(sr, xa));
 154  154  }
 155  155  
 156  156  smb_sdrc_t
 157  157  smb_pre_transaction_secondary(smb_request_t *sr)
 158  158  {
 159      -        DTRACE_SMB_1(op__TransactionSecondary__start, smb_request_t *, sr);
      159 +        DTRACE_SMB_START(op__TransactionSecondary, smb_request_t *, sr);
 160  160          return (SDRC_SUCCESS);
 161  161  }
 162  162  
 163  163  void
 164  164  smb_post_transaction_secondary(smb_request_t *sr)
 165  165  {
 166      -        DTRACE_SMB_1(op__TransactionSecondary__done, smb_request_t *, sr);
      166 +        DTRACE_SMB_DONE(op__TransactionSecondary, smb_request_t *, sr);
 167  167  }
 168  168  
 169  169  smb_sdrc_t
 170  170  smb_com_transaction_secondary(smb_request_t *sr)
 171  171  {
 172  172          uint16_t tpscnt, tdscnt, pscnt, psdisp;
 173  173          uint16_t dscnt, dsoff, dsdisp, psoff;
 174  174          smb_xa_t *xa;
 175  175          int rc;
 176  176  
↓ open down ↓ 70 lines elided ↑ open up ↑
 247  247  
 248  248          if (!smb_xa_complete(xa))
 249  249                  return (SDRC_NO_REPLY);
 250  250  
 251  251          return (smb_trans_dispatch(sr, xa));
 252  252  }
 253  253  
 254  254  smb_sdrc_t
 255  255  smb_pre_ioctl(smb_request_t *sr)
 256  256  {
 257      -        DTRACE_SMB_1(op__Ioctl__start, smb_request_t *, sr);
      257 +        DTRACE_SMB_START(op__Ioctl, smb_request_t *, sr);
 258  258          return (SDRC_SUCCESS);
 259  259  }
 260  260  
 261  261  void
 262  262  smb_post_ioctl(smb_request_t *sr)
 263  263  {
 264      -        DTRACE_SMB_1(op__Ioctl__done, smb_request_t *, sr);
      264 +        DTRACE_SMB_DONE(op__Ioctl, smb_request_t *, sr);
 265  265  }
 266  266  
 267  267  smb_sdrc_t
 268  268  smb_com_ioctl(smb_request_t *sr)
 269  269  {
 270  270          uint16_t fid, category, function, tpscnt, tdscnt, mprcnt;
 271  271          uint16_t mdrcnt, pscnt, pdoff, dscnt, dsoff;
 272  272          uint32_t timeout;
 273  273          int rc;
 274  274  
↓ open down ↓ 3 lines elided ↑ open up ↑
 278  278  
 279  279          if (rc != 0)
 280  280                  return (SDRC_ERROR);
 281  281  
 282  282          return (SDRC_NOT_IMPLEMENTED);
 283  283  }
 284  284  
 285  285  smb_sdrc_t
 286  286  smb_pre_transaction2(smb_request_t *sr)
 287  287  {
 288      -        DTRACE_SMB_1(op__Transaction2__start, smb_request_t *, sr);
      288 +        DTRACE_SMB_START(op__Transaction2, smb_request_t *, sr);
 289  289          return (SDRC_SUCCESS);
 290  290  }
 291  291  
 292  292  void
 293  293  smb_post_transaction2(smb_request_t *sr)
 294  294  {
 295      -        DTRACE_SMB_1(op__Transaction2__done, smb_request_t *, sr);
      295 +        DTRACE_SMB_DONE(op__Transaction2, smb_request_t *, sr);
 296  296  }
 297  297  
 298  298  smb_sdrc_t
 299  299  smb_com_transaction2(struct smb_request *sr)
 300  300  {
 301  301          unsigned char   msrcnt, suwcnt;
 302  302          uint16_t        tpscnt, tdscnt, mprcnt, mdrcnt, flags;
 303  303          uint16_t        pscnt, psoff, dscnt, dsoff;
 304  304          uint32_t        timeo;
 305  305          smb_xa_t *xa;
↓ open down ↓ 55 lines elided ↑ open up ↑
 361  361                  smbsr_error(sr, 0, ERRDOS, ERRbadformat);
 362  362                  return (SDRC_ERROR);
 363  363          }
 364  364  
 365  365          return (smb_trans2_dispatch(sr, xa));
 366  366  }
 367  367  
 368  368  smb_sdrc_t
 369  369  smb_pre_transaction2_secondary(smb_request_t *sr)
 370  370  {
 371      -        DTRACE_SMB_1(op__Transaction2Secondary__start, smb_request_t *, sr);
      371 +        DTRACE_SMB_START(op__Transaction2Secondary, smb_request_t *, sr);
 372  372          return (SDRC_SUCCESS);
 373  373  }
 374  374  
 375  375  void
 376  376  smb_post_transaction2_secondary(smb_request_t *sr)
 377  377  {
 378      -        DTRACE_SMB_1(op__Transaction2Secondary__done, smb_request_t *, sr);
      378 +        DTRACE_SMB_DONE(op__Transaction2Secondary, smb_request_t *, sr);
 379  379  }
 380  380  
 381  381  smb_sdrc_t
 382  382  smb_com_transaction2_secondary(smb_request_t *sr)
 383  383  {
 384  384          uint16_t tpscnt, tdscnt, fid;
 385  385          uint16_t pscnt, psoff, psdisp, dscnt, dsoff, dsdisp;
 386  386          smb_xa_t *xa;
 387  387          int rc;
 388  388  
↓ open down ↓ 162 lines elided ↑ open up ↑
 551  551              param_pad,
 552  552              &xa->rep_param_mb,
 553  553              data_pad,
 554  554              &xa->rep_data_mb);
 555  555          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 556  556  }
 557  557  
 558  558  smb_sdrc_t
 559  559  smb_pre_nt_transact(smb_request_t *sr)
 560  560  {
 561      -        DTRACE_SMB_1(op__NtTransact__start, smb_request_t *, sr);
      561 +        DTRACE_SMB_START(op__NtTransact, smb_request_t *, sr);
 562  562          return (SDRC_SUCCESS);
 563  563  }
 564  564  
 565  565  void
 566  566  smb_post_nt_transact(smb_request_t *sr)
 567  567  {
 568      -        DTRACE_SMB_1(op__NtTransact__done, smb_request_t *, sr);
      568 +        DTRACE_SMB_DONE(op__NtTransact, smb_request_t *, sr);
 569  569  }
 570  570  
 571  571  smb_sdrc_t
 572  572  smb_com_nt_transact(struct smb_request *sr)
 573  573  {
 574  574          uint16_t        Function;
 575  575          unsigned char   MaxSetupCount, SetupCount;
 576  576          uint32_t        TotalParameterCount, TotalDataCount;
 577  577          uint32_t        MaxParameterCount, MaxDataCount, pscnt;
 578  578          uint32_t        psoff, dscnt, dsoff;
↓ open down ↓ 58 lines elided ↑ open up ↑
 637  637                  smbsr_error(sr, 0, ERRDOS, ERRbadformat);
 638  638                  return (SDRC_ERROR);
 639  639          }
 640  640  
 641  641          return (smb_nt_trans_dispatch(sr, xa));
 642  642  }
 643  643  
 644  644  smb_sdrc_t
 645  645  smb_pre_nt_transact_secondary(smb_request_t *sr)
 646  646  {
 647      -        DTRACE_SMB_1(op__NtTransactSecondary__start, smb_request_t *, sr);
      647 +        DTRACE_SMB_START(op__NtTransactSecondary, smb_request_t *, sr);
 648  648          return (SDRC_SUCCESS);
 649  649  }
 650  650  
 651  651  void
 652  652  smb_post_nt_transact_secondary(smb_request_t *sr)
 653  653  {
 654      -        DTRACE_SMB_1(op__NtTransactSecondary__done, smb_request_t *, sr);
      654 +        DTRACE_SMB_DONE(op__NtTransactSecondary, smb_request_t *, sr);
 655  655  }
 656  656  
 657  657  smb_sdrc_t
 658  658  smb_com_nt_transact_secondary(struct smb_request *sr)
 659  659  {
 660  660          uint16_t tpscnt, tdscnt, fid;
 661  661          uint16_t pscnt, psoff, psdisp, dscnt, dsoff, dsdisp;
 662  662          smb_xa_t *xa;
 663  663          int rc;
 664  664  
↓ open down ↓ 760 lines elided ↑ open up ↑
1425 1425           * fsctl "output" is what we read from the pipe (and becomes the
1426 1426           * transaction receive data).
1427 1427           */
1428 1428          fsctl.CtlCode = FSCTL_PIPE_TRANSCEIVE;
1429 1429          fsctl.InputCount = xa->smb_tdscnt; /* write count */
1430 1430          fsctl.OutputCount = 0; /* minimum to read from the pipe */
1431 1431          fsctl.MaxOutputResp = xa->smb_mdrcnt;   /* max to read */
1432 1432          fsctl.in_mbc = &xa->req_data_mb; /* write from here */
1433 1433          fsctl.out_mbc = &xa->rep_data_mb; /* read into here */
1434 1434  
1435      -        status = smb_opipe_fsctl(sr, &fsctl);
     1435 +        status = smb_opipe_transceive(sr, &fsctl);
1436 1436          if (status) {
1437 1437                  smbsr_status(sr, status, 0, 0);
1438 1438                  if (NT_SC_SEVERITY(status) == NT_STATUS_SEVERITY_ERROR)
1439 1439                          return (SDRC_ERROR);
1440 1440                  /* Warnings like NT_STATUS_BUFFER_OVERFLOW are OK */
1441 1441          }
1442 1442  
1443 1443          return (SDRC_SUCCESS);
1444 1444  }
1445 1445  
↓ open down ↓ 310 lines elided ↑ open up ↑
1756 1756                  data_off = param_off + n_param + data_pad;
1757 1757                  fmt = "bww2.wwwwwwb.Cw#.CwC";
1758 1758                  nt_unknown_secret = 0x0100;
1759 1759          }
1760 1760          else
1761 1761          {
1762 1762                  data_pad = (param_off + n_param) & 1; /* Pad to short */
1763 1763                  /* Param off from hdr start */
1764 1764                  data_off = param_off + n_param + data_pad;
1765 1765                  fmt = "bww2.wwwwwwb.Cw#.C#.C";
1766      -                nt_unknown_secret = data_pad;
     1766 +                nt_unknown_secret = (uint16_t)data_pad;
1767 1767          }
1768 1768  
1769 1769          total_bytes = param_pad + n_param + data_pad + n_data;
1770 1770  
1771 1771          rc = smbsr_encode_result(sr, 10+n_setup, total_bytes,
1772 1772              fmt,
1773 1773              10 + n_setup,               /* wct */
1774 1774              n_param,                    /* Total Parameter Bytes */
1775 1775              n_data /* + data_pad */,    /* Total Data Bytes */
1776 1776              n_param,                    /* Total Parameter Bytes this buffer */
↓ open down ↓ 282 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX