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-15577 SMB2 ioct dfs_get_referral returns wrong error
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-15577 SMB2 ioct dfs_get_referral returns wrong error
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@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>
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)

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbsrv/smb_dfs.c
          +++ new/usr/src/uts/common/fs/smbsrv/smb_dfs.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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 2010 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   *
  25      - * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
       25 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  26   26   */
  27   27  
  28   28  #include <smbsrv/smb_kproto.h>
  29   29  #include <smbsrv/smb_dfs.h>
  30   30  #include <smbsrv/smb_door.h>
  31      -#include <smbsrv/winioctl.h>
       31 +#include <smb/winioctl.h>
  32   32  
  33   33  /*
  34   34   * Get Referral response header flags
  35   35   * For exact meaning refer to MS-DFSC spec.
  36   36   *
  37   37   * R: ReferralServers
  38   38   * S: StorageServers
  39   39   * T: TargetFailback
  40   40   */
  41   41  #define DFS_HDRFLG_R            0x00000001
↓ open down ↓ 35 lines elided ↑ open up ↑
  77   77      dfs_info_t *);
  78   78  static uint32_t smb_dfs_encode_refv3x(smb_request_t *, mbuf_chain_t *,
  79   79      dfs_info_t *, uint16_t);
  80   80  static void smb_dfs_encode_targets(mbuf_chain_t *, dfs_info_t *);
  81   81  static uint32_t smb_dfs_referrals_get(smb_request_t *, char *, dfs_reftype_t,
  82   82      dfs_referral_response_t *);
  83   83  static void smb_dfs_referrals_free(dfs_referral_response_t *);
  84   84  static uint16_t smb_dfs_referrals_unclen(dfs_info_t *, uint16_t);
  85   85  
  86   86  /*
       87 + * Handle device type FILE_DEVICE_DFS
       88 + * for smb2_ioctl
       89 + */
       90 +uint32_t
       91 +smb_dfs_fsctl(smb_request_t *sr, smb_fsctl_t *fsctl)
       92 +{
       93 +        uint32_t status;
       94 +
       95 +        if (!STYPE_ISIPC(sr->tid_tree->t_res_type))
       96 +                return (NT_STATUS_INVALID_DEVICE_REQUEST);
       97 +
       98 +        switch (fsctl->CtlCode) {
       99 +        case FSCTL_DFS_GET_REFERRALS:
      100 +                status = smb_dfs_get_referrals(sr, fsctl);
      101 +                break;
      102 +        case FSCTL_DFS_GET_REFERRALS_EX: /* XXX - todo */
      103 +        default:
      104 +                status = NT_STATUS_NOT_SUPPORTED;
      105 +        }
      106 +
      107 +        return (status);
      108 +}
      109 +
      110 +/*
  87  111   * Note: SMB1 callers in smb_trans2_dfs.c
  88  112   * smb_com_trans2_report_dfs_inconsistency
  89  113   * smb_com_trans2_get_dfs_referral
  90  114   */
  91  115  
  92  116  /*
  93  117   * See [MS-DFSC] for details about this command
      118 + * Handles FSCTL_DFS_GET_REFERRALS (only)
  94  119   */
  95  120  uint32_t
  96  121  smb_dfs_get_referrals(smb_request_t *sr, smb_fsctl_t *fsctl)
  97  122  {
  98  123          dfs_info_t *referrals;
  99  124          dfs_referral_response_t refrsp;
 100  125          dfs_reftype_t reftype;
 101  126          char *path;
 102  127          uint16_t maxver;
 103  128          uint32_t status;
↓ open down ↓ 6 lines elided ↑ open up ↑
 110  135          ASSERT(STYPE_ISIPC(sr->tid_tree->t_res_type));
 111  136  
 112  137          /*
 113  138           * XXX Instead of decoding the referral request and encoding
 114  139           * the response here (in-kernel) we could pass the given
 115  140           * request buffer in our door call, and let that return the
 116  141           * response buffer ready to stuff into out_mbc.  That would
 117  142           * allow all this decoding/encoding to happen at user-level.
 118  143           * (and most of this file would go away. :-)
 119  144           */
 120      -        switch (fsctl->CtlCode) {
 121      -        case FSCTL_DFS_GET_REFERRALS:
 122      -                /*
 123      -                 * Input data is (w) MaxReferralLevel, (U) path
 124      -                 */
 125      -                rc = smb_mbc_decodef(fsctl->in_mbc, "%wu",
 126      -                    sr, &maxver, &path);
 127      -                if (rc != 0)
 128      -                        return (NT_STATUS_INVALID_PARAMETER);
 129      -                break;
 130  145  
 131      -        case FSCTL_DFS_GET_REFERRALS_EX: /* XXX - todo */
 132      -        default:
 133      -                return (NT_STATUS_NOT_SUPPORTED);
 134      -        }
      146 +        /*
      147 +         * Input data is (w) MaxReferralLevel, (U) path
      148 +         */
      149 +        rc = smb_mbc_decodef(fsctl->in_mbc, "%wu",
      150 +            sr, &maxver, &path);
      151 +        if (rc != 0)
      152 +                return (NT_STATUS_INVALID_PARAMETER);
 135  153  
 136  154          reftype = smb_dfs_get_reftype((const char *)path);
 137  155          switch (reftype) {
 138  156          case DFS_REFERRAL_INVALID:
 139  157                  /* Need to check the error for this case */
 140  158                  return (NT_STATUS_INVALID_PARAMETER);
 141  159  
 142  160          case DFS_REFERRAL_DOMAIN:
 143  161          case DFS_REFERRAL_DC:
 144  162                  /* MS-DFSC: this error is returned by non-DC root */
↓ open down ↓ 239 lines elided ↑ open up ↑
 384  402  }
 385  403  
 386  404  /*
 387  405   * Prepare a response with V3/V4 referral format.
 388  406   *
 389  407   * For more details, see comments for smb_dfs_encode_refv2() or see
 390  408   * MS-DFSC specification.
 391  409   */
 392  410  static uint32_t
 393  411  smb_dfs_encode_refv3x(smb_request_t *sr, mbuf_chain_t *mbc,
 394      -        dfs_info_t *referrals,
 395      -    uint16_t ver)
      412 +        dfs_info_t *referrals, uint16_t ver)
 396  413  {
 397  414          _NOTE(ARGUNUSED(sr))
 398  415          uint16_t entsize, rep_bufsize, hdrsize;
 399  416          uint16_t server_type;
 400  417          uint16_t flags = 0;
 401  418          uint16_t path_offs, altpath_offs, netpath_offs;
 402  419          uint16_t targetsz, total_targetsz = 0;
 403  420          uint16_t dfs_pathsz;
 404  421          uint16_t r;
 405  422  
↓ open down ↓ 91 lines elided ↑ open up ↑
 497  514          req.rq_type = reftype;
 498  515          req.rq_path = dfs_path;
 499  516  
 500  517          bzero(refrsp, sizeof (dfs_referral_response_t));
 501  518          refrsp->rp_status = NT_STATUS_NOT_FOUND;
 502  519  
 503  520          rc = smb_kdoor_upcall(sr->sr_server, SMB_DR_DFS_GET_REFERRALS,
 504  521              &req, dfs_referral_query_xdr, refrsp, dfs_referral_response_xdr);
 505  522  
 506  523          if (rc != 0 || refrsp->rp_status != ERROR_SUCCESS) {
 507      -                return (NT_STATUS_NO_SUCH_DEVICE);
      524 +                return (NT_STATUS_FS_DRIVER_REQUIRED);
 508  525          }
 509  526  
 510  527          (void) strsubst(refrsp->rp_referrals.i_uncpath, '/', '\\');
 511  528          return (NT_STATUS_SUCCESS);
 512  529  }
 513  530  
 514  531  static void
 515  532  smb_dfs_referrals_free(dfs_referral_response_t *refrsp)
 516  533  {
 517  534          xdr_free(dfs_referral_response_xdr, (char *)refrsp);
↓ open down ↓ 24 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX